本文整理汇总了Python中mrjob.job.MRJob.mr方法的典型用法代码示例。如果您正苦于以下问题:Python MRJob.mr方法的具体用法?Python MRJob.mr怎么用?Python MRJob.mr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mrjob.job.MRJob
的用法示例。
在下文中一共展示了MRJob.mr方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_deprecated_mapper_final_positional_arg
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import mr [as 别名]
def test_deprecated_mapper_final_positional_arg(self):
def mapper(k, v):
pass
def reducer(k, v):
pass
def mapper_final():
pass
stderr = StringIO()
with no_handlers_for_logger():
log_to_stream('mrjob.job', stderr)
step = MRJob.mr(mapper, reducer, mapper_final)
# should be allowed to specify mapper_final as a positional arg,
# but we log a warning
self.assertEqual(
step,
MRJob.mr(
mapper=mapper, reducer=reducer, mapper_final=mapper_final))
self.assertIn('mapper_final should be specified', stderr.getvalue())
# can't specify mapper_final as a positional and keyword arg
self.assertRaises(
TypeError,
MRJob.mr,
mapper,
reducer,
mapper_final,
mapper_final=mapper_final)
示例2: test_mr
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import mr [as 别名]
def test_mr(self):
def mapper(k, v):
pass
def mapper_init():
pass
def mapper_final():
pass
def reducer(k, vs):
pass
def reducer_init():
pass
def reducer_final():
pass
# make sure it returns the format we currently expect
self.assertEqual(MRJob.mr(mapper, reducer),
stepdict(mapper, reducer))
self.assertEqual(MRJob.mr(mapper, reducer,
mapper_init=mapper_init,
mapper_final=mapper_final,
reducer_init=reducer_init,
reducer_final=reducer_final),
stepdict(mapper, reducer,
mapper_init=mapper_init,
mapper_final=mapper_final,
reducer_init=reducer_init,
reducer_final=reducer_final))
self.assertEqual(MRJob.mr(mapper),
stepdict(mapper))
示例3: test_no_mapper
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import mr [as 别名]
def test_no_mapper(self):
def mapper_final(k, v): pass
def reducer(k, vs): pass
assert_equal(MRJob.mr(), (_IDENTITY_MAPPER, None))
assert_equal(MRJob.mr(reducer=reducer), (_IDENTITY_MAPPER, reducer))
assert_equal(MRJob.mr(reducer=reducer, mapper_final=mapper_final),
((_IDENTITY_MAPPER, mapper_final), reducer))
示例4: test_mr
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import mr [as 别名]
def test_mr(self):
def mapper(k, v): pass
def mapper_final(k, v): pass
def reducer(k, vs): pass
# make sure it returns the format we currently expect
assert_equal(MRJob.mr(mapper, reducer), (mapper, reducer))
assert_equal(MRJob.mr(mapper, reducer, mapper_final=mapper_final),
((mapper, mapper_final), reducer))
assert_equal(MRJob.mr(mapper), (mapper, None))
示例5: test_no_reducer
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import mr [as 别名]
def test_no_reducer(self):
def reducer_init():
pass
def reducer_final():
pass
self.assertEqual(MRJob.mr(reducer_init=reducer_init),
stepdict(reducer_init=reducer_init))
self.assertEqual(MRJob.mr(reducer_final=reducer_final),
stepdict(reducer_final=reducer_final))
示例6: test_mapper_and_reducer_as_positional_args
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import mr [as 别名]
def test_mapper_and_reducer_as_positional_args(self):
def mapper(k, v):
pass
def reducer(k, v):
pass
def combiner(k, v):
pass
self.assertEqual(MRJob.mr(mapper), MRJob.mr(mapper=mapper))
self.assertEqual(
MRJob.mr(mapper, reducer), MRJob.mr(
mapper=mapper, reducer=reducer))
self.assertEqual(
MRJob.mr(mapper, reducer=reducer),
MRJob.mr(mapper=mapper, reducer=reducer))
self.assertEqual(
MRJob.mr(mapper, reducer, combiner=combiner),
MRJob.mr(mapper=mapper, reducer=reducer, combiner=combiner))
# can't specify something as a positional and keyword arg
self.assertRaises(TypeError, MRJob.mr, mapper, mapper=mapper)
self.assertRaises(
TypeError, MRJob.mr, mapper, reducer, reducer=reducer)
示例7: test_mr
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import mr [as 别名]
def test_mr(self):
kwargs = {
'mapper': _IDENTITY_MAPPER,
'reducer': _IDENTITY_REDUCER,
}
with logger_disabled('mrjob.job'):
self.assertEqual(MRJob.mr(**kwargs), MRStep(**kwargs))
示例8: test_no_mapper
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import mr [as 别名]
def test_no_mapper(self):
def mapper_init():
pass
def mapper_final():
pass
def reducer(k, vs):
pass
self.assertRaises(Exception, MRJob.mr)
self.assertEqual(MRJob.mr(reducer=reducer), stepdict(reducer=reducer))
self.assertEqual(
MRJob.mr(reducer=reducer, mapper_final=mapper_final),
stepdict(reducer=reducer, mapper_final=mapper_final))
self.assertEqual(
MRJob.mr(reducer=reducer, mapper_init=mapper_init),
stepdict(reducer=reducer, mapper_init=mapper_init))
示例9: steps
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import mr [as 别名]
def steps(self):
return map(lambda _: MRJob.mr(self.mapper, self.reducer,
self.mapper_final),
xrange(0, self.options.iterations))
示例10: test_mr_positional_arguments
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import mr [as 别名]
def test_mr_positional_arguments(self):
with logger_disabled('mrjob.job'):
self.assertEqual(
MRJob.mr(_IDENTITY_MAPPER, _IDENTITY_REDUCER),
MRStep(mapper=_IDENTITY_MAPPER, reducer=_IDENTITY_REDUCER))
示例11: test_mr
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import mr [as 别名]
def test_mr(self):
kwargs = {"mapper": _IDENTITY_MAPPER, "reducer": _IDENTITY_REDUCER}
with logger_disabled("mrjob.job"):
self.assertEqual(MRJob.mr(**kwargs), MRStep(**kwargs))