本文整理汇总了Python中tests.mr_filter_job.FilterJob.sandbox方法的典型用法代码示例。如果您正苦于以下问题:Python FilterJob.sandbox方法的具体用法?Python FilterJob.sandbox怎么用?Python FilterJob.sandbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.mr_filter_job.FilterJob
的用法示例。
在下文中一共展示了FilterJob.sandbox方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mapper_pre_filter
# 需要导入模块: from tests.mr_filter_job import FilterJob [as 别名]
# 或者: from tests.mr_filter_job.FilterJob import sandbox [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$"])
示例2: test_mapper_pre_filter
# 需要导入模块: from tests.mr_filter_job import FilterJob [as 别名]
# 或者: from tests.mr_filter_job.FilterJob import sandbox [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$'])
示例3: test_mapper_pre_filter
# 需要导入模块: from tests.mr_filter_job import FilterJob [as 别名]
# 或者: from tests.mr_filter_job.FilterJob import sandbox [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')
示例4: test_reducer_pre_filter
# 需要导入模块: from tests.mr_filter_job import FilterJob [as 别名]
# 或者: from tests.mr_filter_job.FilterJob import sandbox [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$'])