fairy 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,21 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/node/p-io-filter"
|
7
|
+
require "fairy/node/p-single-exportable"
|
8
|
+
|
9
|
+
module Fairy
|
10
|
+
class PHere<PIOFilter
|
11
|
+
Processor.def_export self
|
12
|
+
|
13
|
+
include PSingleExportable
|
14
|
+
|
15
|
+
def basic_each(&block)
|
16
|
+
@input.each do |e|
|
17
|
+
block.call e
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/node/p-io-filter"
|
7
|
+
require "fairy/node/p-single-exportable"
|
8
|
+
|
9
|
+
module Fairy
|
10
|
+
class PIdentity<PSingleExportFilter
|
11
|
+
Processor.def_export self
|
12
|
+
|
13
|
+
def initialize(id, ntask, bjob, opts=nil)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def basic_each(&block)
|
18
|
+
@input.each do |e|
|
19
|
+
block.call e
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/node/p-filter"
|
7
|
+
require "fairy/node/p-single-exportable"
|
8
|
+
|
9
|
+
module Fairy
|
10
|
+
|
11
|
+
class PInject<PIOFilter
|
12
|
+
def initialize(id, processor, bjob, opts, block_source)
|
13
|
+
super
|
14
|
+
|
15
|
+
@init_value = :__FAIRY_NO_VALUE__
|
16
|
+
if @opts.key?(:init_value)
|
17
|
+
@init_value = @opts[:init_value].dc_deep_copy
|
18
|
+
end
|
19
|
+
@block_source = block_source
|
20
|
+
# @inject_proc = @context.create_proc(@block_source)
|
21
|
+
end
|
22
|
+
|
23
|
+
def basic_each(&block)
|
24
|
+
@inject_proc = BBlock.new(@block_source, @context, self)
|
25
|
+
sum = @init_value
|
26
|
+
@input.each do |e|
|
27
|
+
if sum == :__FAIRY_NO_VALUE__
|
28
|
+
sum = e
|
29
|
+
else
|
30
|
+
# Log::debug(self, "sum, e, #{sum}, #{e}")
|
31
|
+
if Import::CTLTOKEN_NULLVALUE === (v = @inject_proc.yield(sum, e))
|
32
|
+
next
|
33
|
+
end
|
34
|
+
sum = v
|
35
|
+
end
|
36
|
+
end
|
37
|
+
finish(sum, &block)
|
38
|
+
end
|
39
|
+
|
40
|
+
# def start
|
41
|
+
# super do
|
42
|
+
# @inject_proc = BBlock.new(@block_source, @context, self)
|
43
|
+
# sum = @init_value
|
44
|
+
# @import.each do |e|
|
45
|
+
# if sum == :__FAIRY_NO_VALUE__
|
46
|
+
# sum = e
|
47
|
+
# else
|
48
|
+
# sum = @inject_proc.yield(sum, e)
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
# finish(sum)
|
52
|
+
# end
|
53
|
+
end
|
54
|
+
|
55
|
+
class PLocalInject<PInject
|
56
|
+
include PSingleExportable
|
57
|
+
|
58
|
+
Processor.def_export self
|
59
|
+
|
60
|
+
def finish(sum, &block)
|
61
|
+
# block.call sum
|
62
|
+
block.call [no, sum]
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
class PWideInject<PInject
|
68
|
+
Processor.def_export self
|
69
|
+
|
70
|
+
def initialize(*args)
|
71
|
+
super
|
72
|
+
|
73
|
+
@value = :__FAIRY_NO_VALUE__
|
74
|
+
@value_mutex = Mutex.new
|
75
|
+
@value_cv = ConditionVariable.new
|
76
|
+
end
|
77
|
+
|
78
|
+
def input=(input)
|
79
|
+
super
|
80
|
+
|
81
|
+
start do
|
82
|
+
self.super_each{}
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
alias super_each each
|
87
|
+
|
88
|
+
def basic_each(&block)
|
89
|
+
@inject_proc = BBlock.new(@block_source, @context, self)
|
90
|
+
sum = @init_value
|
91
|
+
@input.sort_by{|n, e| n}.each do |n, e|
|
92
|
+
#Log::debug(self, "n e: #{n}, #{e}")
|
93
|
+
if sum == :__FAIRY_NO_VALUE__
|
94
|
+
sum = e
|
95
|
+
else
|
96
|
+
if Import::CTLTOKEN_NULLVALUE === (v = @inject_proc.yield(sum, e))
|
97
|
+
next
|
98
|
+
end
|
99
|
+
sum = v
|
100
|
+
end
|
101
|
+
end
|
102
|
+
finish(sum, &block)
|
103
|
+
end
|
104
|
+
|
105
|
+
def each(&block)
|
106
|
+
block.call value
|
107
|
+
end
|
108
|
+
|
109
|
+
def value
|
110
|
+
@value_mutex.synchronize do
|
111
|
+
while @value == :__FAIRY_NO_VALUE__
|
112
|
+
@value_cv.wait(@value_mutex)
|
113
|
+
end
|
114
|
+
@value
|
115
|
+
end
|
116
|
+
end
|
117
|
+
DeepConnect.def_method_spec(self, "DVAL value")
|
118
|
+
|
119
|
+
def finish(sum, &block)
|
120
|
+
@value = sum
|
121
|
+
@value_cv.broadcast
|
122
|
+
if block
|
123
|
+
block.call sum
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/node/p-filter"
|
7
|
+
require "fairy/node/p-single-exportable"
|
8
|
+
|
9
|
+
require "fairy/share/file-place"
|
10
|
+
|
11
|
+
module Fairy
|
12
|
+
class PInputFile<PSingleExportInput
|
13
|
+
Processor.def_export self
|
14
|
+
|
15
|
+
def PInputFile.open(processor, bjob, opts, fn)
|
16
|
+
nfile = PInputFile.new(processor, bjob, opts)
|
17
|
+
nfile.open(fn)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(id, ntask, bjob, opts=nil)
|
21
|
+
super
|
22
|
+
@file = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def open(nfileplace)
|
26
|
+
@file_name = nfileplace.path
|
27
|
+
self.no = nfileplace.no
|
28
|
+
begin
|
29
|
+
@file = File.open(@file_name)
|
30
|
+
rescue
|
31
|
+
e = $!.exception($!.message+ "(vfile entry##{nfileplace.no}: #{nfileplace.url})")
|
32
|
+
e.set_backtrace($!.backtrace)
|
33
|
+
|
34
|
+
Log::error_exception(e)
|
35
|
+
handle_exception(e)
|
36
|
+
raise e
|
37
|
+
end
|
38
|
+
# start
|
39
|
+
self
|
40
|
+
end
|
41
|
+
DeepConnect::def_method_spec(self, "REF open(VAL)")
|
42
|
+
|
43
|
+
# def start
|
44
|
+
# buf = ""
|
45
|
+
# buf_size = 1024*20
|
46
|
+
# rest = nil
|
47
|
+
# super do
|
48
|
+
# while @file.read(buf_size, buf)
|
49
|
+
# lines = buf.split
|
50
|
+
# if rest
|
51
|
+
# begin
|
52
|
+
# lines[0] = rest+lines[0]
|
53
|
+
# rescue
|
54
|
+
# Log::debug(self, "AAAAAAAAAAAAAAAA")
|
55
|
+
# Log::debug(self, buf.inspect)
|
56
|
+
# Log::debug(self, lines.inspect)
|
57
|
+
# raise
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
# rest = lines.pop
|
61
|
+
# if @export.respond_to?(:push_buf)
|
62
|
+
# @export.push_buf lines
|
63
|
+
# else
|
64
|
+
# for l in lines
|
65
|
+
# @export.push l
|
66
|
+
# end
|
67
|
+
# end
|
68
|
+
# end
|
69
|
+
# if rest
|
70
|
+
# @export.push rest
|
71
|
+
# end
|
72
|
+
# @file.close
|
73
|
+
# @file = nil # FileオブジェクトをGCの対象にするため
|
74
|
+
# end
|
75
|
+
# end
|
76
|
+
|
77
|
+
# def start
|
78
|
+
# super do
|
79
|
+
# for l in @file
|
80
|
+
# @export.push l
|
81
|
+
# end
|
82
|
+
# @file.close
|
83
|
+
# @file = nil # FileオブジェクトをGCの対象にするため
|
84
|
+
# end
|
85
|
+
# end
|
86
|
+
|
87
|
+
def basic_each(&block)
|
88
|
+
begin
|
89
|
+
@file.each &block
|
90
|
+
ensure
|
91
|
+
@file.close
|
92
|
+
@file = nil # FileオブジェクトをGCの対象にするため
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def basic_next
|
97
|
+
begin
|
98
|
+
ret = @file.gets
|
99
|
+
ensure
|
100
|
+
unless ret
|
101
|
+
@file.close
|
102
|
+
@file = nil
|
103
|
+
return :END_OF_STREAM
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/node/p-single-exportable"
|
7
|
+
|
8
|
+
module Fairy
|
9
|
+
class PInputIota<PSingleExportInput
|
10
|
+
Processor.def_export self
|
11
|
+
|
12
|
+
def initialize(id, ntask, bjob, opts)
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def open(niota_place)
|
17
|
+
self.no = niota_place.no
|
18
|
+
|
19
|
+
@first = niota_place.first
|
20
|
+
@last = niota_place.last
|
21
|
+
end
|
22
|
+
|
23
|
+
def basic_each(&block)
|
24
|
+
for i in @first..@last
|
25
|
+
block.call i
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# def start
|
30
|
+
# super do
|
31
|
+
# for i in @first..@last
|
32
|
+
# @export.push i
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/node/p-filter"
|
7
|
+
require "fairy/node/p-single-exportable"
|
8
|
+
|
9
|
+
module Fairy
|
10
|
+
class PInputLocalFile<PSingleExportInput
|
11
|
+
Processor.def_export self
|
12
|
+
|
13
|
+
def self.open(id, ntask, bjob, io, opts=nil)
|
14
|
+
nlfileinput = self.new(id, processor, bjob, opts)
|
15
|
+
nlfileinput.open(job)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(id, ntask, bjob, opts=nil)
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def open(nioplace)
|
23
|
+
@io = nioplace.io
|
24
|
+
self.no = nioplace.no
|
25
|
+
@io_external_encoding = @io.external_encoding.dc_deep_copy
|
26
|
+
|
27
|
+
@buffer_size = @opts[:buffer_size]
|
28
|
+
@buffer_size = CONF.INPUT_LOCAL_FILE_BUFFER_SIZE unless @buffer_size
|
29
|
+
end
|
30
|
+
|
31
|
+
def basic_each(&block)
|
32
|
+
rest = nil
|
33
|
+
while (buf = @io.read(@buffer_size))
|
34
|
+
lines = buf.scan(/.*\n?/)
|
35
|
+
lines.pop # scan で末尾にゴミが出るため
|
36
|
+
if rest
|
37
|
+
begin
|
38
|
+
lines[0] = rest+lines[0]
|
39
|
+
rescue
|
40
|
+
Log::debug(self, @io.inspect)
|
41
|
+
Log::debug(self, buf.inspect)
|
42
|
+
Log::debug(self, lines.inspect)
|
43
|
+
Log::debug(self, rest.inspect)
|
44
|
+
raise
|
45
|
+
end
|
46
|
+
end
|
47
|
+
rest = lines.pop
|
48
|
+
lines.each{|l|
|
49
|
+
l.force_encoding(@io_external_encoding)
|
50
|
+
block.call(l)}
|
51
|
+
end
|
52
|
+
if rest
|
53
|
+
rest.force_encoding(@io_external_encoding)
|
54
|
+
block.call rest
|
55
|
+
end
|
56
|
+
@io.close
|
57
|
+
@io = nil # FileオブジェクトをGCの対象にするため
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/node/p-single-exportable"
|
7
|
+
|
8
|
+
module Fairy
|
9
|
+
class PInputVArray<PSingleExportInput
|
10
|
+
Processor.def_export self
|
11
|
+
|
12
|
+
# def initialize(processor, bjob, opts)
|
13
|
+
# super
|
14
|
+
# end
|
15
|
+
|
16
|
+
def open(nvarrayplace)
|
17
|
+
@array = nvarrayplace.ary
|
18
|
+
self.no = nvarrayplace.no
|
19
|
+
end
|
20
|
+
|
21
|
+
def basic_each(&block)
|
22
|
+
@array.each &block
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/node/p-filter"
|
7
|
+
|
8
|
+
module Fairy
|
9
|
+
class PIOFilter<PFilter
|
10
|
+
Processor.def_export self
|
11
|
+
|
12
|
+
ST_WAIT_IMPORT = :ST_WAIT_IMPORT
|
13
|
+
|
14
|
+
def initialize(id, ntask, bjob, opts=nil, *rests)
|
15
|
+
super
|
16
|
+
self.status = ST_WAIT_IMPORT
|
17
|
+
end
|
18
|
+
|
19
|
+
def input=(input)
|
20
|
+
@input = input
|
21
|
+
if input.kind_of?(Import)
|
22
|
+
input.njob_id = @id
|
23
|
+
end
|
24
|
+
self.no = input.no
|
25
|
+
self.key = input.key
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007-2010 Rakuten, Inc.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "fairy/node/p-io-filter"
|
7
|
+
require "fairy/node/p-single-exportable"
|
8
|
+
|
9
|
+
module Fairy
|
10
|
+
class PMap<PSingleExportFilter
|
11
|
+
Processor.def_export self
|
12
|
+
|
13
|
+
DeepConnect.def_single_method_spec(self, "REF new(DEFAULT, REF, REF, VAL, REF)")
|
14
|
+
def initialize(id, ntask, bjob, opts, block_source)
|
15
|
+
super
|
16
|
+
@block_source = block_source
|
17
|
+
# @map_proc = eval("proc{#{@block_source}}", TOPLEVEL_BINDING)
|
18
|
+
# @map_proc = @context.create_proc(@block_source)
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
# def start
|
24
|
+
# super do
|
25
|
+
# @map_proc = BBlock.new(@block_source, @context, self)
|
26
|
+
# @import.each do |e|
|
27
|
+
# @export.push @map_proc.yield(e)
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
|
32
|
+
def basic_each(&block)
|
33
|
+
@map_proc = BBlock.new(@block_source, @context, self)
|
34
|
+
|
35
|
+
@input.each do |e|
|
36
|
+
block.call @map_proc.yield(e)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|