zillabyte 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +9 -9
- data/ruby/lib/zillabyte.rb +3 -15
- data/ruby/lib/zillabyte/harness/app.rb +59 -0
- data/ruby/lib/zillabyte/harness/each.rb +5 -5
- data/ruby/lib/zillabyte/harness/helper.rb +139 -153
- data/ruby/lib/zillabyte/harness/live_delegator.rb +52 -23
- data/ruby/lib/zillabyte/harness/source.rb +15 -21
- data/ruby/lib/zillabyte/harness/stream.rb +86 -0
- data/ruby/lib/zillabyte/version.rb +1 -1
- metadata +7 -9
- data/ruby/lib/zillabyte/harness/simple_aggregate.rb +0 -144
- data/ruby/lib/zillabyte/harness/simple_function.rb +0 -134
- data/ruby/lib/zillabyte/harness/simple_source.rb +0 -93
- data/ruby/lib/zillabyte/harness/topology.rb +0 -127
@@ -1,134 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
|
3
|
-
class Zillabyte::Harness::SimpleFunction
|
4
|
-
attr_accessor :_nodes, :_relation, :_matches, :_emits, :_prepare, :_execute, :_name, :_info_file, :_options
|
5
|
-
|
6
|
-
def self.build(*args, &block)
|
7
|
-
h = Zillabyte::Harness::SimpleFunction.new()
|
8
|
-
h.instance_eval(&block)
|
9
|
-
#yield(h)
|
10
|
-
h._name = h._name
|
11
|
-
Zillabyte::Harness::Helper.check_name("simple_function", h._name, {})
|
12
|
-
Zillabyte::Harness::Helper.check_emits("simple_function", h._emits, {})
|
13
|
-
generic_emits = h.get_generic_emits
|
14
|
-
|
15
|
-
h._nodes = []
|
16
|
-
h._options = Zillabyte::Harness::Helper.opt_parser()
|
17
|
-
|
18
|
-
if(h._options[:command] == :info)
|
19
|
-
h._info_file = File.open(h._options[:file],"w+")
|
20
|
-
hash = {"language" => "ruby", "name" => h._name}
|
21
|
-
Zillabyte::Harness::Helper.write_hash_to_file(hash, h._info_file)
|
22
|
-
end
|
23
|
-
|
24
|
-
h.build_source()
|
25
|
-
fn = h.build_each(generic_emits)
|
26
|
-
h.build_sink()
|
27
|
-
|
28
|
-
if(h._options[:command] == :execute and h._options[:name] == 'each')
|
29
|
-
pipe_name = h._options[:pipe]
|
30
|
-
c = Zillabyte::Harness::EachController.new(fn, progress = Zillabyte::Common::Progress.new)
|
31
|
-
c.run(pipe_name)
|
32
|
-
end
|
33
|
-
|
34
|
-
h
|
35
|
-
end
|
36
|
-
|
37
|
-
def name(v)
|
38
|
-
@_name = v
|
39
|
-
end
|
40
|
-
|
41
|
-
def matches(v, options = {})
|
42
|
-
case v
|
43
|
-
when String
|
44
|
-
@_relation = { :query => v, :options => options.is_a?(Hash) ? options : {} }
|
45
|
-
when Array
|
46
|
-
@_matches = v
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def emits(v)
|
51
|
-
@_emits = v
|
52
|
-
end
|
53
|
-
|
54
|
-
def prepare(&block)
|
55
|
-
@_prepare = block
|
56
|
-
end
|
57
|
-
|
58
|
-
def execute(&block)
|
59
|
-
@_execute = block
|
60
|
-
end
|
61
|
-
|
62
|
-
def get_generic_emits()
|
63
|
-
generic_emits = []
|
64
|
-
@_emits.each do |relation|
|
65
|
-
temit = []
|
66
|
-
relation[1].each do |column|
|
67
|
-
column.each do |col, type|
|
68
|
-
temit << col
|
69
|
-
end
|
70
|
-
end
|
71
|
-
generic_emits << [relation[0], temit]
|
72
|
-
end
|
73
|
-
generic_emits
|
74
|
-
end
|
75
|
-
|
76
|
-
def build_source()
|
77
|
-
h = Zillabyte::Harness::Source.new(false)
|
78
|
-
h._matches = @_matches if @_matches
|
79
|
-
h._relation = @_relation if @_relation
|
80
|
-
Zillabyte::Harness::Helper.check_source("simple_function", h)
|
81
|
-
@_nodes << h
|
82
|
-
if(@_options[:command] == :info)
|
83
|
-
info_hash = {"name" => h._name, "type" => h._type}
|
84
|
-
if(h._relation)
|
85
|
-
info_hash["relation"] = h._relation
|
86
|
-
elsif(h._matches)
|
87
|
-
info_hash["matches"] = h._matches
|
88
|
-
end
|
89
|
-
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, @_info_file)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def build_each(generic_emits)
|
94
|
-
h = Zillabyte::Harness::Each.new()
|
95
|
-
h._name = 'each'
|
96
|
-
h._emits = generic_emits
|
97
|
-
h._prepare = @_prepare
|
98
|
-
h._execute = @_execute
|
99
|
-
@_nodes << h
|
100
|
-
if(@_options[:command] == :info)
|
101
|
-
info_hash = {"name" => h._name, "type" => h._type, "emits" => h._emits}
|
102
|
-
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, @_info_file)
|
103
|
-
end
|
104
|
-
h
|
105
|
-
end
|
106
|
-
|
107
|
-
def build_sink()
|
108
|
-
# Construct the sink...
|
109
|
-
n_sinks = @_emits.length
|
110
|
-
@_emits.each do |emit|
|
111
|
-
h = Zillabyte::Harness::Sink.new()
|
112
|
-
h._name = "sink"
|
113
|
-
h._relation = emit[0]
|
114
|
-
columns = emit[1]
|
115
|
-
columns.each do |col|
|
116
|
-
col.each do |cname, ctype|
|
117
|
-
h.column(cname, ctype)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
if(n_sinks > 1)
|
121
|
-
h._consumes = h._name
|
122
|
-
end
|
123
|
-
@_nodes << h
|
124
|
-
if(@_options[:command] == :info)
|
125
|
-
info_hash = {"name" => h._name, "type" => h._type, "columns" => h._columns, "relation" => h._relation || h._name}
|
126
|
-
if(h._consumes)
|
127
|
-
info_hash["consumes"] = h._consumes
|
128
|
-
end
|
129
|
-
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, @_info_file)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
|
3
|
-
class Zillabyte::Harness::SimpleSource
|
4
|
-
attr_accessor :_nodes, :_sink, :_name
|
5
|
-
|
6
|
-
def self.build(*args, &block)
|
7
|
-
|
8
|
-
# Parse the options...
|
9
|
-
options = Zillabyte::Harness::Helper.opt_parser()
|
10
|
-
flow = Zillabyte::Harness::SimpleSource.new()
|
11
|
-
flow._nodes = []
|
12
|
-
flow._name = options[:name]
|
13
|
-
|
14
|
-
# Get the user logic...
|
15
|
-
#yield(flow)
|
16
|
-
flow.instance_eval(&block)
|
17
|
-
if(options[:command] == :info)
|
18
|
-
_info_file = File.open(options[:file], "w+")
|
19
|
-
info_hash = {"language" => "ruby", "name" => flow._name}
|
20
|
-
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, _info_file)
|
21
|
-
end
|
22
|
-
|
23
|
-
# Get the source-specific logic...
|
24
|
-
source = Zillabyte::Harness::Source.new(false)
|
25
|
-
#yield(source)
|
26
|
-
source.instance_eval(&block)
|
27
|
-
source._name = "source"
|
28
|
-
Zillabyte::Harness::Helper.check_source("simple_source", source)
|
29
|
-
flow._nodes << source
|
30
|
-
if(options[:command] == :info)
|
31
|
-
info_hash = {"name" => source._name, "type" => source._type}
|
32
|
-
if(source._emits)
|
33
|
-
info_hash["emits"] = source._emits
|
34
|
-
elsif(source._relation)
|
35
|
-
info_hash["relation"] = source._relation
|
36
|
-
elsif(source._matches)
|
37
|
-
info_hash["matches"] = source._matches
|
38
|
-
end
|
39
|
-
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, _info_file)
|
40
|
-
end
|
41
|
-
|
42
|
-
# Add the sink...
|
43
|
-
flow._nodes << flow._sink
|
44
|
-
if(options[:command] == :info)
|
45
|
-
info_hash = {"name" => flow._sink._name, "type" => flow._sink._type, "columns" => flow._sink._columns, "relation" => flow._sink._relation || flow._sink._name}
|
46
|
-
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, _info_file)
|
47
|
-
end
|
48
|
-
|
49
|
-
# Execute...
|
50
|
-
if(options[:command] == :execute and options[:name] == "source")
|
51
|
-
pipe_name = options[:pipe]
|
52
|
-
c = Zillabyte::Harness::SourceController.new(source, progress = Zillabyte::Common::Progress.new)
|
53
|
-
c.run(pipe_name)
|
54
|
-
end
|
55
|
-
|
56
|
-
# Done
|
57
|
-
flow
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
def name(v)
|
63
|
-
Zillabyte::Harness::Helper.check_name("simple_source", v, {})
|
64
|
-
@_name = v
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
def emits(v)
|
69
|
-
# Construct the sink...
|
70
|
-
Zillabyte::Harness::Helper.check_emits("simple_source", v, {})
|
71
|
-
@_sink = Zillabyte::Harness::Sink.new()
|
72
|
-
@_sink._name = "sink"
|
73
|
-
@_sink._relation = v[0][0]
|
74
|
-
columns = v[0][1]
|
75
|
-
columns.each do |col|
|
76
|
-
col.each do |cname, ctype|
|
77
|
-
@_sink.column(cname, ctype)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
def prepare(&block)
|
84
|
-
# Dummy function, prepare is picked up by Each above
|
85
|
-
end
|
86
|
-
|
87
|
-
def next_batch(&block)
|
88
|
-
# Dummy function, execute is picked up by Each above
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
end
|
93
|
-
|
@@ -1,127 +0,0 @@
|
|
1
|
-
require "json"
|
2
|
-
|
3
|
-
class Zillabyte::Harness::Topology
|
4
|
-
attr_accessor :_name, :_options, :_nodes, :_streams, :_names, :_branched, :_info_file #instance variables?
|
5
|
-
|
6
|
-
def self.build(name)
|
7
|
-
h = Zillabyte::Harness::Topology.new()
|
8
|
-
h._nodes = []
|
9
|
-
h._streams = {}
|
10
|
-
h._names = {}
|
11
|
-
h._branched = false
|
12
|
-
h._name = name
|
13
|
-
Zillabyte::Harness::Helper.check_name("new", h._name, {})
|
14
|
-
h._options = Zillabyte::Harness::Helper.opt_parser()
|
15
|
-
if(h._options[:command] == :info)
|
16
|
-
h._info_file = File.open(h._options[:file],"w+")
|
17
|
-
info_hash = {"language" => "ruby", "name" => h._name}
|
18
|
-
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, h._info_file)
|
19
|
-
end
|
20
|
-
h
|
21
|
-
end
|
22
|
-
|
23
|
-
def source(&block)
|
24
|
-
h = Zillabyte::Harness::Source.new(true)
|
25
|
-
#yield(h)
|
26
|
-
h.instance_eval(&block)
|
27
|
-
Zillabyte::Harness::Helper.check_name("source", h._name, @_names)
|
28
|
-
Zillabyte::Harness::Helper.check_source("source", h)
|
29
|
-
@_nodes << h
|
30
|
-
if(@_options[:command] == :info)
|
31
|
-
info_hash = {"name" => h._name, "type" => h._type}
|
32
|
-
if(h._relation)
|
33
|
-
info_hash["relation"] = h._relation
|
34
|
-
elsif(h._matches)
|
35
|
-
info_hash["matches"] = h._matches
|
36
|
-
elsif(h._emits)
|
37
|
-
@_branched = Zillabyte::Harness::Helper.check_emits("source", h._emits, @_streams) || @_branched
|
38
|
-
info_hash["emits"] = h._emits
|
39
|
-
end
|
40
|
-
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, @_info_file)
|
41
|
-
elsif(@_options[:command] == :execute and @_options[:name] == h._name)
|
42
|
-
pipe_name = @_options[:pipe]
|
43
|
-
c = Zillabyte::Harness::SourceController.new(h, progress = Zillabyte::Common::Progress.new)
|
44
|
-
c.run(pipe_name)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def each(&block)
|
49
|
-
h = Zillabyte::Harness::Each.new()
|
50
|
-
#yield(h)
|
51
|
-
h.instance_eval(&block)
|
52
|
-
Zillabyte::Harness::Helper.check_name("each", h._name, @_names)
|
53
|
-
if(@_branched)
|
54
|
-
Zillabyte::Harness::Helper.check_consumes(h, @_streams)
|
55
|
-
else
|
56
|
-
if(h._consumes)
|
57
|
-
h._consumes = nil
|
58
|
-
end
|
59
|
-
end
|
60
|
-
@_branched = Zillabyte::Harness::Helper.check_emits("each", h._emits, @_streams) || @_branched
|
61
|
-
@_nodes << h
|
62
|
-
if(@_options[:command] == :info)
|
63
|
-
info_hash = {"name" => h._name, "type" => h._type, "emits" => h._emits}
|
64
|
-
if(h._consumes)
|
65
|
-
info_hash["consumes"] = h._consumes
|
66
|
-
end
|
67
|
-
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, @_info_file)
|
68
|
-
elsif(@_options[:command] == :execute and @_options[:name] == h._name)
|
69
|
-
pipe_name = @_options[:pipe]
|
70
|
-
c = Zillabyte::Harness::EachController.new(h, progress = Zillabyte::Common::Progress.new)
|
71
|
-
c.run(pipe_name)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def aggregate(&block)
|
76
|
-
h = Zillabyte::Harness::Aggregate.new()
|
77
|
-
#yield(h)
|
78
|
-
h.instance_eval(&block)
|
79
|
-
Zillabyte::Harness::Helper.check_name("aggregate", h._name, @_names)
|
80
|
-
if(@_branched)
|
81
|
-
Zillabyte::Harness::Helper.check_consumes(h, @_streams)
|
82
|
-
else
|
83
|
-
if(h._consumes)
|
84
|
-
h._consumes = nil
|
85
|
-
end
|
86
|
-
end
|
87
|
-
Zillabyte::Harness::Helper.check_group_by("aggregate", h, @_nodes, @_streams)
|
88
|
-
@_branched = Zillabyte::Harness::Helper.check_emits("aggregate", h._emits, @_streams) || @_branched
|
89
|
-
@_nodes << h
|
90
|
-
if(@_options[:command] == :info)
|
91
|
-
info_hash = {"name" => h._name, "type" => h._type, "group_by" => h._group_by, "emits" => h._emits}
|
92
|
-
if(h._consumes)
|
93
|
-
info_hash["consumes"] = h._consumes
|
94
|
-
end
|
95
|
-
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, @_info_file)
|
96
|
-
elsif(@_options[:command] == :execute)
|
97
|
-
pipe_name = @_options[:pipe]
|
98
|
-
if(@_options[:name] == h._name)
|
99
|
-
c = Zillabyte::Harness::AggregateController.new(h, Zillabyte::Common::Progress.new)
|
100
|
-
c.run(pipe_name)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def sink(&block)
|
106
|
-
h = Zillabyte::Harness::Sink.new()
|
107
|
-
#yield(h)
|
108
|
-
h.instance_eval(&block)
|
109
|
-
Zillabyte::Harness::Helper.check_sink(h, @_nodes)
|
110
|
-
if(@_branched)
|
111
|
-
Zillabyte::Harness::Helper.check_consumes(h, @_streams)
|
112
|
-
else
|
113
|
-
if(h._consumes)
|
114
|
-
h._consumes = nil
|
115
|
-
end
|
116
|
-
end
|
117
|
-
@_nodes << h
|
118
|
-
if(@_options[:command] == :info)
|
119
|
-
info_hash = {"name" => h._name, "type" => h._type, "columns" => h._columns, "relation" => h._relation || h._name}
|
120
|
-
if(h._consumes)
|
121
|
-
info_hash["consumes"] = h._consumes
|
122
|
-
end
|
123
|
-
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, @_info_file)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
end
|