我最近发现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的减少,然后降到B的减少。
这里有什么想法?
答案 0 :(得分:0)
这是一个简单而微妙的问题:我没有
show = True
for job1。出于某种原因,对于job2的show set,它向我展示了来自job1的map()和map-shuffle()步骤,所以因为我没有得到我期望的最终结果并输入其中一个job2函数看起来错误,我得出的结论是job1步骤没有正常运行(在我添加job2之前,我进一步支持这一点,我验证了job1输出的准确性)。