我最近发现了Disco Project,与Hadoop相比,我非常喜欢它,但我遇到了一个问题。我的项目是这样设置的(如果有帮助的话,我很乐意剪切/粘贴真实的代码):
myfile.py
from disco.core import Job, result_iterator
import collections, sys
from disco.worker.classic.func import chain_reader
from disco.worker.classic.worker import Params
def helper1():
#do stuff
def helper2():
#do stuff
.
.
.
def helperN():
#do stuff
class A(Job):
@staticmethod
def map_reader(fd, params):
#Read input file
yield line
def map(self, line, params):
#Process lines into dictionary
#Iterate dictionary
yield k, v
def reduce(self, iter, out, params):
#iterate iter
#Process k, v into dictionary, aggregating values
#Process dictionry
#Iterate dictionary
out.add(k,v)
Class B(Job):
map_reader = staticmethod(chain_reader)
map = staticmethod(nop_map)
reduce(self, iter, out, params):
#Process iter
#iterate results
out.add(k,v)
if __name__ == '__main__':
from myfile import A, B
job1 = A().run(input=[input_filename], params=Params(k=k))
job2 = B().run(input=[job1.wait()], params=Params(k=k))
with open(output_filename, 'w') as fp:
for count, line in result_iterator(job2.wait(show=True)):
fp.write(str(count) + ',' + line + 'n')
我的问题是,作业流完全跳过了A的reduce,然后下降到了B的reduce。
你知道这里发生了什么吗?
这是一个简单但微妙的问题:我没有
show = True
对于job1。出于某种原因,在为job2设置show的情况下,它向我显示了job1中的map()和map-shuffle()步骤,所以由于我没有得到预期的最终结果,并且对其中一个job2函数的输入看起来是错误的,我得出了job1步骤没有正确运行的结论(在添加job2之前,我验证了job1输出的准确性,这一点得到了进一步的支持)。