当前位置: 首页>>代码示例>>Python>>正文


Python MRJob.mr方法代码示例

本文整理汇总了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)
开发者ID:bchess,项目名称:mrjob,代码行数:33,代码来源:test_job.py

示例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))
开发者ID:DrMavenRebe,项目名称:mrjob,代码行数:37,代码来源:test_job.py

示例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))
开发者ID:Jyrsa,项目名称:mrjob,代码行数:10,代码来源:job_test.py

示例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))
开发者ID:Jyrsa,项目名称:mrjob,代码行数:13,代码来源:job_test.py

示例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))
开发者ID:DrMavenRebe,项目名称:mrjob,代码行数:14,代码来源:test_job.py

示例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)
开发者ID:bchess,项目名称:mrjob,代码行数:30,代码来源:test_job.py

示例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))
开发者ID:tempcyc,项目名称:mrjob,代码行数:10,代码来源:test_job.py

示例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))
开发者ID:bchess,项目名称:mrjob,代码行数:20,代码来源:test_job.py

示例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))
开发者ID:charleswli,项目名称:wormsimulator,代码行数:6,代码来源:SchimmyPropagate.py

示例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))
开发者ID:tempcyc,项目名称:mrjob,代码行数:7,代码来源:test_job.py

示例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))
开发者ID:davidmarin,项目名称:mrjob,代码行数:7,代码来源:test_job.py


注:本文中的mrjob.job.MRJob.mr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。