本文整理汇总了Python中mrjob.job.MRJob.parse_output方法的典型用法代码示例。如果您正苦于以下问题:Python MRJob.parse_output方法的具体用法?Python MRJob.parse_output怎么用?Python MRJob.parse_output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mrjob.job.MRJob
的用法示例。
在下文中一共展示了MRJob.parse_output方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_default_protocol
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_output [as 别名]
def test_default_protocol(self):
job = MRJob()
data = iter([b'1\t2', b'\n{"3": ', b'4}\t"fi', b've"\n'])
self.assertEqual(
list(job.parse_output(data)),
[(1, 2), ({'3': 4}, 'five')])
示例2: test_default
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_output [as 别名]
def test_default(self):
# test parsing JSON
mr_job = MRJob()
output = '0\t1\n"a"\t"b"\n'
mr_job.stdout = StringIO(output)
self.assertEqual(mr_job.parse_output(), [(0, 1), ('a', 'b')])
# verify that stdout is not cleared
self.assertEqual(mr_job.stdout.getvalue(), output)
示例3: test_protocol_instance
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_output [as 别名]
def test_protocol_instance(self):
# see if we can use the repr protocol
mr_job = MRJob()
output = "0\t1\n['a', 'b']\tset(['c', 'd'])\n"
mr_job.stdout = StringIO(output)
self.assertEqual(mr_job.parse_output(ReprProtocol()), [(0, 1), (["a", "b"], set(["c", "d"]))])
# verify that stdout is not cleared
self.assertEqual(mr_job.stdout.getvalue(), output)
示例4: test_parse_output
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_output [as 别名]
def test_parse_output(self):
# test parsing JSON
mr_job = MRJob()
output = b'0\t1\n"a"\t"b"\n'
mr_job.stdout = BytesIO(output)
with logger_disabled('mrjob.job'):
self.assertEqual(mr_job.parse_output(), [(0, 1), ('a', 'b')])
# verify that stdout is not cleared
self.assertEqual(mr_job.stdout.getvalue(), output)
示例5: test_deprecated_protocol_aliases
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_output [as 别名]
def test_deprecated_protocol_aliases(self):
# see if we can use the repr protocol
mr_job = MRJob()
output = "0\t1\n['a', 'b']\tset(['c', 'd'])\n"
mr_job.stdout = StringIO(output)
assert_equal(mr_job.parse_output('repr'),
[(0, 1), (['a', 'b'], set(['c', 'd']))])
# verify that stdout is not cleared
assert_equal(mr_job.stdout.getvalue(), output)
示例6: test_parse_output_with_protocol_instance
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_output [as 别名]
def test_parse_output_with_protocol_instance(self):
# see if we can use the repr protocol
mr_job = MRJob()
output = b"0\t1\n['a', 'b']\tset(['c', 'd'])\n"
mr_job.stdout = BytesIO(output)
with logger_disabled('mrjob.job'):
self.assertEqual(mr_job.parse_output(ReprProtocol()),
[(0, 1), (['a', 'b'], set(['c', 'd']))])
# verify that stdout is not cleared
self.assertEqual(mr_job.stdout.getvalue(), output)
示例7: test_bytes_value_protocol
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_output [as 别名]
def test_bytes_value_protocol(self):
job = MRJob()
job.OUTPUT_PROTOCOL = BytesValueProtocol
data = iter([b'one\nt', b'wo\nthree\n', b'four\nfive\n'])
self.assertEqual(
list(job.parse_output(data)),
[(None, b'one\n'),
(None, b'two\n'),
(None, b'three\n'),
(None, b'four\n'),
(None, b'five\n')])