zillabyte 0.0.24 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +6 -14
- data/ruby/lib/zillabyte.rb +6 -0
- data/ruby/lib/zillabyte/harness/app.rb +10 -14
- data/ruby/lib/zillabyte/harness/base.rb +11 -0
- data/ruby/lib/zillabyte/harness/component.rb +32 -0
- data/ruby/lib/zillabyte/harness/component_sink.rb +26 -0
- data/ruby/lib/zillabyte/harness/component_source.rb +17 -0
- data/ruby/lib/zillabyte/harness/component_stream.rb +20 -0
- data/ruby/lib/zillabyte/harness/each.rb +1 -1
- data/ruby/lib/zillabyte/harness/filter.rb +3 -3
- data/ruby/lib/zillabyte/harness/group_by.rb +5 -21
- data/ruby/lib/zillabyte/harness/helper.rb +225 -29
- data/ruby/lib/zillabyte/harness/injected_component.rb +31 -0
- data/ruby/lib/zillabyte/harness/join.rb +21 -13
- data/ruby/lib/zillabyte/harness/live_delegator.rb +8 -9
- data/ruby/lib/zillabyte/harness/sink.rb +1 -6
- data/ruby/lib/zillabyte/harness/stream.rb +83 -52
- data/ruby/lib/zillabyte/version.rb +1 -1
- metadata +21 -15
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZTgwZDUxMTQ0OWY2ODJmYTkzYzllNDAwMWZkNGVmZTczNzBhNTc3NzMwZThi
|
10
|
-
MmQ4YjA5NTc0M2ZmZTBhYmEzODhmMzcyZGIzNTRkZGZjMDMyOGQzYWViNWQz
|
11
|
-
Y2U1NmU1YzI1YTZhYWZmMzVlYWQwZDEyY2EwNDVkODVlNDEzODQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
M2QzZWI1YzA4YmM3ZDE3NjNlNjY5MzgwMzhlY2ZhOGE1YmM3ZGRkMmI5ZWYw
|
14
|
-
YWY3ODRjOGMwOWY4ZjM4YjA5Y2JkZmVjZjIxYTI2NGEwYjVhZWYwYjgyYjhk
|
15
|
-
Y2MzYWM2MDcxYjg0OWE2ZjgzOTMwZmViYTJlNTVlOTYwNmNkOTA=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c42be796292e1dd2943f43b64e37364fa8208073
|
4
|
+
data.tar.gz: 604ea5c2a29c5cf979f8e8f3a61d496cdd6d04bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 419d310b450c14dadc0fdaefe0acf97db813953a24a4727f1308ab2051ce0f35b8458641bcbf79cca7cb49f79cf437d6bd13516ecc33c98cce9d6d6f85c74c02
|
7
|
+
data.tar.gz: 75da6f6f8f6c48162278c6fd21fd1614ff87f89cb9ddbb0e81fa33e525ddd3bd4e57a60cbfc85ba5ce0ed359ac953e12050a7f34b6c86dd1588a73a0b1f697eb
|
data/ruby/lib/zillabyte.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "active_support/core_ext"
|
2
2
|
require "zillabyte/harness"
|
3
|
+
require "zillabyte/version"
|
3
4
|
require "zillabyte/common/progress"
|
4
5
|
|
5
6
|
module Zillabyte
|
@@ -8,5 +9,10 @@ module Zillabyte
|
|
8
9
|
@app = Zillabyte::Harness::App.build(name)
|
9
10
|
@app
|
10
11
|
end
|
12
|
+
|
13
|
+
def self.component(name=nil)
|
14
|
+
@component = Zillabyte::Harness::Component.build(name)
|
15
|
+
@component
|
16
|
+
end
|
11
17
|
|
12
18
|
end
|
@@ -1,19 +1,15 @@
|
|
1
1
|
require "json"
|
2
|
+
require "zillabyte/harness/base"
|
2
3
|
|
3
|
-
class Zillabyte::Harness::App
|
4
|
-
attr_accessor :_name, :_options, :_nodes, :_streams, :_names, :_info_file
|
4
|
+
class Zillabyte::Harness::App < Zillabyte::Harness::Base
|
5
5
|
|
6
6
|
def self.build(name)
|
7
|
-
h = Zillabyte::Harness::App.new
|
8
|
-
h._nodes = []
|
9
|
-
h._streams = {}
|
10
|
-
h._names = {}
|
11
|
-
h._name = name
|
7
|
+
h = Zillabyte::Harness::App.new name
|
12
8
|
Zillabyte::Harness::Helper.check_name("app", h._name, {})
|
13
9
|
h._options = Zillabyte::Harness::Helper.opt_parser()
|
14
10
|
if(h._options[:command] == :info)
|
15
11
|
h._info_file = File.open(h._options[:file],"w+")
|
16
|
-
info_hash = {"language" => "ruby", "name" => h._name}
|
12
|
+
info_hash = {"language" => "ruby", "name" => h._name, "flow_type" => "app", "multilang_version" => Zillabyte::VERSION}
|
17
13
|
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, h._info_file)
|
18
14
|
end
|
19
15
|
h
|
@@ -39,15 +35,15 @@ class Zillabyte::Harness::App
|
|
39
35
|
end
|
40
36
|
@_nodes << h
|
41
37
|
if(@_options[:command] == :info)
|
42
|
-
|
38
|
+
node_hash = {"name" => h._name, "type" => h._type}
|
43
39
|
if(h._relation)
|
44
|
-
|
40
|
+
node_hash["relation"] = h._relation
|
45
41
|
elsif(h._matches)
|
46
|
-
|
42
|
+
node_hash["matches"] = h._matches
|
47
43
|
else
|
48
|
-
|
44
|
+
node_hash["end_cycle_policy"] = h._end_cycle_policy
|
49
45
|
end
|
50
|
-
Zillabyte::Harness::Helper.
|
46
|
+
Zillabyte::Harness::Helper.write_node_to_file(node_hash, @_info_file)
|
51
47
|
elsif(@_options[:command] == :execute and @_options[:name] == h._name)
|
52
48
|
pipe_name = @_options[:pipe]
|
53
49
|
c = Zillabyte::Harness::SourceController.new(h, progress = Zillabyte::Common::Progress.new)
|
@@ -56,7 +52,7 @@ class Zillabyte::Harness::App
|
|
56
52
|
|
57
53
|
output_streams = []
|
58
54
|
h._emits.each do |stream|
|
59
|
-
output_streams << Zillabyte::Harness::Stream.new(stream, self,
|
55
|
+
output_streams << Zillabyte::Harness::Stream.new(stream, self, h._name)
|
60
56
|
end
|
61
57
|
output_streams = output_streams[0] if output_streams.size == 1
|
62
58
|
output_streams
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "zillabyte/harness/base"
|
2
|
+
|
3
|
+
class Zillabyte::Harness::Component < Zillabyte::Harness::Base
|
4
|
+
|
5
|
+
def self.build(name)
|
6
|
+
h = Zillabyte::Harness::Component.new name
|
7
|
+
Zillabyte::Harness::Helper.check_name("component", h._name, {})
|
8
|
+
h._options = Zillabyte::Harness::Helper.opt_parser()
|
9
|
+
if(h._options[:command] == :info)
|
10
|
+
h._info_file = File.open(h._options[:file],"w+")
|
11
|
+
info_hash = {"language" => "ruby", "name" => h._name, "flow_type" => "component", "multilang_version" => Zillabyte::VERSION}
|
12
|
+
Zillabyte::Harness::Helper.write_hash_to_file(info_hash, h._info_file)
|
13
|
+
end
|
14
|
+
h
|
15
|
+
end
|
16
|
+
|
17
|
+
def inputs(*args, &block)
|
18
|
+
h = Zillabyte::Harness::ComponentSource.new
|
19
|
+
h.instance_eval(&block)
|
20
|
+
Zillabyte::Harness::Helper.check_name("inputs", h._name, @_names)
|
21
|
+
Zillabyte::Harness::Helper.check_component_source(h)
|
22
|
+
|
23
|
+
if(self._options[:command] == :info)
|
24
|
+
node_hash = {"name" => h._name, "type" => h._type, "fields" => h._fields}
|
25
|
+
Zillabyte::Harness::Helper.write_node_to_file(node_hash, self._info_file)
|
26
|
+
end
|
27
|
+
|
28
|
+
# For components, each "inputs" statement only defines a single stream
|
29
|
+
output_stream = Zillabyte::Harness::ComponentStream.new(h._emits.first, self, h._name)
|
30
|
+
output_stream
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Zillabyte::Harness::ComponentSink
|
2
|
+
attr_accessor :_name, :_relation, :_type, :_columns, :_scope
|
3
|
+
|
4
|
+
def initialize()
|
5
|
+
@_type = 'sink'
|
6
|
+
@_columns = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def name(v)
|
10
|
+
@_name = v
|
11
|
+
end
|
12
|
+
|
13
|
+
def relation(v)
|
14
|
+
@_relation = v
|
15
|
+
end
|
16
|
+
|
17
|
+
def field(cname, ctype)
|
18
|
+
col = {cname => ctype}
|
19
|
+
@_columns << col
|
20
|
+
end
|
21
|
+
|
22
|
+
def scope(v)
|
23
|
+
@_scope = v
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Zillabyte::Harness::ComponentSource
|
2
|
+
attr_accessor :_name, :_type, :_emits, :_fields
|
3
|
+
|
4
|
+
def initialize()
|
5
|
+
@_type = "source"
|
6
|
+
@_emits = ["stream_"+Zillabyte::Harness::Counter.get()]
|
7
|
+
@_fields = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def name(v)
|
11
|
+
@_name = v
|
12
|
+
end
|
13
|
+
|
14
|
+
def field(name, type)
|
15
|
+
@_fields << {name => type}
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'zillabyte/harness/stream'
|
2
|
+
|
3
|
+
class Zillabyte::Harness::ComponentStream < Zillabyte::Harness::Stream
|
4
|
+
|
5
|
+
def sink(*args, &block)
|
6
|
+
h = Zillabyte::Harness::ComponentSink.new
|
7
|
+
h.instance_eval(&block)
|
8
|
+
Zillabyte::Harness::Helper.check_name("outputs", h._name, @_app._names)
|
9
|
+
Zillabyte::Harness::Helper.check_component_sink(h)
|
10
|
+
|
11
|
+
if(@_app._options[:command] == :info)
|
12
|
+
node_hash = {"name" => h._name, "type" => h._type, "columns" => h._columns, "relation" => h._relation || h._name, "scope" => h._scope}
|
13
|
+
Zillabyte::Harness::Helper.write_node_to_file(node_hash, @_app._info_file)
|
14
|
+
arc_hash = {"name" => @_name, "origin" => @_previous_node_name, "dest" => h._name}
|
15
|
+
Zillabyte::Harness::Helper.write_arc_to_file(arc_hash, @_app._info_file)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
alias :outputs :sink
|
19
|
+
|
20
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class Zillabyte::Harness::Filter
|
2
|
-
attr_accessor :_name, :_type, :_emits, :
|
2
|
+
attr_accessor :_name, :_type, :_emits, :_prepare, :_keep
|
3
3
|
|
4
4
|
def initialize()
|
5
5
|
@_name = "filter_"+Zillabyte::Harness::Counter.get()
|
@@ -9,11 +9,11 @@ class Zillabyte::Harness::Filter
|
|
9
9
|
def name(v)
|
10
10
|
@_name = v
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def emits(*v)
|
14
14
|
@_emits = *v
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def prepare(&block)
|
18
18
|
@_prepare = block
|
19
19
|
end
|
@@ -1,36 +1,20 @@
|
|
1
1
|
class Zillabyte::Harness::GroupBy
|
2
|
-
attr_accessor :_name, :_type, :
|
2
|
+
attr_accessor :_name, :_type, :_group_by, :_emits, :_begin_group, :_aggregate, :_end_group
|
3
3
|
|
4
|
-
def initialize(*
|
4
|
+
def initialize(*v)
|
5
5
|
@_name = "group_by_"+Zillabyte::Harness::Counter.get()
|
6
6
|
@_type = 'group_by'
|
7
|
-
@_group_by =
|
7
|
+
@_group_by = *v
|
8
8
|
end
|
9
9
|
|
10
10
|
def name(v)
|
11
11
|
@_name = v
|
12
12
|
end
|
13
|
-
|
14
|
-
def consumes(v)
|
15
|
-
@_consumes = v
|
16
|
-
end
|
17
13
|
|
18
|
-
def
|
19
|
-
@
|
14
|
+
def emits(*v)
|
15
|
+
@_emits = *v
|
20
16
|
end
|
21
17
|
|
22
|
-
def group_by
|
23
|
-
if @_group_by.is_a?(Array)
|
24
|
-
return @_group_by
|
25
|
-
else
|
26
|
-
return [@_group_by]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def emits(v)
|
31
|
-
@_emits = v
|
32
|
-
end
|
33
|
-
|
34
18
|
def begin_group(&block)
|
35
19
|
@_begin_group = block
|
36
20
|
end
|
@@ -26,6 +26,14 @@ class Zillabyte::Harness::Helper
|
|
26
26
|
options
|
27
27
|
end
|
28
28
|
|
29
|
+
def self.write_node_to_file(hash, file)
|
30
|
+
Zillabyte::Harness::Helper.write_hash_to_file({"class" => "node", "info" => hash}, file)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.write_arc_to_file(hash, file)
|
34
|
+
Zillabyte::Harness::Helper.write_hash_to_file({"class" => "arc", "info" => hash}, file)
|
35
|
+
end
|
36
|
+
|
29
37
|
def self.write_hash_to_file(hash, file)
|
30
38
|
file.write(hash.to_json+"\n")
|
31
39
|
end
|
@@ -44,7 +52,7 @@ class Zillabyte::Harness::Helper
|
|
44
52
|
|
45
53
|
# \w matchs [a-zA-Z0-9_]
|
46
54
|
if(!(name.is_a?(String) or name.is_a?(Symbol)) or (name =~ /^\w+$/).nil?)
|
47
|
-
msg = "#{ee}\"Name\" must be a non-empty STRING with only alphanumeric and underscore characters at \"#{name}\". Apps and
|
55
|
+
msg = "#{ee}\"Name\" must be a non-empty STRING with only alphanumeric and underscore characters at \"#{name}\". Apps and components must have names. The following methods must have names as well: \"sink\", \"inputs\" and \"outputs\"."
|
48
56
|
Zillabyte::Harness::Helper.print_error(msg)
|
49
57
|
end
|
50
58
|
if(names[name] and names[name] != "app" and names[name] != "sink" and operation != "app" and operation != "sink")
|
@@ -94,22 +102,28 @@ class Zillabyte::Harness::Helper
|
|
94
102
|
end
|
95
103
|
|
96
104
|
def self.check_emits(operation, emits, streams)
|
97
|
-
|
105
|
+
if operation == "component"
|
106
|
+
oo = "outputs"
|
107
|
+
else
|
108
|
+
oo = "emits"
|
109
|
+
end
|
110
|
+
|
111
|
+
ee = "Error in \"#{operation}\" at \"#{oo}\": \n\t "
|
98
112
|
pp = ""
|
99
113
|
|
100
114
|
if(!emits.instance_of?(Array))
|
101
|
-
msg = "#{ee}\"
|
115
|
+
msg = "#{ee}An \"#{oo}\" must be a sequence of comma-separated STRINGS. #{pp}"
|
102
116
|
Zillabyte::Harness::Helper.print_error(msg)
|
103
117
|
end
|
104
118
|
n_emits = emits.length
|
105
119
|
if(n_emits == 0)
|
106
|
-
msg = "#{ee}Must emit at least one stream, \"
|
120
|
+
msg = "#{ee}Must emit at least one stream, \"#{oo}\" cannot be an empty. #{pp}"
|
107
121
|
Zillabyte::Harness::Helper.print_error(msg)
|
108
122
|
end
|
109
123
|
|
110
124
|
emits.each do |e|
|
111
125
|
if(!e.instance_of?(String) or (e =~ /^\w+$/).nil?)
|
112
|
-
msg = "#{ee}\"
|
126
|
+
msg = "#{ee}An \"#{oo}\" stream name must be a non-empty STRING with only alphanumeric and underscore characters in \"#{e}\". #{pp}"
|
113
127
|
Zillabyte::Harness::Helper.print_error(msg)
|
114
128
|
end
|
115
129
|
if(streams[e])
|
@@ -124,8 +138,12 @@ class Zillabyte::Harness::Helper
|
|
124
138
|
ee = "Error in \"filter\": \n\t "
|
125
139
|
pp = @@_print_check_filter
|
126
140
|
|
141
|
+
if filter._emits.size != 1
|
142
|
+
msg = "#{ee}A \"filter\" must emit a single stream. #{pp}"
|
143
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
144
|
+
end
|
127
145
|
if !filter._keep
|
128
|
-
msg = "#{ee}A \"filter\" must contain a \"
|
146
|
+
msg = "#{ee}A \"filter\" must contain a \"keep\" block. #{pp}"
|
129
147
|
Zillabyte::Harness::Helper.print_error(msg)
|
130
148
|
end
|
131
149
|
end
|
@@ -140,6 +158,83 @@ class Zillabyte::Harness::Helper
|
|
140
158
|
end
|
141
159
|
end
|
142
160
|
|
161
|
+
def self.check_group_by(group_by)
|
162
|
+
ee = "Error in \"group_by\": \n\t "
|
163
|
+
pp = @@_print_check_group_by
|
164
|
+
|
165
|
+
if !group_by._group_by or group_by._group_by.empty?
|
166
|
+
msg = "#{ee} A \"group_by\" must contain a non-empty \"group_by\" clause. #{pp}"
|
167
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
168
|
+
end
|
169
|
+
group_by._group_by.each do |field|
|
170
|
+
if(!(field.is_a?(String) or field.is_a?(Symbol)) or (field =~ /^\w+$/).nil?)
|
171
|
+
msg = "#{ee}Field names must be non-empty STRINGS with only alphanumeric and underscore characters at \"#{field}\"."
|
172
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
if !group_by._begin_group
|
177
|
+
msg = "#{ee}A \"group_by\" must contain a \"begin_group\" block. #{pp}"
|
178
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
179
|
+
end
|
180
|
+
if !group_by._aggregate
|
181
|
+
msg = "#{ee}A \"group_by\" must contain an \"aggregate\" block. #{pp}"
|
182
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
183
|
+
end
|
184
|
+
if !group_by._end_group
|
185
|
+
msg = "#{ee}A \"group_by\" must contain an \"end_group\" block. #{pp}"
|
186
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.check_join(join_with)
|
191
|
+
ee = "Error in \"join_with\": \n\t "
|
192
|
+
pp = @@_print_check_join
|
193
|
+
|
194
|
+
if join_with._emits.size != 1
|
195
|
+
msg = "#{ee}A \"join_with\" must emit a single stream. #{pp}"
|
196
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
197
|
+
end
|
198
|
+
|
199
|
+
lhs_fields = join_with._lhs_fields
|
200
|
+
rhs_fields = join_with._rhs_fields
|
201
|
+
if !lhs_fields or !rhs_fields
|
202
|
+
msg = "#{ee}The fields to join on must be specified in the format described below! #{pp}"
|
203
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
204
|
+
end
|
205
|
+
if(!(lhs_fields.is_a?(String) or lhs_fields.is_a?(Symbol)) or (lhs_fields =~ /^\w+$/).nil?)
|
206
|
+
msg = "#{ee}Field names must be non-empty STRINGS with only alphanumeric and underscore characters at \"#{lhs_fields}\". #{pp}"
|
207
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
208
|
+
end
|
209
|
+
if(!(rhs_fields.is_a?(String) or rhs_fields.is_a?(Symbol)) or (rhs_fields =~ /^\w+$/).nil?)
|
210
|
+
msg = "#{ee}Field names must be non-empty STRINGS with only alphanumeric and underscore characters at \"#{rhs_fields}\". #{pp}"
|
211
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
212
|
+
end
|
213
|
+
|
214
|
+
supported_joins = [:inner, :left, :right]
|
215
|
+
if !supported_joins.member? join_with._join_type
|
216
|
+
msg = "#{ee}The requested \"join_type\", \"#{join_with._join_type}\", is not supported. Currently we support \"#{supported_joins}\". #{pp}"
|
217
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def self.check_call_component(node)
|
222
|
+
ee = "Error in \"call_component\": \n\t "
|
223
|
+
pp = @@_print_check_call_component
|
224
|
+
|
225
|
+
id = node._id
|
226
|
+
if !id
|
227
|
+
msg = "#{ee} The \"component_id\" must be specified. Check \"zillabyte components\" to find the correct ID. #{pp}"
|
228
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
229
|
+
end
|
230
|
+
|
231
|
+
# \w matchs [0-9]
|
232
|
+
if(!(id.is_a?(String) or id.is_a?(Symbol)) or (id =~ /^[0-9]+$/).nil? or id[0] == "0")
|
233
|
+
msg = "#{ee} Invalid \"component_id\". The \"component_id\" must be a number. Check \"zillabyte components\" to find the correct ID. #{pp}"
|
234
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
143
238
|
def self.check_sink(sink, nodes)
|
144
239
|
ee = "Error in \"sink\": \n\t "
|
145
240
|
pp = @@_print_check_sink
|
@@ -175,16 +270,15 @@ class Zillabyte::Harness::Helper
|
|
175
270
|
columns.each do |col|
|
176
271
|
cname = col.keys()[0]
|
177
272
|
ctype = col[cname]
|
178
|
-
Zillabyte::Harness::Helper.
|
273
|
+
Zillabyte::Harness::Helper.check_field_format("sink",@@_print_check_sink,cname,ctype,name)
|
179
274
|
end
|
180
275
|
end
|
181
276
|
|
182
|
-
def self.
|
183
|
-
ee = "Error in \"
|
184
|
-
pp = @@_print_check_sink
|
277
|
+
def self.check_field_format(operation, pp, cname, ctype, relation_name)
|
278
|
+
ee = "Error in \"#{operation}\": \n\t "
|
185
279
|
|
186
280
|
if(!(cname.is_a?(String) or cname.is_a?(Symbol)) or (cname =~ /^\w+$/).nil?)
|
187
|
-
msg = "#{ee}Field names must be non-empty STRINGS with only alphanumeric and underscore characters in
|
281
|
+
msg = "#{ee}Field names must be non-empty STRINGS with only alphanumeric and underscore characters in \"#{relation_name}\". #{pp}"
|
188
282
|
Zillabyte::Harness::Helper.print_error(msg)
|
189
283
|
end
|
190
284
|
if(cname =~ /^v[0-9]+$/i or @@_meta_names.member?(cname.downcase))
|
@@ -192,13 +286,47 @@ class Zillabyte::Harness::Helper
|
|
192
286
|
Zillabyte::Harness::Helper.print_error(msg)
|
193
287
|
end
|
194
288
|
if(!ctype.instance_of?(Symbol))
|
195
|
-
msg = "#{ee}Field data types must be SYMBOLS in
|
289
|
+
msg = "#{ee}Field data types must be SYMBOLS in \"#{relation_name}\". #{pp}"
|
196
290
|
Zillabyte::Harness::Helper.print_error(msg)
|
197
291
|
end
|
198
292
|
if(ctype != :string and ctype != :integer and ctype != :float and ctype != :double && ctype != :boolean)
|
199
|
-
msg = "#{ee}Invalid field data type at \"#{ctype}\" in
|
293
|
+
msg = "#{ee}Invalid field data type at \"#{ctype}\" in \"#{relation_name}\". #{pp}"
|
294
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
def self.check_component_source(node)
|
299
|
+
ee = "Error in \"inputs\": \n\t "
|
300
|
+
pp = @@_print_check_component_source
|
301
|
+
|
302
|
+
fields = node._fields
|
303
|
+
if(fields.empty?)
|
304
|
+
msg = "#{ee}Must be at least one output field to \"#{node._name}\". #{pp}"
|
305
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
306
|
+
end
|
307
|
+
|
308
|
+
fields.each do |field|
|
309
|
+
fname = field.keys[0]
|
310
|
+
ftype = field[fname]
|
311
|
+
Zillabyte::Harness::Helper.check_field_format("inputs", pp, fname, ftype, node._name)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
def self.check_component_sink(node)
|
316
|
+
ee = "Error in \"outputs\": \n\t "
|
317
|
+
pp = @@_print_check_component_sink
|
318
|
+
|
319
|
+
columns = node._columns
|
320
|
+
if(columns.empty?)
|
321
|
+
msg = "#{ee}Must be at least one output field to \"#{node._name}\". #{pp}"
|
200
322
|
Zillabyte::Harness::Helper.print_error(msg)
|
201
323
|
end
|
324
|
+
|
325
|
+
columns.each do |col|
|
326
|
+
cname = col.keys[0]
|
327
|
+
ctype = col[cname]
|
328
|
+
Zillabyte::Harness::Helper.check_field_format("outputs", pp, cname, ctype, node._name)
|
329
|
+
end
|
202
330
|
end
|
203
331
|
|
204
332
|
# Test helper...
|
@@ -240,18 +368,27 @@ OUTPUT
|
|
240
368
|
- The "end_cycle_policy" is used to specify when a cycle should end. Two options are available:
|
241
369
|
* :null_emit - end the cycle when a field contains "nil" or when nothing is emitted from the "next_tuple" block.
|
242
370
|
* :explicit - the end of a cycle is explicitly declared in the "next_tuple" block. This is done by including the "end_cycle" keyword in the "next_tuple" block, e.g. end_cycle if @queue.nil?.
|
371
|
+
- The "begin_cycle" and "next_tuple" blocks can be in do...end format or {} format.
|
372
|
+
* the "begin_cycle" block is where any setup is done to initialize the content and quantity of tuples emitted by the "next_tuple" block.
|
373
|
+
* the "next_tuple" block is where the tuples are actually emitted.
|
243
374
|
OUTPUT
|
244
375
|
|
245
376
|
@@_print_check_filter = <<-OUTPUT
|
246
377
|
\n\n"Filter" Syntax:
|
247
378
|
Simplified syntax:
|
248
|
-
stream.filter
|
379
|
+
stream.filter do |tuple|
|
380
|
+
|=block=|
|
381
|
+
end
|
382
|
+
- The condition for keeping the tuple should be specified in the block.
|
383
|
+
- This is equivalent to just specifying a "keep" block below.
|
249
384
|
|
250
|
-
* Outputs a given tuple from the stream only if condition is true
|
251
385
|
Custom filter:
|
252
|
-
stream.filter do
|
253
|
-
|
386
|
+
stream.filter do
|
387
|
+
name "name" \t\t\t => optional
|
388
|
+
keep |=block=|
|
254
389
|
end
|
390
|
+
- The "keep" block must take in a single argument (the "tuple").
|
391
|
+
- Tuples will pass through if "keep" returns "True".
|
255
392
|
OUTPUT
|
256
393
|
|
257
394
|
@@_print_check_each = <<-OUTPUT
|
@@ -270,21 +407,80 @@ OUTPUT
|
|
270
407
|
prepare |=block=| \t\t\t\t => optional if no initialization needed
|
271
408
|
execute |=block=|
|
272
409
|
end
|
410
|
+
- The "prepare" and "execute" blocks can be in do...end format or {} format.
|
411
|
+
* the "prepare" block is where any setup is done to prepare for tuple processing in the "execute" block.
|
412
|
+
* the "execute" block is where the tuples are actually processed. It must take in a single argument (the "tuple").
|
273
413
|
OUTPUT
|
274
414
|
|
275
|
-
@@
|
276
|
-
\n\n"
|
415
|
+
@@_print_check_group_by = <<-OUTPUT
|
416
|
+
\n\n"Group By" Syntax:
|
277
417
|
stream.group_by do
|
278
|
-
name "name" => optional
|
279
|
-
group_by
|
280
|
-
emits
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
418
|
+
name "name" \t\t\t\t\t => optional
|
419
|
+
group_by "field_1", "field_2", ...
|
420
|
+
emits "stream_1", "stream_2", ... \t\t => optional for single output stream
|
421
|
+
begin_group |=block=|
|
422
|
+
aggregate |=block=|
|
423
|
+
end_group |=block=|
|
424
|
+
end
|
425
|
+
- The "begin_group", "aggregate" and "end_group" blocks can be in do...end format or {} format.
|
426
|
+
* the "begin_group" block is where the initial values for the aggregation are set. It must take in a single argument (the "grouping tuple", which is emitted at the beginning of each group and contains the values of the fields specified in "group_by").
|
427
|
+
* the "aggregate" block is where the aggregation is performed. It must take in a single argument (the "tuple").
|
428
|
+
* the "end_group" block is where the final aggregated value is emitted.
|
429
|
+
OUTPUT
|
430
|
+
|
431
|
+
@@_print_check_join = <<-OUTPUT
|
432
|
+
\n\n"Join With" Syntax:
|
433
|
+
lhs_stream.join_with( rhs_stream_object, options )
|
434
|
+
- Options should be specified as a hash. The following keys are recognized:
|
435
|
+
Mandatory:
|
436
|
+
* "on" \t\t -- specifies the fields to join on. The value must be a STRING or a length-2 ARRAY. If value = a STRING, the LH and RH join fields will both be set to this STRING. If value = a length-2 ARRAY, the LH join field will be set to array[0] and the RH join field will be set to array[1].
|
437
|
+
|
438
|
+
Optional:
|
439
|
+
* "type" \t -- specifies the join type. The default is "inner".
|
440
|
+
* "emits" \t -- specifies the stream to emit. A "join" may only emit a single stream.
|
441
|
+
OUTPUT
|
442
|
+
|
443
|
+
@@_print_check_component_source = <<-OUTPUT
|
444
|
+
\n\n"Inputs" Syntax:
|
445
|
+
component.inputs do
|
446
|
+
name "input_stream_name"
|
447
|
+
field "field_1", :type_1
|
448
|
+
field "field_2", :type_2
|
449
|
+
end
|
450
|
+
- "Inputs" stream "name" must be specified as a non-empty STRING with only alphanumeric and underscore characters!
|
451
|
+
- Field names must be non-empty STRINGS with only alphanumeric or underscore characters.
|
452
|
+
- Field names cannot be "v[number]", "id", "confidence", "since" or "source" which are reserved Zillabyte names.
|
453
|
+
- Field types must be SYMBOLS. The following types are allowed :string, :integer, :float, :double, and :boolean.
|
454
|
+
OUTPUT
|
455
|
+
|
456
|
+
@@_print_check_component_sink = <<-OUTPUT
|
457
|
+
\n\n"Outputs" Syntax:
|
458
|
+
component_stream.outputs do
|
459
|
+
name "output_stream_name"
|
460
|
+
field "field_1", :type_1
|
461
|
+
field "field_2", :type_2
|
462
|
+
end
|
463
|
+
- "Outputs" stream "name" must be specified as a non-empty STRING with only alphanumeric and underscore characters!
|
464
|
+
- Field names must be non-empty STRINGS with only alphanumeric or underscore characters.
|
465
|
+
- Field names cannot be "v[number]", "id", "confidence", "since" or "source" which are reserved Zillabyte names.
|
466
|
+
- Field types must be SYMBOLS. The following types are allowed :string, :integer, :float, :double, and :boolean.
|
467
|
+
OUTPUT
|
468
|
+
|
469
|
+
@@_print_check_call_component = <<-OUTPUT
|
470
|
+
\n\n"Call_component" Syntax:
|
471
|
+
stream.call_component do
|
472
|
+
component_id "component_id"
|
473
|
+
name "name" \t\t\t\t\t\t\t\t\t => optional
|
474
|
+
additional_inputs other_input_stream_object_1, other_input_stream_object_2, ... \t => blank if none
|
475
|
+
outputs "output_stream_name_1", "output_stream_name_2", ...
|
476
|
+
end
|
477
|
+
- The "component_id" MUST be given and correspond to the id listed in the output of "zillabyte components".
|
478
|
+
- To correctly stich in the component, the implicit assumptions below WILL BE USED:
|
479
|
+
* The "stream" that "call_component" is invoked on MUST correspond to the first listed input stream to the component.
|
480
|
+
* The streams specified in "additional_inputs" MUST correspond to the other listed input streams in order.
|
481
|
+
* Tuples emitted from the preceeding operation MUST contain the fields listed for the corresponding component input streams.
|
482
|
+
* The streams specified in "outputs" must correspond to the listed output streams to the component in order.
|
483
|
+
* The number of input and output streams specified must match the number listed for the component.
|
288
484
|
OUTPUT
|
289
485
|
|
290
486
|
@@_meta_names = ["id", "confidence", "since", "source"]
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Zillabyte::Harness::InjectedComponent
|
2
|
+
attr_accessor :_name, :_type, :_id, :_consumes, :_emits, :_output_format
|
3
|
+
|
4
|
+
def initialize()
|
5
|
+
@_name = "component_"+Zillabyte::Harness::Counter.get()
|
6
|
+
@_type = "component"
|
7
|
+
@_consumes = []
|
8
|
+
@_output_format = "replace"
|
9
|
+
end
|
10
|
+
|
11
|
+
def name(v)
|
12
|
+
@_name = v
|
13
|
+
end
|
14
|
+
|
15
|
+
def component_id(v)
|
16
|
+
@_id = v.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def additional_inputs(*v)
|
20
|
+
@_consumes = *v
|
21
|
+
end
|
22
|
+
|
23
|
+
def outputs(*v)
|
24
|
+
@_emits = *v
|
25
|
+
end
|
26
|
+
|
27
|
+
def output_format(v)
|
28
|
+
@_output_format = v
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -1,25 +1,33 @@
|
|
1
1
|
class Zillabyte::Harness::Join
|
2
|
-
attr_accessor :_name, :_type, :
|
2
|
+
attr_accessor :_name, :_type, :_lhs_fields, :_rhs_fields, :_join_type, :_emits
|
3
3
|
#:_group_by, :_emits, :_begin_group, :_aggregate, :_end_group
|
4
4
|
|
5
|
-
def initialize(
|
5
|
+
def initialize(options = {})
|
6
6
|
@_name = "join_"+Zillabyte::Harness::Counter.get()
|
7
7
|
@_type = 'join'
|
8
|
-
@_lhs_stream = lhs_stream
|
9
|
-
@_rhs_stream = rhs_stream
|
10
8
|
@_join_type = :inner
|
11
|
-
|
9
|
+
|
12
10
|
options.symbolize_keys!
|
11
|
+
|
12
|
+
emits = options[:emits]
|
13
|
+
if emits
|
14
|
+
if emits.is_a?(String)
|
15
|
+
@_emits = [options[:emits]]
|
16
|
+
else
|
17
|
+
@_emits = options[:emits]
|
18
|
+
end
|
19
|
+
end
|
13
20
|
|
14
21
|
# Figure out which fields to join on..
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
on = options[:on]
|
23
|
+
if on
|
24
|
+
if on.is_a?(Array) and on.size == 2
|
25
|
+
@_lhs_fields = on[0]
|
26
|
+
@_rhs_fields = on[1]
|
27
|
+
elsif (on.is_a?(String) or on.is_a?(Symbol))
|
28
|
+
@_lhs_fields = on
|
29
|
+
@_rhs_fields = on
|
30
|
+
end
|
23
31
|
end
|
24
32
|
|
25
33
|
# Different kind of join types...
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "json"
|
3
|
+
require "base64"
|
3
4
|
|
4
5
|
module Zillabyte
|
5
6
|
|
@@ -115,14 +116,14 @@ module Zillabyte
|
|
115
116
|
|
116
117
|
|
117
118
|
def set_state(key, val)
|
118
|
-
send_msg_to_parent({'set_state' => Base64.encode64(
|
119
|
+
send_msg_to_parent({'set_state' => Base64.encode64(Marshal.dump(val)), 'key' => key})
|
119
120
|
end
|
120
121
|
|
121
122
|
def get_state(key)
|
122
123
|
send_msg_to_parent({'get_state' => key})
|
123
124
|
ret = read_message()
|
124
125
|
if ret['state']
|
125
|
-
return
|
126
|
+
return Marshal.load(Base64.decode64(ret['state']))
|
126
127
|
else
|
127
128
|
return nil
|
128
129
|
end
|
@@ -131,8 +132,8 @@ module Zillabyte
|
|
131
132
|
def emit(*args)
|
132
133
|
|
133
134
|
stream = nil
|
134
|
-
tuple =
|
135
|
-
meta =
|
135
|
+
tuple = {}
|
136
|
+
meta = {}
|
136
137
|
|
137
138
|
if (args.size == 1)
|
138
139
|
tuple = args[0]
|
@@ -151,7 +152,7 @@ module Zillabyte
|
|
151
152
|
end
|
152
153
|
|
153
154
|
if tuple.is_a?(Tuple)
|
154
|
-
meta = meta ||
|
155
|
+
meta = tuple.meta || {} if meta == {}
|
155
156
|
tuple = tuple.values
|
156
157
|
end
|
157
158
|
|
@@ -319,7 +320,7 @@ module Zillabyte
|
|
319
320
|
begin
|
320
321
|
t = Tuple.from_hash(read_command)
|
321
322
|
next if(!t)
|
322
|
-
keep t
|
323
|
+
emit t if keep t
|
323
324
|
rescue SignalException => e
|
324
325
|
raise
|
325
326
|
rescue Exception => e
|
@@ -419,9 +420,7 @@ module Zillabyte
|
|
419
420
|
end
|
420
421
|
|
421
422
|
def keep(*args)
|
422
|
-
|
423
|
-
emit args[0]
|
424
|
-
end
|
423
|
+
self.instance_exec *args, &@harness._keep
|
425
424
|
end
|
426
425
|
|
427
426
|
def prepare(*args)
|
@@ -1,16 +1,11 @@
|
|
1
1
|
class Zillabyte::Harness::Sink
|
2
|
-
attr_accessor :_name, :_relation, :_type, :_columns, :
|
2
|
+
attr_accessor :_name, :_relation, :_type, :_columns, :_scope
|
3
3
|
|
4
4
|
def initialize()
|
5
5
|
@_type = 'sink'
|
6
6
|
@_columns = []
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
def consumes(v)
|
11
|
-
@_consumes = v
|
12
|
-
end
|
13
|
-
|
14
9
|
def name(v)
|
15
10
|
@_name = v
|
16
11
|
end
|
@@ -19,7 +19,6 @@ class Zillabyte::Harness::Stream
|
|
19
19
|
if(block.arity == 0)
|
20
20
|
h.instance_eval(&block)
|
21
21
|
Zillabyte::Harness::Helper.check_name("each", h._name, @_app._names)
|
22
|
-
Zillabyte::Harness::Helper.check_each(h)
|
23
22
|
if h._emits
|
24
23
|
Zillabyte::Harness::Helper.check_emits("each", h._emits, @_app._streams)
|
25
24
|
else
|
@@ -30,11 +29,15 @@ class Zillabyte::Harness::Stream
|
|
30
29
|
h._emits = ["stream_"+Zillabyte::Harness::Counter.get()]
|
31
30
|
h._execute = block
|
32
31
|
end
|
32
|
+
|
33
|
+
Zillabyte::Harness::Helper.check_each(h)
|
33
34
|
@_app._nodes << h
|
35
|
+
|
34
36
|
if(@_app._options[:command] == :info)
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
node_hash = {"name" => h._name, "type" => h._type}
|
38
|
+
Zillabyte::Harness::Helper.write_node_to_file(node_hash, @_app._info_file)
|
39
|
+
arc_hash = {"name" => @_name, "origin" => @_previous_node_name, "dest" => h._name}
|
40
|
+
Zillabyte::Harness::Helper.write_arc_to_file(arc_hash, @_app._info_file)
|
38
41
|
elsif(@_app._options[:command] == :execute and @_app._options[:name] == h._name)
|
39
42
|
pipe_name = @_app._options[:pipe]
|
40
43
|
c = Zillabyte::Harness::EachController.new(h, progress = Zillabyte::Common::Progress.new)
|
@@ -43,7 +46,7 @@ class Zillabyte::Harness::Stream
|
|
43
46
|
|
44
47
|
output_streams = []
|
45
48
|
h._emits.each do |stream|
|
46
|
-
output_streams <<
|
49
|
+
output_streams << self.class.new(stream, @_app, h._name)
|
47
50
|
end
|
48
51
|
output_streams = output_streams[0] if output_streams.size == 1
|
49
52
|
output_streams
|
@@ -51,26 +54,36 @@ class Zillabyte::Harness::Stream
|
|
51
54
|
|
52
55
|
def filter(&block)
|
53
56
|
h = Zillabyte::Harness::Filter.new()
|
54
|
-
|
55
|
-
|
57
|
+
# Does the block take 0 arguments? If so it's not just a keep block.
|
58
|
+
if(block.arity == 0)
|
59
|
+
h.instance_eval(&block)
|
60
|
+
Zillabyte::Harness::Helper.check_name("filter", h._name, @_app._names)
|
61
|
+
if h._emits
|
62
|
+
Zillabyte::Harness::Helper.check_emits("filter", h._emits, @_app._streams)
|
63
|
+
else
|
64
|
+
h._emits = ["stream_"+Zillabyte::Harness::Counter.get()]
|
65
|
+
end
|
66
|
+
else
|
67
|
+
h._emits = ["stream_"+Zillabyte::Harness::Counter.get()]
|
68
|
+
h._keep = block
|
69
|
+
end
|
56
70
|
|
71
|
+
Zillabyte::Harness::Helper.check_filter(h)
|
57
72
|
@_app._nodes << h
|
73
|
+
|
58
74
|
if(@_app._options[:command] == :info)
|
59
|
-
|
60
|
-
|
61
|
-
|
75
|
+
node_hash = {"name" => h._name, "type" => h._type}
|
76
|
+
Zillabyte::Harness::Helper.write_node_to_file(node_hash, @_app._info_file)
|
77
|
+
arc_hash = {"name" => @_name, "origin" => @_previous_node_name, "dest" => h._name}
|
78
|
+
Zillabyte::Harness::Helper.write_arc_to_file(arc_hash, @_app._info_file)
|
62
79
|
elsif(@_app._options[:command] == :execute and @_app._options[:name] == h._name)
|
63
80
|
pipe_name = @_app._options[:pipe]
|
64
81
|
c = Zillabyte::Harness::FilterController.new(h, progress = Zillabyte::Common::Progress.new)
|
65
82
|
c.run(pipe_name)
|
66
83
|
end
|
67
84
|
|
68
|
-
|
69
|
-
|
70
|
-
output_streams << Zillabyte::Harness::Stream.new(stream, @_app, h._name)
|
71
|
-
end
|
72
|
-
output_streams = output_streams[0] if output_streams.size == 1
|
73
|
-
output_streams
|
85
|
+
output_stream = self.class.new(h._emits[0], @_app, h._name) # filters only have one output stream
|
86
|
+
output_stream
|
74
87
|
end
|
75
88
|
|
76
89
|
def group_by(*args, &block)
|
@@ -81,11 +94,7 @@ class Zillabyte::Harness::Stream
|
|
81
94
|
# Yield
|
82
95
|
h.instance_eval(&block)
|
83
96
|
Zillabyte::Harness::Helper.check_name("group_by", h._name, @_app._names)
|
84
|
-
|
85
|
-
# Sanity checks
|
86
|
-
# Zillabyte::Harness::Helper.check_group_by("aggregate", h, @_nodes, @_streams)
|
87
|
-
# @_branched = Zillabyte::Harness::Helper.check_emits("aggregate", h._emits, @_streams) || @_branched
|
88
|
-
|
97
|
+
|
89
98
|
# Multiple emits?
|
90
99
|
if h._emits
|
91
100
|
Zillabyte::Harness::Helper.check_emits("group_by", h._emits, @_app._streams)
|
@@ -93,18 +102,20 @@ class Zillabyte::Harness::Stream
|
|
93
102
|
h._emits = ["stream_"+Zillabyte::Harness::Counter.get()]
|
94
103
|
end
|
95
104
|
|
96
|
-
|
105
|
+
Zillabyte::Harness::Helper.check_group_by(h)
|
97
106
|
@_app._nodes << h
|
98
107
|
|
99
108
|
# Handle incoming command..
|
100
109
|
if(@_app._options[:command] == :info)
|
101
110
|
|
102
111
|
# Info..
|
103
|
-
|
104
|
-
Zillabyte::Harness::Helper.
|
112
|
+
node_hash = {"name" => h._name, "type" => h._type, "group_by" => h._group_by}
|
113
|
+
Zillabyte::Harness::Helper.write_node_to_file(node_hash, @_app._info_file)
|
114
|
+
arc_hash = {"name" => @_name, "origin" => @_previous_node_name, "dest" => h._name}
|
115
|
+
Zillabyte::Harness::Helper.write_arc_to_file(arc_hash, @_app._info_file)
|
105
116
|
|
106
117
|
elsif(@_app._options[:command] == :execute and @_app._options[:name] == h._name)
|
107
|
-
|
118
|
+
|
108
119
|
# Execute..
|
109
120
|
pipe_name = @_app._options[:pipe]
|
110
121
|
c = Zillabyte::Harness::GroupByController.new(h, Zillabyte::Common::Progress.new)
|
@@ -112,24 +123,20 @@ class Zillabyte::Harness::Stream
|
|
112
123
|
|
113
124
|
end
|
114
125
|
|
115
|
-
|
116
|
-
|
117
126
|
# Return the stream
|
118
127
|
output_streams = []
|
119
128
|
h._emits.each do |stream|
|
120
|
-
output_streams <<
|
129
|
+
output_streams << self.class.new(stream, @_app, h._name)
|
121
130
|
end
|
122
131
|
output_streams = output_streams[0] if output_streams.size == 1
|
123
132
|
output_streams
|
124
133
|
|
125
134
|
end
|
126
135
|
|
127
|
-
|
128
|
-
|
129
136
|
def join_with(rhs_stream, *args, &block)
|
130
137
|
|
131
138
|
# Init
|
132
|
-
h = Zillabyte::Harness::Join.new(
|
139
|
+
h = Zillabyte::Harness::Join.new(*args)
|
133
140
|
|
134
141
|
# Yield
|
135
142
|
throw "programmable joins are not supported at this time" unless block.nil?
|
@@ -137,33 +144,30 @@ class Zillabyte::Harness::Stream
|
|
137
144
|
|
138
145
|
# Sanity
|
139
146
|
Zillabyte::Harness::Helper.check_name("join", h._name, @_app._names)
|
140
|
-
|
141
|
-
when :inner,:left,:right
|
142
|
-
when :outer
|
143
|
-
Zillabyte::Harness::Helper.print_error("Outer joins are currently not supported")
|
144
|
-
else
|
145
|
-
Zillabyte::Harness::Helper.print_error("Unknown join type: #{h._join_type}")
|
146
|
-
end
|
147
|
-
|
147
|
+
|
148
148
|
# Build the node
|
149
|
-
|
150
|
-
|
149
|
+
if h._emits
|
150
|
+
Zillabyte::Harness::Helper.check_emits("join", h._emits, @_app._streams)
|
151
|
+
else
|
152
|
+
h._emits = ["stream_"+Zillabyte::Harness::Counter.get()]
|
153
|
+
end
|
154
|
+
|
155
|
+
Zillabyte::Harness::Helper.check_join(h)
|
151
156
|
@_app._nodes << h
|
152
157
|
|
153
158
|
# Handle incoming command..
|
154
159
|
if(@_app._options[:command] == :info)
|
155
160
|
# Info..
|
156
|
-
|
157
|
-
"name" => h._name,
|
161
|
+
node_hash = {"name" => h._name,
|
158
162
|
"type" => h._type,
|
159
|
-
"consumes_lhs" => h._lhs_stream._name,
|
160
|
-
"consumes_rhs" => h._rhs_stream._name,
|
161
163
|
"lhs_fields" => h._lhs_fields,
|
162
164
|
"rhs_fields" => h._rhs_fields,
|
163
|
-
"join_type" => h._join_type
|
164
|
-
|
165
|
-
}
|
166
|
-
Zillabyte::Harness::Helper.
|
165
|
+
"join_type" => h._join_type}
|
166
|
+
Zillabyte::Harness::Helper.write_node_to_file(node_hash, @_app._info_file)
|
167
|
+
arc_hash1 = {"name" => @_name, "origin" => @_previous_node_name, "dest" => h._name, "left" => 1}
|
168
|
+
Zillabyte::Harness::Helper.write_arc_to_file(arc_hash1, @_app._info_file)
|
169
|
+
arc_hash2 = {"name" => rhs_stream._name, "origin" => rhs_stream._previous_node_name, "dest" => h._name, "right" => 1}
|
170
|
+
Zillabyte::Harness::Helper.write_arc_to_file(arc_hash2, @_app._info_file)
|
167
171
|
|
168
172
|
elsif(@_app._options[:command] == :execute and @_app._options[:name] == h._name)
|
169
173
|
|
@@ -173,13 +177,38 @@ class Zillabyte::Harness::Stream
|
|
173
177
|
end
|
174
178
|
|
175
179
|
# Return the stream
|
176
|
-
output_stream =
|
180
|
+
output_stream = self.class.new(h._emits[0], @_app, h._name)
|
177
181
|
return output_stream
|
178
182
|
|
179
183
|
end
|
180
184
|
|
185
|
+
def call_component(&block)
|
186
|
+
h = Zillabyte::Harness::InjectedComponent.new()
|
187
|
+
h.instance_eval(&block)
|
188
|
+
Zillabyte::Harness::Helper.check_name("component", h._name, @_app._names)
|
189
|
+
Zillabyte::Harness::Helper.check_call_component(h)
|
190
|
+
Zillabyte::Harness::Helper.check_emits("component", h._emits, @_app._streams)
|
191
|
+
@_app._nodes << h
|
181
192
|
|
193
|
+
if(@_app._options[:command] == :info)
|
194
|
+
node_hash = {"name" => h._name, "type" => h._type, "id" => h._id, "output_format" => h._output_format}
|
195
|
+
Zillabyte::Harness::Helper.write_node_to_file(node_hash, @_app._info_file)
|
196
|
+
arc_hash = {"name" => @_name, "origin" => @_previous_node_name, "dest" => h._name}
|
197
|
+
Zillabyte::Harness::Helper.write_arc_to_file(arc_hash, @_app._info_file)
|
198
|
+
h._consumes.each do |stream|
|
199
|
+
arc_hash = {"name" => stream._name, "origin" => stream._previous_node_name, "dest" => h._name}
|
200
|
+
Zillabyte::Harness::Helper.write_arc_to_file(arc_hash, @_app._info_file)
|
201
|
+
end
|
202
|
+
end
|
182
203
|
|
204
|
+
# Return the stream
|
205
|
+
output_streams = []
|
206
|
+
h._emits.each do |stream|
|
207
|
+
output_streams << self.class.new(stream, @_app, h._name)
|
208
|
+
end
|
209
|
+
output_streams = output_streams[0] if output_streams.size == 1
|
210
|
+
output_streams
|
211
|
+
end
|
183
212
|
|
184
213
|
def sink(&block)
|
185
214
|
h = Zillabyte::Harness::Sink.new()
|
@@ -187,8 +216,10 @@ class Zillabyte::Harness::Stream
|
|
187
216
|
Zillabyte::Harness::Helper.check_sink(h, @_app._nodes)
|
188
217
|
@_app._nodes << h
|
189
218
|
if(@_app._options[:command] == :info)
|
190
|
-
|
191
|
-
Zillabyte::Harness::Helper.
|
219
|
+
node_hash = {"name" => h._name, "type" => h._type, "columns" => h._columns, "relation" => h._relation || h._name, "scope" => h._scope}
|
220
|
+
Zillabyte::Harness::Helper.write_node_to_file(node_hash, @_app._info_file)
|
221
|
+
arc_hash = {"name" => @_name, "origin" => @_previous_node_name, "dest" => h._name}
|
222
|
+
Zillabyte::Harness::Helper.write_arc_to_file(arc_hash, @_app._info_file)
|
192
223
|
end
|
193
224
|
end
|
194
225
|
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zillabyte
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zillabyte
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mkfifo
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: zillabyte-cli
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.0
|
47
|
+
version: 0.1.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.0
|
54
|
+
version: 0.1.0
|
55
55
|
description: The Official Zillabyte Gem
|
56
56
|
email:
|
57
57
|
- gem@zillabyte.com
|
@@ -59,22 +59,28 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ruby/lib/zillabyte.rb
|
62
63
|
- ruby/lib/zillabyte/common/progress.rb
|
64
|
+
- ruby/lib/zillabyte/harness.rb
|
63
65
|
- ruby/lib/zillabyte/harness/app.rb
|
66
|
+
- ruby/lib/zillabyte/harness/base.rb
|
67
|
+
- ruby/lib/zillabyte/harness/component.rb
|
68
|
+
- ruby/lib/zillabyte/harness/component_sink.rb
|
69
|
+
- ruby/lib/zillabyte/harness/component_source.rb
|
70
|
+
- ruby/lib/zillabyte/harness/component_stream.rb
|
64
71
|
- ruby/lib/zillabyte/harness/counter.rb
|
65
72
|
- ruby/lib/zillabyte/harness/each.rb
|
66
73
|
- ruby/lib/zillabyte/harness/filter.rb
|
67
74
|
- ruby/lib/zillabyte/harness/group_by.rb
|
68
75
|
- ruby/lib/zillabyte/harness/helper.rb
|
76
|
+
- ruby/lib/zillabyte/harness/injected_component.rb
|
69
77
|
- ruby/lib/zillabyte/harness/join.rb
|
70
78
|
- ruby/lib/zillabyte/harness/live_delegator.rb
|
71
79
|
- ruby/lib/zillabyte/harness/sink.rb
|
72
80
|
- ruby/lib/zillabyte/harness/source.rb
|
73
81
|
- ruby/lib/zillabyte/harness/stream.rb
|
74
82
|
- ruby/lib/zillabyte/harness/tuple.rb
|
75
|
-
- ruby/lib/zillabyte/harness.rb
|
76
83
|
- ruby/lib/zillabyte/version.rb
|
77
|
-
- ruby/lib/zillabyte.rb
|
78
84
|
homepage: http://www.zillabyte.com
|
79
85
|
licenses:
|
80
86
|
- MIT
|
@@ -85,17 +91,17 @@ require_paths:
|
|
85
91
|
- ruby/lib
|
86
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
93
|
requirements:
|
88
|
-
- -
|
94
|
+
- - ">="
|
89
95
|
- !ruby/object:Gem::Version
|
90
96
|
version: '0'
|
91
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
98
|
requirements:
|
93
|
-
- -
|
99
|
+
- - ">="
|
94
100
|
- !ruby/object:Gem::Version
|
95
101
|
version: '0'
|
96
102
|
requirements: []
|
97
103
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
104
|
+
rubygems_version: 2.2.2
|
99
105
|
signing_key:
|
100
106
|
specification_version: 4
|
101
107
|
summary: The Official Zillabyte Gem
|