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


Python FilterJob.make_runner方法代码示例

本文整理汇总了Python中tests.mr_filter_job.FilterJob.make_runner方法的典型用法代码示例。如果您正苦于以下问题:Python FilterJob.make_runner方法的具体用法?Python FilterJob.make_runner怎么用?Python FilterJob.make_runner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.mr_filter_job.FilterJob的用法示例。


在下文中一共展示了FilterJob.make_runner方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_mapper_pre_filter

# 需要导入模块: from tests.mr_filter_job import FilterJob [as 别名]
# 或者: from tests.mr_filter_job.FilterJob import make_runner [as 别名]
    def test_mapper_pre_filter(self):
        data = b"x\ny\nz\n"
        job = FilterJob(["--mapper-filter", "cat -e", "--runner=local"])
        job.sandbox(stdin=BytesIO(data))
        with job.make_runner() as r:
            self.assertEqual(
                r._get_steps(), [{"type": "streaming", "mapper": {"type": "script", "pre_filter": "cat -e"}}]
            )

            r.run()

            lines = [line.strip() for line in list(r.stream_output())]
            self.assertEqual(sorted(lines), [b"x$", b"y$", b"z$"])
开发者ID:alanhdu,项目名称:mrjob,代码行数:15,代码来源:test_local.py

示例2: test_mapper_pre_filter

# 需要导入模块: from tests.mr_filter_job import FilterJob [as 别名]
# 或者: from tests.mr_filter_job.FilterJob import make_runner [as 别名]
    def test_mapper_pre_filter(self):
        data = 'x\ny\nz\n'
        job = FilterJob(['--mapper-filter', 'cat -e', '--runner=local'])
        job.sandbox(stdin=StringIO(data))
        with job.make_runner() as r:
            self.assertEqual(
                r._get_steps(),
                [{
                    'type': 'streaming',
                    'mapper': {
                        'type': 'script',
                        'pre_filter': 'cat -e'}}])

            r.run()

            lines = [line.strip() for line in list(r.stream_output())]
            self.assertItemsEqual(lines, ['x$', 'y$', 'z$'])
开发者ID:SeanOC,项目名称:mrjob,代码行数:19,代码来源:test_local.py

示例3: test_mapper_pre_filter

# 需要导入模块: from tests.mr_filter_job import FilterJob [as 别名]
# 或者: from tests.mr_filter_job.FilterJob import make_runner [as 别名]
    def test_mapper_pre_filter(self):
        data = 'x\ny\nz\n'
        job = FilterJob(['--mapper-filter', 'cat -e', '--runner=local'])
        job.sandbox(stdin=StringIO(data))
        with job.make_runner() as r:
            self.assertEqual(
                r._get_steps(),
                [{
                    'type': 'streaming',
                    'mapper': {
                        'type': 'script',
                        'pre_filter': 'cat -e'}}])

            r.run()

            self.assertEqual(
                ''.join(r.stream_output()),
                'x$\ny$\nz$\n')
开发者ID:eklitzke,项目名称:mrjob,代码行数:20,代码来源:test_local.py

示例4: test_reducer_pre_filter

# 需要导入模块: from tests.mr_filter_job import FilterJob [as 别名]
# 或者: from tests.mr_filter_job.FilterJob import make_runner [as 别名]
    def test_reducer_pre_filter(self):
        data = b'x\ny\nz\n'
        job = FilterJob(['--reducer-filter', 'cat -e', '--runner=local'])
        job.sandbox(stdin=BytesIO(data))
        with job.make_runner() as r:
            self.assertEqual(
                r._get_steps(),
                [{
                    'type': 'streaming',
                    'mapper': {
                        'type': 'script',
                    },
                    'reducer': {
                        'type': 'script',
                        'pre_filter': 'cat -e'}}])

            r.run()

            lines = [line.strip() for line in list(r.stream_output())]
            self.assertEqual(sorted(lines), [b'x$', b'y$', b'z$'])
开发者ID:northaviva,项目名称:mrjob,代码行数:22,代码来源:test_local.py


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