zillabyte 0.1.1 → 0.1.3
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 +14 -6
- data/ruby/lib/zillabyte/harness/each.rb +7 -2
- data/ruby/lib/zillabyte/harness/helper.rb +42 -17
- data/ruby/lib/zillabyte/harness/injected_component.rb +1 -1
- data/ruby/lib/zillabyte/harness/live_delegator.rb +20 -27
- data/ruby/lib/zillabyte/harness/stream.rb +7 -3
- data/ruby/lib/zillabyte/version.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NTA2NGJmMzJjMjMzOTBhMDcyNDczNWIzNDc3MTgyODljMWI3YTYzMw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZWNiZDUwNGYxMGVmYjk2OTJkODJiMzlmOTFhN2JiMzQ5Zjc3NGEzOA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTMwMzFmMzk1ZTIwY2JhMmFkM2ExNzYzMmExMzViZmFmYTcxYTU2YTk0ODUz
|
10
|
+
MjgyYjY5OTkwZDhmOWRiZTUyZDQxYWRhOTg0Y2IyMzVmN2U0NjY3YzlmNDU4
|
11
|
+
OTc4NjYyNDdjYzg4MTUyZGUzYjU5NzZkZDI0YzIzZDE5MDNhZTk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YWFlNzQxMWQ5OWQxZjYzYTZiM2E4N2RmODMxMDQ4NTg4M2I0ZDA0YmVmY2Rm
|
14
|
+
Nzg1OGRmYzE1ZjEwMTE5ODJhZGZiZTQ4ZjE1YzhhM2FmY2FhYmU0YWZmMTM4
|
15
|
+
NDE4ZWQ5Mjk0Y2JkYWMyZWY0Mzk5N2JlNjAxMWM2ZTQ5NDczZmE=
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class Zillabyte::Harness::Each
|
2
|
-
attr_accessor :_name, :_type, :_emits, :_prepare, :_execute
|
2
|
+
attr_accessor :_name, :_type, :_emits, :_output_format, :_prepare, :_execute
|
3
3
|
|
4
4
|
def initialize()
|
5
5
|
@_name = "each_"+Zillabyte::Harness::Counter.get()
|
6
|
-
@_type =
|
6
|
+
@_type = "each"
|
7
|
+
@_output_format = :replace
|
7
8
|
end
|
8
9
|
|
9
10
|
def name(v)
|
@@ -14,6 +15,10 @@ class Zillabyte::Harness::Each
|
|
14
15
|
@_emits = *v
|
15
16
|
end
|
16
17
|
|
18
|
+
def output_format(v)
|
19
|
+
@_output_format = v
|
20
|
+
end
|
21
|
+
|
17
22
|
def prepare(&block)
|
18
23
|
@_prepare = block
|
19
24
|
end
|
@@ -2,6 +2,10 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
class Zillabyte::Harness::Helper
|
4
4
|
|
5
|
+
META_NAMES = ["id", "confidence", "since", "source"]
|
6
|
+
ALLOWED_OUTPUT_FORMATS = [:replace, :merge]
|
7
|
+
ALLOWED_END_CYCLE_POLICIES = [:null_emit, :explicit, :infinite]
|
8
|
+
|
5
9
|
def self.opt_parser()
|
6
10
|
options = {
|
7
11
|
"name" => Dir.pwd.split("/")[-1]
|
@@ -63,6 +67,15 @@ class Zillabyte::Harness::Helper
|
|
63
67
|
|
64
68
|
end
|
65
69
|
|
70
|
+
def self.check_output_format(operation, output_format)
|
71
|
+
ee = "Error in \"#{operation}\" at \"output_format\": \n\t "
|
72
|
+
|
73
|
+
if(!ALLOWED_OUTPUT_FORMATS.member? output_format)
|
74
|
+
msg = "#{ee}Invalid \"output_format\": #{output_format}. The allowed formats are :replace and :merge."
|
75
|
+
Zillabyte::Harness::Helper.print_error(msg)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
66
79
|
def self.check_custom_source(source)
|
67
80
|
ee = "Error in \"source\": \n\t "
|
68
81
|
pp = @@_print_check_source
|
@@ -74,8 +87,7 @@ class Zillabyte::Harness::Helper
|
|
74
87
|
Zillabyte::Harness::Helper.print_error(msg)
|
75
88
|
end
|
76
89
|
|
77
|
-
|
78
|
-
if !(allowed_policies.member? source._end_cycle_policy)
|
90
|
+
if !(ALLOWED_END_CYCLE_POLICIES.member? source._end_cycle_policy)
|
79
91
|
msg = "#{ee}Invalid \"end_cycle_policy\": \"#{source._end_cycle_policy}\". The allowed policies are :null_emit and :explicit. #{pp}"
|
80
92
|
Zillabyte::Harness::Helper.print_error(msg)
|
81
93
|
end
|
@@ -155,7 +167,9 @@ class Zillabyte::Harness::Helper
|
|
155
167
|
if !each._execute
|
156
168
|
msg = "#{ee}An \"each\" must contain an \"execute\" block. #{pp}"
|
157
169
|
Zillabyte::Harness::Helper.print_error(msg)
|
158
|
-
end
|
170
|
+
end
|
171
|
+
|
172
|
+
Zillabyte::Harness::Helper.check_output_format("each", each._output_format)
|
159
173
|
end
|
160
174
|
|
161
175
|
def self.check_group_by(group_by)
|
@@ -224,15 +238,16 @@ class Zillabyte::Harness::Helper
|
|
224
238
|
|
225
239
|
id = node._id
|
226
240
|
if !id
|
227
|
-
msg = "#{ee}
|
241
|
+
msg = "#{ee}The \"component_id\" must be specified. This may be the name or ID of the component. Check \"zillabyte components\" to find this information. #{pp}"
|
228
242
|
Zillabyte::Harness::Helper.print_error(msg)
|
229
243
|
end
|
230
244
|
|
231
|
-
|
232
|
-
|
233
|
-
msg = "#{ee} Invalid \"component_id\". The \"component_id\" must be a number. Check \"zillabyte components\" to find the correct ID. #{pp}"
|
245
|
+
if(!(id.is_a?(String) or id.is_a?(Symbol)) or (id =~ /^\w+$/).nil?)
|
246
|
+
msg = "#{ee}The \"component_id\" must be a non-empty STRING with only alphanumeric and underscore characters in \"#{id}\". #{pp}"
|
234
247
|
Zillabyte::Harness::Helper.print_error(msg)
|
235
248
|
end
|
249
|
+
|
250
|
+
Zillabyte::Harness::Helper.check_output_format("call_component", node._output_format)
|
236
251
|
end
|
237
252
|
|
238
253
|
def self.check_sink(sink, nodes)
|
@@ -281,7 +296,7 @@ class Zillabyte::Harness::Helper
|
|
281
296
|
msg = "#{ee}Field names must be non-empty STRINGS with only alphanumeric and underscore characters in \"#{relation_name}\". #{pp}"
|
282
297
|
Zillabyte::Harness::Helper.print_error(msg)
|
283
298
|
end
|
284
|
-
if(cname =~ /^v[0-9]+$/i or
|
299
|
+
if(cname =~ /^v[0-9]+$/i or META_NAMES.member?(cname.downcase))
|
285
300
|
msg = "#{ee}\"v[number]\", \"id\", \"confidence\", \"since\" and \"source\" are special names in Zillabyte. Please name your field something else. #{pp}"
|
286
301
|
Zillabyte::Harness::Helper.print_error(msg)
|
287
302
|
end
|
@@ -385,10 +400,13 @@ OUTPUT
|
|
385
400
|
Custom filter:
|
386
401
|
stream.filter do
|
387
402
|
name "name" \t\t\t => optional
|
403
|
+
emits "stream_1", "stream_2", ... \t\t => optional for single output stream
|
404
|
+
prepare |=block=| \t\t\t\t => optional if no initialization needed
|
388
405
|
keep |=block=|
|
389
406
|
end
|
390
|
-
- The "keep"
|
391
|
-
|
407
|
+
- The "prepare" and "keep" blocks can be in do...end format or {} format.
|
408
|
+
* the "prepare" block is where any setup is done to prepare for tuple processing in the "keep" block.
|
409
|
+
* tuples will pass through the filter if "keep" returns "True". It must take in a single argument (the "tuple").
|
392
410
|
OUTPUT
|
393
411
|
|
394
412
|
@@_print_check_each = <<-OUTPUT
|
@@ -404,9 +422,13 @@ OUTPUT
|
|
404
422
|
stream.each do
|
405
423
|
name "name" \t\t\t\t\t => optional
|
406
424
|
emits "stream_1", "stream_2", ... \t\t => optional for single output stream
|
425
|
+
output_format :replace OR :merge \t\t => optional, defaults to :replace
|
407
426
|
prepare |=block=| \t\t\t\t => optional if no initialization needed
|
408
427
|
execute |=block=|
|
409
428
|
end
|
429
|
+
- The allowed output formats are :replace and :merge.
|
430
|
+
* :replace - discards the input tuple values and only emits the specified values. This is the default.
|
431
|
+
* :merge - re-emits the input tuple values along with the specified values.
|
410
432
|
- The "prepare" and "execute" blocks can be in do...end format or {} format.
|
411
433
|
* the "prepare" block is where any setup is done to prepare for tuple processing in the "execute" block.
|
412
434
|
* the "execute" block is where the tuples are actually processed. It must take in a single argument (the "tuple").
|
@@ -469,12 +491,16 @@ OUTPUT
|
|
469
491
|
@@_print_check_call_component = <<-OUTPUT
|
470
492
|
\n\n"Call_component" Syntax:
|
471
493
|
stream.call_component do
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
494
|
+
component_id "component_id"
|
495
|
+
name "name" \t\t\t\t\t\t\t\t\t => optional
|
496
|
+
additional_inputs other_input_stream_object_1, other_input_stream_object_2, ... \t => blank if none
|
497
|
+
outputs "output_stream_name_1", "output_stream_name_2", ...
|
498
|
+
output_format :replace OR :merge \t\t => optional, defaults to :replace
|
499
|
+
end
|
500
|
+
- The "component_id" MUST be given and correspond to the name or id listed in the output of "zillabyte components".
|
501
|
+
- The allowed output formats are :replace and :merge. Note that only linear components, i.e. those with only "each" and "filter" operations support :merge.
|
502
|
+
* :replace - discards the input tuple values and only emits the output values. This is the default.
|
503
|
+
* :merge - re-emits the input tuple values along with the output values.
|
478
504
|
- To correctly stich in the component, the implicit assumptions below WILL BE USED:
|
479
505
|
* The "stream" that "call_component" is invoked on MUST correspond to the first listed input stream to the component.
|
480
506
|
* The streams specified in "additional_inputs" MUST correspond to the other listed input streams in order.
|
@@ -483,5 +509,4 @@ OUTPUT
|
|
483
509
|
* The number of input and output streams specified must match the number listed for the component.
|
484
510
|
OUTPUT
|
485
511
|
|
486
|
-
@@_meta_names = ["id", "confidence", "since", "source"]
|
487
512
|
end
|
@@ -89,14 +89,14 @@ module Zillabyte
|
|
89
89
|
Storm::Protocol.pending_commands.shift ||
|
90
90
|
begin
|
91
91
|
msg = read_message
|
92
|
-
while msg.is_a?(Hash) && msg['pong']
|
92
|
+
while msg && msg.is_a?(Hash) && msg['pong']
|
93
93
|
# Ignore 'pong' commands (i.e. the response from our 'pings' above)
|
94
94
|
msg = read_message
|
95
95
|
end
|
96
96
|
msg
|
97
|
-
rescue
|
98
|
-
|
99
|
-
|
97
|
+
rescue StandardError => e
|
98
|
+
log "message error: #{e}"
|
99
|
+
nil
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -114,21 +114,6 @@ module Zillabyte
|
|
114
114
|
File.open("#{heartbeat_dir}/#{pid}", "w").close
|
115
115
|
end
|
116
116
|
|
117
|
-
|
118
|
-
def set_state(key, val)
|
119
|
-
send_msg_to_parent({'set_state' => Base64.encode64(Marshal.dump(val)), 'key' => key})
|
120
|
-
end
|
121
|
-
|
122
|
-
def get_state(key)
|
123
|
-
send_msg_to_parent({'get_state' => key})
|
124
|
-
ret = read_message()
|
125
|
-
if ret['state']
|
126
|
-
return Marshal.load(Base64.decode64(ret['state']))
|
127
|
-
else
|
128
|
-
return nil
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
117
|
def emit(*args)
|
133
118
|
|
134
119
|
stream = nil
|
@@ -243,7 +228,7 @@ module Zillabyte
|
|
243
228
|
|
244
229
|
while true
|
245
230
|
begin
|
246
|
-
msg = read_command
|
231
|
+
msg = read_command || {}
|
247
232
|
case msg['command']
|
248
233
|
when 'begin_cycle'
|
249
234
|
begin_cycle
|
@@ -287,9 +272,13 @@ module Zillabyte
|
|
287
272
|
|
288
273
|
while true
|
289
274
|
begin
|
290
|
-
|
291
|
-
|
292
|
-
|
275
|
+
m = read_command()
|
276
|
+
if(m)
|
277
|
+
t = Tuple.from_hash(m)
|
278
|
+
if(t)
|
279
|
+
execute t
|
280
|
+
end
|
281
|
+
end
|
293
282
|
rescue SignalException => e
|
294
283
|
raise
|
295
284
|
rescue ParentDeadException => e
|
@@ -318,9 +307,13 @@ module Zillabyte
|
|
318
307
|
|
319
308
|
while true
|
320
309
|
begin
|
321
|
-
|
322
|
-
|
323
|
-
|
310
|
+
m = read_command()
|
311
|
+
if m
|
312
|
+
t = Tuple.from_hash(m)
|
313
|
+
if t
|
314
|
+
emit(t) if keep t
|
315
|
+
end
|
316
|
+
end
|
324
317
|
rescue SignalException => e
|
325
318
|
raise
|
326
319
|
rescue Exception => e
|
@@ -343,7 +336,7 @@ module Zillabyte
|
|
343
336
|
|
344
337
|
while true
|
345
338
|
begin
|
346
|
-
msg = read_command
|
339
|
+
msg = read_command || {}
|
347
340
|
case msg['command']
|
348
341
|
when 'begin_group'
|
349
342
|
t = Tuple.from_hash(msg)
|
@@ -34,7 +34,7 @@ class Zillabyte::Harness::Stream
|
|
34
34
|
@_app._nodes << h
|
35
35
|
|
36
36
|
if(@_app._options[:command] == :info)
|
37
|
-
node_hash = {"name" => h._name, "type" => h._type}
|
37
|
+
node_hash = {"name" => h._name, "type" => h._type, "output_format" => h._output_format}
|
38
38
|
Zillabyte::Harness::Helper.write_node_to_file(node_hash, @_app._info_file)
|
39
39
|
arc_hash = {"name" => @_name, "origin" => @_previous_node_name, "dest" => h._name}
|
40
40
|
Zillabyte::Harness::Helper.write_arc_to_file(arc_hash, @_app._info_file)
|
@@ -182,9 +182,13 @@ class Zillabyte::Harness::Stream
|
|
182
182
|
|
183
183
|
end
|
184
184
|
|
185
|
-
def call_component(&block)
|
185
|
+
def call_component(comp_id = nil, &block)
|
186
|
+
|
186
187
|
h = Zillabyte::Harness::InjectedComponent.new()
|
187
|
-
h.instance_eval(&block)
|
188
|
+
h.instance_eval(&block) if block_given?
|
189
|
+
h._id ||= comp_id
|
190
|
+
h._emits ||= ["stream_"+Zillabyte::Harness::Counter.get()] # We default to single-stream when called like this..
|
191
|
+
|
188
192
|
Zillabyte::Harness::Helper.check_name("component", h._name, @_app._names)
|
189
193
|
Zillabyte::Harness::Helper.check_call_component(h)
|
190
194
|
Zillabyte::Harness::Helper.check_emits("component", h._emits, @_app._streams)
|
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.1.
|
4
|
+
version: 0.1.3
|
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-07-14 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.1.
|
47
|
+
version: 0.1.3
|
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.1.
|
54
|
+
version: 0.1.3
|
55
55
|
description: The Official Zillabyte Gem
|
56
56
|
email:
|
57
57
|
- gem@zillabyte.com
|
@@ -59,9 +59,7 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- ruby/lib/zillabyte.rb
|
63
62
|
- ruby/lib/zillabyte/common/progress.rb
|
64
|
-
- ruby/lib/zillabyte/harness.rb
|
65
63
|
- ruby/lib/zillabyte/harness/app.rb
|
66
64
|
- ruby/lib/zillabyte/harness/base.rb
|
67
65
|
- ruby/lib/zillabyte/harness/component.rb
|
@@ -80,7 +78,9 @@ files:
|
|
80
78
|
- ruby/lib/zillabyte/harness/source.rb
|
81
79
|
- ruby/lib/zillabyte/harness/stream.rb
|
82
80
|
- ruby/lib/zillabyte/harness/tuple.rb
|
81
|
+
- ruby/lib/zillabyte/harness.rb
|
83
82
|
- ruby/lib/zillabyte/version.rb
|
83
|
+
- ruby/lib/zillabyte.rb
|
84
84
|
homepage: http://www.zillabyte.com
|
85
85
|
licenses:
|
86
86
|
- MIT
|
@@ -91,17 +91,17 @@ require_paths:
|
|
91
91
|
- ruby/lib
|
92
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ! '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ! '>='
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.
|
104
|
+
rubygems_version: 2.0.6
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: The Official Zillabyte Gem
|