-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
193 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
*.jl.mem | ||
*~ | ||
.idea/ | ||
.vscode/ | ||
target/ | ||
project/ | ||
*.class | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,51 @@ | ||
module Spark | ||
|
||
export | ||
SparkConf, | ||
SparkContext, | ||
RDD, | ||
JuliaRDD, | ||
JavaRDD, | ||
text_file, | ||
parallelize, | ||
map, | ||
map_pair, | ||
map_partitions, | ||
map_partitions_pair, | ||
map_partitions_with_index, | ||
reduce, | ||
filter, | ||
collect, | ||
count, | ||
id, | ||
num_partitions, | ||
close, | ||
@attach, | ||
share_variable, | ||
@share, | ||
flat_map, | ||
flat_map_pair, | ||
cartesian, | ||
group_by_key, | ||
reduce_by_key, | ||
cache, | ||
repartition, | ||
coalesce, | ||
pipe, | ||
# SparkConf, | ||
# SparkContext, | ||
# RDD, | ||
# JuliaRDD, | ||
# JavaRDD, | ||
# text_file, | ||
# parallelize, | ||
# map, | ||
# map_pair, | ||
# map_partitions, | ||
# map_partitions_pair, | ||
# map_partitions_with_index, | ||
# reduce, | ||
# filter, | ||
# collect, | ||
# count, | ||
# id, | ||
# num_partitions, | ||
# close, | ||
# @attach, | ||
# share_variable, | ||
# @share, | ||
# flat_map, | ||
# flat_map_pair, | ||
# cartesian, | ||
# group_by_key, | ||
# reduce_by_key, | ||
# cache, | ||
# repartition, | ||
# coalesce, | ||
# pipe, | ||
# SQL | ||
SparkSession, | ||
Dataset, | ||
sql, | ||
count, | ||
read_json, | ||
write_json, | ||
read_parquet, | ||
write_parquet, | ||
read_df, | ||
write_df | ||
|
||
|
||
|
||
include("core.jl") | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# # const JFile = @jimport java.io.File | ||
# const JToolProvider = @jimport javax.tools.ToolProvider | ||
# const JJavaCompiler = @jimport javax.tools.JavaCompiler | ||
# const JInputStream = @jimport java.io.InputStream | ||
# const JOutputStream = @jimport java.io.OutputStream | ||
# const JArray = @jimport java.lang.reflect.Array | ||
|
||
const JInMemoryJavaCompiler = @jimport org.mdkt.compiler.InMemoryJavaCompiler | ||
|
||
# const JUDF1 = @jimport org.apache.spark.sql.api.java.UDF1 | ||
|
||
|
||
function mkclass(name::String, src::String) | ||
jcompiler = jcall(JInMemoryJavaCompiler, "newInstance", JInMemoryJavaCompiler, ()) | ||
return jcall(jcompiler, "compile", JClass, (JString, JString), name, src) | ||
end | ||
|
||
|
||
function instantiate(name::String, src::String) | ||
jclass = mkclass(name, src) | ||
return jcall(jclass, "newInstance", JObject, ()) | ||
end | ||
|
||
|
||
function main() | ||
init() | ||
name = "julia.compiled.Dummy" | ||
src = """ | ||
package julia.compiled; | ||
import java.util.function.Function; | ||
public class Dummy implements Function<String, String> { | ||
@Override | ||
public String apply(String name) { | ||
return "Hello, " + name; | ||
} | ||
public void hello() { | ||
System.out.println("Hello!"); | ||
} | ||
} | ||
""" | ||
jc = mkclass(name, src) | ||
jo = jcall(jc, "newInstance", JObject, ()) | ||
# jo = instantiate(name, src) | ||
# can't call inherited methods like this? | ||
jcall(jo, "apply", JString, (JString,), "Lee") | ||
jcall2(jo, "hello", Nothing, ()) | ||
jcall(jc, "getMethods", Vector{JMethod}, ()) | ||
end | ||
|
||
|
||
function jcall2(jobj::JavaObject, name::String, ret_type, arg_types, args...) | ||
jclass = getclass(jobj) | ||
jargs = [a for a in convert.(arg_types, args)] # convert to Vector | ||
meth = jcall(jclass, "getMethod", JMethod, (JString, Vector{JClass}), name, getclass.(jargs)) | ||
return meth(jobj, jargs...) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
struct DotCaller{O, Fn} | ||
obj::O | ||
fn::Fn | ||
end | ||
|
||
DotCaller(obj, fn) = DotCaller{typeof(obj), typeof(fn)}(obj, fn) | ||
|
||
(c::DotCaller)(args...) = c.fn(c.obj, args...) | ||
|
||
|
||
|
||
macro dot_call(T) | ||
return quote | ||
function Base.getproperty(obj::$T, prop::Symbol) | ||
if prop in names(@__MODULE__) | ||
fn = getfield(@__MODULE__, prop) | ||
return DotCaller(obj, fn) | ||
else | ||
return getfield(obj, prop) | ||
end | ||
end | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
import Base: map, reduce, count, collect, close | ||
import Base.Iterators | ||
|
||
# config | ||
const JSparkConf = @jimport org.apache.spark.SparkConf | ||
# context | ||
const JSparkContext = @jimport org.apache.spark.SparkContext | ||
const JJavaSparkContext = @jimport org.apache.spark.api.java.JavaSparkContext | ||
|
||
# RDD | ||
const JRDD = @jimport org.apache.spark.rdd.RDD | ||
const JJavaRDD = @jimport org.apache.spark.api.java.JavaRDD | ||
const JJavaPairRDD = @jimport org.apache.spark.api.java.JavaPairRDD | ||
const JJuliaRDD = @jimport org.apache.spark.api.julia.JuliaRDD | ||
const JJuliaPairRDD = @jimport org.apache.spark.api.julia.JuliaPairRDD | ||
# utils | ||
const JRDDUtils = @jimport org.apache.spark.api.julia.RDDUtils | ||
# Java utils | ||
const JIterator = @jimport java.util.Iterator | ||
const JList = @jimport java.util.List | ||
const JMap = @jimport java.util.Map | ||
const JArrayList = @jimport java.util.ArrayList | ||
const JHashMap = @jimport java.util.HashMap | ||
const JSystem = @jimport java.lang.System | ||
|
||
|
||
include("serialization.jl") | ||
include("config.jl") | ||
include("context.jl") | ||
include("rdd.jl") | ||
include("attach.jl") | ||
include("worker.jl") |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
include("basic.jl") | ||
include("map.jl") | ||
include("map_partitions.jl") | ||
include("attach.jl") | ||
include("reduce.jl") | ||
include("text_file.jl") | ||
include("share_variable.jl") | ||
include("flat_map.jl") | ||
include("cartesian.jl") | ||
include("group_by_key.jl") | ||
include("reduce_by_key.jl") | ||
include("collect_pair.jl") | ||
include("map_pair.jl") | ||
include("julian_versions.jl") | ||
include("repartition_coalesce.jl") | ||
include("filter.jl") | ||
include("pipe.jl") |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters