fairy 0.6.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.
- data/LICENSE +674 -0
- data/Makefile +116 -0
- data/README +15 -0
- data/bin/fairy +582 -0
- data/bin/fairy-cat +74 -0
- data/bin/fairy-cp +128 -0
- data/bin/fairy-rm +122 -0
- data/bin/subcmd/controller +41 -0
- data/bin/subcmd/inspector +81 -0
- data/bin/subcmd/master +43 -0
- data/bin/subcmd/node +47 -0
- data/bin/subcmd/processor +54 -0
- data/doc/programming-interface.html +240 -0
- data/doc/programming-interface.rd +300 -0
- data/etc/fairy.conf.tmpl +118 -0
- data/ext/simple_hash/extconf.rb +4 -0
- data/ext/simple_hash/simple_hash.c +42 -0
- data/fairy.gemspec +60 -0
- data/lib/fairy/client/addins.rb +20 -0
- data/lib/fairy/client/barrier.rb +29 -0
- data/lib/fairy/client/basic-group-by.rb +52 -0
- data/lib/fairy/client/cat.rb +41 -0
- data/lib/fairy/client/direct-product.rb +51 -0
- data/lib/fairy/client/equijoin.rb +79 -0
- data/lib/fairy/client/exec.rb +54 -0
- data/lib/fairy/client/filter.rb +62 -0
- data/lib/fairy/client/find.rb +35 -0
- data/lib/fairy/client/group-by.rb +194 -0
- data/lib/fairy/client/here.rb +84 -0
- data/lib/fairy/client/inject.rb +70 -0
- data/lib/fairy/client/input-file.rb +53 -0
- data/lib/fairy/client/input-iota.rb +49 -0
- data/lib/fairy/client/input-local-file.rb +188 -0
- data/lib/fairy/client/input-varray.rb +30 -0
- data/lib/fairy/client/input.rb +42 -0
- data/lib/fairy/client/io-filter.rb +26 -0
- data/lib/fairy/client/junction.rb +31 -0
- data/lib/fairy/client/map.rb +34 -0
- data/lib/fairy/client/merge-group-by.rb +71 -0
- data/lib/fairy/client/output-file.rb +64 -0
- data/lib/fairy/client/output-local-file.rb +60 -0
- data/lib/fairy/client/output-null.rb +47 -0
- data/lib/fairy/client/output-varray.rb +50 -0
- data/lib/fairy/client/output.rb +29 -0
- data/lib/fairy/client/roma-put.rb +62 -0
- data/lib/fairy/client/roma.rb +156 -0
- data/lib/fairy/client/seg-join.rb +61 -0
- data/lib/fairy/client/seg-map.rb +78 -0
- data/lib/fairy/client/seg-shuffle.rb +35 -0
- data/lib/fairy/client/seg-split.rb +27 -0
- data/lib/fairy/client/seg-zip.rb +60 -0
- data/lib/fairy/client/select.rb +38 -0
- data/lib/fairy/client/sort.rb +48 -0
- data/lib/fairy/client/sort18.rb +56 -0
- data/lib/fairy/client/sort19.rb +61 -0
- data/lib/fairy/client/there.rb +47 -0
- data/lib/fairy/client/top_n_into_roma.rb +34 -0
- data/lib/fairy/client/wc.rb +92 -0
- data/lib/fairy/controller.rb +1103 -0
- data/lib/fairy/logger.rb +107 -0
- data/lib/fairy/master/addins.rb +20 -0
- data/lib/fairy/master/atom.rb +17 -0
- data/lib/fairy/master/c-barrier.rb +283 -0
- data/lib/fairy/master/c-basic-group-by.rb +250 -0
- data/lib/fairy/master/c-cat.rb +159 -0
- data/lib/fairy/master/c-direct-product.rb +203 -0
- data/lib/fairy/master/c-exec.rb +68 -0
- data/lib/fairy/master/c-filter.rb +422 -0
- data/lib/fairy/master/c-find.rb +138 -0
- data/lib/fairy/master/c-group-by.rb +64 -0
- data/lib/fairy/master/c-here.rb +80 -0
- data/lib/fairy/master/c-inject.rb +119 -0
- data/lib/fairy/master/c-input-file.rb +46 -0
- data/lib/fairy/master/c-input-iota.rb +66 -0
- data/lib/fairy/master/c-input-local-file.rb +117 -0
- data/lib/fairy/master/c-input-varray.rb +53 -0
- data/lib/fairy/master/c-input.rb +24 -0
- data/lib/fairy/master/c-inputtable.rb +31 -0
- data/lib/fairy/master/c-inputtable18.rb +36 -0
- data/lib/fairy/master/c-inputtable19.rb +35 -0
- data/lib/fairy/master/c-io-filter.rb +28 -0
- data/lib/fairy/master/c-junction.rb +54 -0
- data/lib/fairy/master/c-map.rb +27 -0
- data/lib/fairy/master/c-merge-group-by.rb +241 -0
- data/lib/fairy/master/c-output-file.rb +84 -0
- data/lib/fairy/master/c-output-local-file.rb +19 -0
- data/lib/fairy/master/c-output-null.rb +45 -0
- data/lib/fairy/master/c-output-varray.rb +57 -0
- data/lib/fairy/master/c-output.rb +20 -0
- data/lib/fairy/master/c-seg-join.rb +141 -0
- data/lib/fairy/master/c-seg-map.rb +26 -0
- data/lib/fairy/master/c-seg-shuffle.rb +87 -0
- data/lib/fairy/master/c-seg-split.rb +110 -0
- data/lib/fairy/master/c-seg-zip.rb +132 -0
- data/lib/fairy/master/c-select.rb +27 -0
- data/lib/fairy/master/c-sort.rb +108 -0
- data/lib/fairy/master/c-there.rb +57 -0
- data/lib/fairy/master/c-wc.rb +232 -0
- data/lib/fairy/master/job-interpriter.rb +19 -0
- data/lib/fairy/master/scheduler.rb +24 -0
- data/lib/fairy/master.rb +329 -0
- data/lib/fairy/node/addins.rb +19 -0
- data/lib/fairy/node/p-barrier.rb +95 -0
- data/lib/fairy/node/p-basic-group-by.rb +252 -0
- data/lib/fairy/node/p-direct-product.rb +153 -0
- data/lib/fairy/node/p-exec.rb +30 -0
- data/lib/fairy/node/p-filter.rb +363 -0
- data/lib/fairy/node/p-find.rb +111 -0
- data/lib/fairy/node/p-group-by.rb +1534 -0
- data/lib/fairy/node/p-here.rb +21 -0
- data/lib/fairy/node/p-identity.rb +24 -0
- data/lib/fairy/node/p-inject.rb +127 -0
- data/lib/fairy/node/p-input-file.rb +108 -0
- data/lib/fairy/node/p-input-iota.rb +39 -0
- data/lib/fairy/node/p-input-local-file.rb +61 -0
- data/lib/fairy/node/p-input-varray.rb +26 -0
- data/lib/fairy/node/p-io-filter.rb +28 -0
- data/lib/fairy/node/p-map.rb +40 -0
- data/lib/fairy/node/p-merger-group-by.rb +48 -0
- data/lib/fairy/node/p-output-file.rb +104 -0
- data/lib/fairy/node/p-output-local-file.rb +14 -0
- data/lib/fairy/node/p-output-null.rb +32 -0
- data/lib/fairy/node/p-output-varray.rb +41 -0
- data/lib/fairy/node/p-seg-join.rb +82 -0
- data/lib/fairy/node/p-seg-map.rb +34 -0
- data/lib/fairy/node/p-seg-split.rb +61 -0
- data/lib/fairy/node/p-seg-zip.rb +79 -0
- data/lib/fairy/node/p-select.rb +40 -0
- data/lib/fairy/node/p-single-exportable.rb +90 -0
- data/lib/fairy/node/p-sort.rb +195 -0
- data/lib/fairy/node/p-task.rb +113 -0
- data/lib/fairy/node/p-there.rb +44 -0
- data/lib/fairy/node/p-wc.rb +266 -0
- data/lib/fairy/node.rb +187 -0
- data/lib/fairy/processor.rb +510 -0
- data/lib/fairy/share/base-app.rb +114 -0
- data/lib/fairy/share/block-source.rb +234 -0
- data/lib/fairy/share/conf.rb +396 -0
- data/lib/fairy/share/debug.rb +21 -0
- data/lib/fairy/share/encoding.rb +17 -0
- data/lib/fairy/share/fast-tempfile.rb +93 -0
- data/lib/fairy/share/file-place.rb +176 -0
- data/lib/fairy/share/hash-1.rb +20 -0
- data/lib/fairy/share/hash-md5.rb +28 -0
- data/lib/fairy/share/hash-murmur.rb +69 -0
- data/lib/fairy/share/hash-rb18.rb +20 -0
- data/lib/fairy/share/hash-simple-hash.rb +28 -0
- data/lib/fairy/share/inspector.rb +16 -0
- data/lib/fairy/share/lc/exceptions.rb +82 -0
- data/lib/fairy/share/lc/ja/exceptions.rb +81 -0
- data/lib/fairy/share/locale.rb +17 -0
- data/lib/fairy/share/log.rb +215 -0
- data/lib/fairy/share/pool-dictionary.rb +53 -0
- data/lib/fairy/share/port-marshaled-queue.rb +347 -0
- data/lib/fairy/share/port.rb +1697 -0
- data/lib/fairy/share/reference.rb +45 -0
- data/lib/fairy/share/stdout.rb +56 -0
- data/lib/fairy/share/tr.rb +16 -0
- data/lib/fairy/share/varray.rb +147 -0
- data/lib/fairy/share/vfile.rb +183 -0
- data/lib/fairy/version.rb +8 -0
- data/lib/fairy.rb +206 -0
- data/sample/grep.rb +46 -0
- data/sample/ping.rb +19 -0
- data/sample/sort.rb +102 -0
- data/sample/wordcount.rb +61 -0
- data/spec/README +12 -0
- data/spec/fairy1_spec.rb +31 -0
- data/spec/fairy2_spec.rb +42 -0
- data/spec/fairy3_spec.rb +126 -0
- data/spec/fairy4_spec.rb +63 -0
- data/spec/fairy5_spec.rb +45 -0
- data/spec/fairy6_spec.rb +52 -0
- data/spec/fairy7_spec.rb +58 -0
- data/spec/fairy8_spec.rb +48 -0
- data/spec/mkdat.rb +148 -0
- data/spec/run_all.sh +65 -0
- data/test/testc.rb +7111 -0
- data/tools/cap_recipe/Capfile +144 -0
- data/tools/cap_recipe/cluster.yml.sample +14 -0
- data/tools/fairy_perf_graph.rb +444 -0
- data/tools/git-tag +44 -0
- data/tools/log-analysis.rb +62 -0
- data/tools/svn-ls-diff +38 -0
- data/tools/svn-tags +37 -0
- metadata +298 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
require "fairy/master/c-filter"
|
|
7
|
+
require "fairy/master/c-inputtable"
|
|
8
|
+
|
|
9
|
+
module Fairy
|
|
10
|
+
class COutput<CFilter
|
|
11
|
+
include CInputtable
|
|
12
|
+
|
|
13
|
+
def input=(input)
|
|
14
|
+
@input = input
|
|
15
|
+
input.output = @input
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
require "fairy/master/c-io-filter"
|
|
7
|
+
require "fairy/master/c-inputtable"
|
|
8
|
+
|
|
9
|
+
module Fairy
|
|
10
|
+
class CSegJoin<CIOFilter
|
|
11
|
+
Controller.def_export self
|
|
12
|
+
|
|
13
|
+
# DeepConnect.def_single_method_spec(self, "REF new(REF, VAL, VAL, REF)")
|
|
14
|
+
|
|
15
|
+
def initialize(controller, opts, others, block_source)
|
|
16
|
+
super
|
|
17
|
+
@others = others
|
|
18
|
+
@block_source = block_source
|
|
19
|
+
|
|
20
|
+
@exports = {}
|
|
21
|
+
@others_status = {}
|
|
22
|
+
@exports_mutex = Mutex.new
|
|
23
|
+
@exports_cv = ConditionVariable.new
|
|
24
|
+
|
|
25
|
+
@key_proc
|
|
26
|
+
init_key_proc
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def init_key_proc
|
|
30
|
+
case join_by
|
|
31
|
+
when :ORDER
|
|
32
|
+
@key_proc = proc{|input| input.no}
|
|
33
|
+
when :KEY
|
|
34
|
+
@key_proc = proc{|input| input.key}
|
|
35
|
+
else
|
|
36
|
+
ERR::Raise ERR::UnrecoginizedOption, join_by
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def join_by
|
|
41
|
+
by = @opts[:by]
|
|
42
|
+
return :ORDER unless by
|
|
43
|
+
by.to_s.upcase.intern
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def node_class_name
|
|
47
|
+
"PSegJoin"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def njob_creation_params
|
|
51
|
+
[@block_source]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def start_create_nodes
|
|
55
|
+
Log::debug self, "START_CREATE_NODES: #{self}"
|
|
56
|
+
@others.each do |other|
|
|
57
|
+
Thread.start do
|
|
58
|
+
other.each_assigned_filter do |input_filter|
|
|
59
|
+
@exports_mutex.synchronize do
|
|
60
|
+
unless exps = @exports[@key_proc.call(input_filter)]
|
|
61
|
+
exps = @exports[@key_proc.call(input_filter)] = {}
|
|
62
|
+
@exports_cv.broadcast
|
|
63
|
+
end
|
|
64
|
+
exp = input_filter.start_export
|
|
65
|
+
exps[other] = exp
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
@exports_mutex.synchronize do
|
|
69
|
+
@others_status[other] = true
|
|
70
|
+
@exports_cv.broadcast
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
super
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def create_and_add_node(ntask, mapper, opts={})
|
|
78
|
+
node = create_node(ntask) {|node|
|
|
79
|
+
if opts[:init_njob]
|
|
80
|
+
opts[:init_njob].call(node)
|
|
81
|
+
end
|
|
82
|
+
mapper.bind_input(node)
|
|
83
|
+
|
|
84
|
+
key = @key_proc.call(node)
|
|
85
|
+
exps = nil
|
|
86
|
+
@exports_mutex.synchronize do
|
|
87
|
+
while !(exps = other_filter_of(key))
|
|
88
|
+
@exports_cv.wait(@exports_mutex)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
node.join_inputs = exps
|
|
92
|
+
exps.zip(node.join_imports) do |other, import|
|
|
93
|
+
other.output = import
|
|
94
|
+
import.no_import = 1
|
|
95
|
+
end
|
|
96
|
+
}
|
|
97
|
+
node
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class NoAllFilter<Exception;end
|
|
101
|
+
|
|
102
|
+
def other_filter_of(key)
|
|
103
|
+
begin
|
|
104
|
+
@others.collect do |o|
|
|
105
|
+
unless exp = @exports[key][o]
|
|
106
|
+
unless @other_status[o]
|
|
107
|
+
raise NoAllFilter
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
exp
|
|
111
|
+
end
|
|
112
|
+
rescue NoAllFilter
|
|
113
|
+
return nil
|
|
114
|
+
rescue
|
|
115
|
+
return nil
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def break_running
|
|
120
|
+
super
|
|
121
|
+
@others.each{|other| Thread.start{other.break_running}}
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
class CPreSegJoinFilter<CIOFilter
|
|
125
|
+
Controller.def_export self
|
|
126
|
+
|
|
127
|
+
def initialize(controller, opts)
|
|
128
|
+
super
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def node_class_name
|
|
132
|
+
"PIdentity"
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def njob_creation_params
|
|
136
|
+
[]
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end
|
|
141
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
require "fairy/master/c-io-filter"
|
|
7
|
+
require "fairy/master/c-inputtable"
|
|
8
|
+
|
|
9
|
+
module Fairy
|
|
10
|
+
class CSegMap<CIOFilter
|
|
11
|
+
Controller.def_export self
|
|
12
|
+
|
|
13
|
+
def initialize(controller, opts, block_source)
|
|
14
|
+
super
|
|
15
|
+
@block_source = block_source
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def node_class_name
|
|
19
|
+
"PSegMap"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def njob_creation_params
|
|
23
|
+
[@block_source]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require "delegate"
|
|
4
|
+
|
|
5
|
+
require "fairy/master/c-filter"
|
|
6
|
+
require "fairy/master/c-io-filter"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
module Fairy
|
|
10
|
+
class CSegShuffle<CIOFilter
|
|
11
|
+
Controller.def_export self
|
|
12
|
+
|
|
13
|
+
# include BInputtable
|
|
14
|
+
|
|
15
|
+
def initialize(controller, opts, block_source)
|
|
16
|
+
super
|
|
17
|
+
# @block = @context.create_proc(@block_source.source)
|
|
18
|
+
|
|
19
|
+
@node2input = {}
|
|
20
|
+
@input2node = {}
|
|
21
|
+
@input_queue = PortQueue.new
|
|
22
|
+
@output_queue = PortQueue.new
|
|
23
|
+
|
|
24
|
+
@block_source = block_source
|
|
25
|
+
@begin_block_source = nil
|
|
26
|
+
if @opts[:BEGIN]
|
|
27
|
+
@begin_block_source = @opts[:BEGIN]
|
|
28
|
+
end
|
|
29
|
+
@end_block_source = nil
|
|
30
|
+
if @opts[:END]
|
|
31
|
+
@end_block_source = @opts[:END]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def node_class_name
|
|
37
|
+
"PIdentity"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def njob_creation_params
|
|
41
|
+
[]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def each_assigned_filter(&block)
|
|
45
|
+
each_node do |node|
|
|
46
|
+
@input_queue.push node
|
|
47
|
+
end
|
|
48
|
+
@input_queue.push nil
|
|
49
|
+
|
|
50
|
+
if @begin_block_source
|
|
51
|
+
bsource = BScript.new(@begin_block_source, @context, self)
|
|
52
|
+
bsource.evaluate
|
|
53
|
+
end
|
|
54
|
+
@block = BBlock.new(@block_source, @context, self)
|
|
55
|
+
begin
|
|
56
|
+
@block.call(@input_queue, @output_queue)
|
|
57
|
+
@output_queue.push nil
|
|
58
|
+
ensure
|
|
59
|
+
if @end_block_source
|
|
60
|
+
bsource = BSource.new(@end_block_source, @context, self)
|
|
61
|
+
bsource.evaluate
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
no = 0
|
|
66
|
+
@output_queue.each do |node|
|
|
67
|
+
node.no = no
|
|
68
|
+
no += 1
|
|
69
|
+
block.call node
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
class PortQueue<DelegateClass(Queue)
|
|
74
|
+
include Enumerable
|
|
75
|
+
|
|
76
|
+
def initialize
|
|
77
|
+
super(Queue.new)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def each
|
|
81
|
+
while e = pop
|
|
82
|
+
yield e
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
require "fairy/master/c-io-filter"
|
|
7
|
+
require "fairy/master/c-inputtable"
|
|
8
|
+
|
|
9
|
+
module Fairy
|
|
10
|
+
class CSegSplit<CIOFilter
|
|
11
|
+
Controller.def_export self
|
|
12
|
+
|
|
13
|
+
# DeepConnect.def_single_method_spec(self, "REF new(REF, VAL, VAL)")
|
|
14
|
+
|
|
15
|
+
def initialize(controller, opts, n)
|
|
16
|
+
super
|
|
17
|
+
@no_split = n
|
|
18
|
+
|
|
19
|
+
@no_of_exports = 0
|
|
20
|
+
@no_of_exports_mutex = Mutex.new
|
|
21
|
+
|
|
22
|
+
# @exports = []
|
|
23
|
+
# @exports_mutex = Mutex.new
|
|
24
|
+
# @exports_cv = ConditionVariable.new
|
|
25
|
+
|
|
26
|
+
# @export2njob = {}
|
|
27
|
+
|
|
28
|
+
# @exports_queue = Queue.new
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# def start_create_nodes
|
|
32
|
+
# super
|
|
33
|
+
# Thread.start{appear_njob}
|
|
34
|
+
# end
|
|
35
|
+
|
|
36
|
+
# def appear_njob
|
|
37
|
+
# Log::debug(self, "APPEAR_NJOB:S")
|
|
38
|
+
# loop do
|
|
39
|
+
# @nodes_mutex.synchronize do
|
|
40
|
+
# while @nodes_for_next_filters.empty?
|
|
41
|
+
# @nodes_cv.wait(@nodes_mutex)
|
|
42
|
+
# end
|
|
43
|
+
# Log::debug(self, "APPEAR_NJOB:1")
|
|
44
|
+
# njob = @nodes_for_next_filters.shift
|
|
45
|
+
# Log::debug(self, "APPEAR_NJOB:2")
|
|
46
|
+
# unless njob
|
|
47
|
+
# Log::debug(self, "APPEAR_NJOB:E")
|
|
48
|
+
# @exports_queue.push nil
|
|
49
|
+
# return
|
|
50
|
+
# end
|
|
51
|
+
|
|
52
|
+
# Log::debug(self, "APPEAR_NJOB:3")
|
|
53
|
+
# njob.exports.each do |exp|
|
|
54
|
+
# exp.no = @no_of_exports
|
|
55
|
+
# # exp.key = njob.key
|
|
56
|
+
# @no_of_exports += 1
|
|
57
|
+
|
|
58
|
+
# @export2njob[exp] = njob
|
|
59
|
+
# @exports_queue.push exp
|
|
60
|
+
# end
|
|
61
|
+
# Log::debug(self, "APPEAR_NJOB:4")
|
|
62
|
+
# end
|
|
63
|
+
# end
|
|
64
|
+
# end
|
|
65
|
+
|
|
66
|
+
# def next_filter(mapper)
|
|
67
|
+
# @exports_queue.pop
|
|
68
|
+
# end
|
|
69
|
+
|
|
70
|
+
# def start_export(njob)
|
|
71
|
+
# Log::debug(self, "START_EXPORT:SS")
|
|
72
|
+
|
|
73
|
+
# Log::debug(self, "START_EXPORT: #{exp.class} #{@export2njob[exp].class}")
|
|
74
|
+
# njob.start_export
|
|
75
|
+
# Log::debug(self, "START_EXPORT:EE")
|
|
76
|
+
# exp
|
|
77
|
+
# end
|
|
78
|
+
|
|
79
|
+
def each_export_by(njob, mapper, &block)
|
|
80
|
+
njob.exports.each do |exp|
|
|
81
|
+
@no_of_exports_mutex.synchronize do
|
|
82
|
+
exp.no = @no_of_exports
|
|
83
|
+
# exp.key = njob.key
|
|
84
|
+
@no_of_exports += 1
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
block.call exp
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# def each_export(&block)
|
|
92
|
+
# each_node do |node|
|
|
93
|
+
# for exp in node.exports
|
|
94
|
+
# exp.no = @no_of_exports
|
|
95
|
+
# @no_of_exports += 1
|
|
96
|
+
# block.call exp, node
|
|
97
|
+
# exp.output_no_import = 1
|
|
98
|
+
# end
|
|
99
|
+
# end
|
|
100
|
+
# end
|
|
101
|
+
|
|
102
|
+
def node_class_name
|
|
103
|
+
"PSegSplit"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def njob_creation_params
|
|
107
|
+
[@no_split]
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
require "fairy/master/c-io-filter"
|
|
7
|
+
require "fairy/master/c-inputtable"
|
|
8
|
+
|
|
9
|
+
module Fairy
|
|
10
|
+
class CSegZip<CIOFilter
|
|
11
|
+
Controller.def_export self
|
|
12
|
+
|
|
13
|
+
ZIP_BY_SEGMENT = :ZIP_BY_SEGMENT
|
|
14
|
+
|
|
15
|
+
DeepConnect.def_single_method_spec(self, "REF new(REF, VAL, VAL, REF)")
|
|
16
|
+
|
|
17
|
+
def initialize(controller, opts, others, block_source)
|
|
18
|
+
super
|
|
19
|
+
@others = others
|
|
20
|
+
@block_source = block_source
|
|
21
|
+
|
|
22
|
+
#@exports = [{o=>filter, ...}, ...]
|
|
23
|
+
@exports = []
|
|
24
|
+
@others_status = {}
|
|
25
|
+
@exports_mutex = Mutex.new
|
|
26
|
+
@exports_cv = ConditionVariable.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def opt_zip_by_substream?
|
|
30
|
+
@opts[ZIP_BY_SEGMENT]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def node_class_name
|
|
34
|
+
"PSegZip"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def njob_creation_params
|
|
38
|
+
[@block_source]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def start_create_nodes
|
|
42
|
+
Log::debug self, "START_CREATE_NODES: #{self}"
|
|
43
|
+
@others.each do |other|
|
|
44
|
+
Thread.start do
|
|
45
|
+
other.each_assigned_filter do |input_filter|
|
|
46
|
+
@exports_mutex.synchronize do
|
|
47
|
+
unless exps = @exports[input_filter.no]
|
|
48
|
+
exps = @exports[input_filter.no] = {}
|
|
49
|
+
@exports_cv.broadcast
|
|
50
|
+
end
|
|
51
|
+
exp = input_filter.start_export
|
|
52
|
+
exps[other] = exp
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
@exports_mutex.synchronize do
|
|
56
|
+
@others_status[other] = true
|
|
57
|
+
@exports_cv.broadcast
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
super
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
class NoAllFilter<Exception;end
|
|
65
|
+
|
|
66
|
+
def create_and_add_node(ntask, mapper, opts={})
|
|
67
|
+
unless opt_zip_by_substream?
|
|
68
|
+
ERR::Raise ERR::NoImplement, "except zip_by_segment"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
node = create_node(ntask) {|node|
|
|
72
|
+
if opts[:init_njob]
|
|
73
|
+
opts[:init_njob].call(node)
|
|
74
|
+
end
|
|
75
|
+
mapper.bind_input(node)
|
|
76
|
+
|
|
77
|
+
no = node.no
|
|
78
|
+
exps = nil
|
|
79
|
+
@exports_mutex.synchronize do
|
|
80
|
+
while !(exps = other_filter_of(no))
|
|
81
|
+
@exports_cv.wait(@exports_mutex)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
node.zip_inputs = exps
|
|
85
|
+
exps.zip(node.zip_imports) do |other, import|
|
|
86
|
+
other.output = import
|
|
87
|
+
import.no_import = 1
|
|
88
|
+
end
|
|
89
|
+
}
|
|
90
|
+
node
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def other_filter_of(no)
|
|
94
|
+
begin
|
|
95
|
+
@others.collect do |o|
|
|
96
|
+
unless exp = @exports[no][o]
|
|
97
|
+
unless @other_status[o]
|
|
98
|
+
raise NoAllFilter
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
exp
|
|
102
|
+
end
|
|
103
|
+
rescue NoAllFilter
|
|
104
|
+
return nil
|
|
105
|
+
rescue
|
|
106
|
+
return nil
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def break_running
|
|
111
|
+
super
|
|
112
|
+
@others.each{|others| Thread.start{others.break_running}}
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class CPreSegZipFilter<CIOFilter
|
|
117
|
+
Controller.def_export self
|
|
118
|
+
|
|
119
|
+
def initialize(controller, opts)
|
|
120
|
+
super
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def node_class_name
|
|
124
|
+
"PIdentity"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def njob_creation_params
|
|
128
|
+
[]
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|