本文整理汇总了Python中mrjob.job.MRJob.increment_counter方法的典型用法代码示例。如果您正苦于以下问题:Python MRJob.increment_counter方法的具体用法?Python MRJob.increment_counter怎么用?Python MRJob.increment_counter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mrjob.job.MRJob
的用法示例。
在下文中一共展示了MRJob.increment_counter方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_commas_in_counters
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_commas_in_counters(self):
# commas should be replaced with semicolons
mr_job = MRJob().sandbox()
mr_job.increment_counter("Bad items", "a, b, c")
mr_job.increment_counter("girl, interrupted", "movie")
self.assertEqual(mr_job.parse_counters(), {"Bad items": {"a; b; c": 1}, "girl; interrupted": {"movie": 1}})
示例2: test_parse_counters
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_parse_counters(self):
mr_job = MRJob().sandbox()
mr_job.increment_counter('Foo', 'Bar')
mr_job.increment_counter('Foo', 'Bar')
mr_job.increment_counter('Foo', 'Baz', 20)
self.assertEqual(mr_job.parse_counters(),
{'Foo': {'Bar': 2, 'Baz': 20}})
示例3: test_commas_in_counters
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_commas_in_counters(self):
# commas should be replaced with semicolons
mr_job = MRJob().sandbox()
mr_job.increment_counter("Bad items", "a, b, c")
mr_job.increment_counter("girl, interrupted", "movie")
parsed_stderr = parse_mr_job_stderr(mr_job.stderr.getvalue())
self.assertEqual(parsed_stderr["counters"], {"Bad items": {"a; b; c": 1}, "girl; interrupted": {"movie": 1}})
示例4: test_commas_in_counters
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_commas_in_counters(self):
# commas should be replaced with semicolons
mr_job = MRJob().sandbox()
mr_job.increment_counter('Bad items', 'a, b, c')
mr_job.increment_counter('girl, interrupted', 'movie')
assert_equal(mr_job.parse_counters(),
{'Bad items': {'a; b; c': 1},
'girl; interrupted': {'movie': 1}})
示例5: test_parse_counters
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_parse_counters(self):
mr_job = MRJob().sandbox()
mr_job.increment_counter('Foo', 'Bar')
mr_job.increment_counter('Foo', 'Bar')
mr_job.increment_counter('Foo', 'Baz', 20)
with logger_disabled('mrjob.job'):
self.assertEqual(mr_job.parse_counters(),
{'Foo': {'Bar': 2, 'Baz': 20}})
示例6: test_commas_in_counters
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_commas_in_counters(self):
# commas should be replaced with semicolons
mr_job = MRJob().sandbox()
mr_job.increment_counter('Bad items', 'a, b, c')
mr_job.increment_counter('girl, interrupted', 'movie')
parsed_stderr = parse_mr_job_stderr(mr_job.stderr.getvalue())
self.assertEqual(parsed_stderr['counters'],
{'Bad items': {'a; b; c': 1},
'girl; interrupted': {'movie': 1}})
示例7: test_counters_and_status
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_counters_and_status(self):
mr_job = MRJob().sandbox()
mr_job.increment_counter('Foo', 'Bar')
mr_job.set_status('Initializing qux gradients...')
mr_job.increment_counter('Foo', 'Bar')
mr_job.increment_counter('Foo', 'Baz', 20)
mr_job.set_status('Sorting metasyntactic variables...')
parsed_stderr = parse_mr_job_stderr(mr_job.stderr.getvalue())
self.assertEqual(
parsed_stderr, {
'counters': {
'Foo': {
'Bar': 2,
'Baz': 20
}
},
'statuses': [
'Initializing qux gradients...',
'Sorting metasyntactic variables...'
],
'other': []
})
# make sure parse_counters() works
self.assertEqual(mr_job.parse_counters(), parsed_stderr['counters'])
示例8: test_negative_and_zero_counters
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_negative_and_zero_counters(self):
mr_job = MRJob().sandbox()
mr_job.increment_counter("Foo", "Bar", -1)
mr_job.increment_counter("Foo", "Baz")
mr_job.increment_counter("Foo", "Baz", -1)
mr_job.increment_counter("Qux", "Quux", 0)
self.assertEqual(mr_job.parse_counters(), {"Foo": {"Bar": -1, "Baz": 0}, "Qux": {"Quux": 0}})
示例9: test_negative_and_zero_counters
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_negative_and_zero_counters(self):
mr_job = MRJob().sandbox()
mr_job.increment_counter('Foo', 'Bar', -1)
mr_job.increment_counter('Foo', 'Baz')
mr_job.increment_counter('Foo', 'Baz', -1)
mr_job.increment_counter('Qux', 'Quux', 0)
assert_equal(mr_job.parse_counters(),
{'Foo': {'Bar': -1, 'Baz': 0}, 'Qux': {'Quux': 0}})
示例10: test_negative_and_zero_counters
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_negative_and_zero_counters(self):
mr_job = MRJob().sandbox()
mr_job.increment_counter("Foo", "Bar", -1)
mr_job.increment_counter("Foo", "Baz")
mr_job.increment_counter("Foo", "Baz", -1)
mr_job.increment_counter("Qux", "Quux", 0)
parsed_stderr = parse_mr_job_stderr(mr_job.stderr.getvalue())
self.assertEqual(parsed_stderr["counters"], {"Foo": {"Bar": -1, "Baz": 0}, "Qux": {"Quux": 0}})
示例11: test_negative_and_zero_counters
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_negative_and_zero_counters(self):
mr_job = MRJob().sandbox()
mr_job.increment_counter('Foo', 'Bar', -1)
mr_job.increment_counter('Foo', 'Baz')
mr_job.increment_counter('Foo', 'Baz', -1)
mr_job.increment_counter('Qux', 'Quux', 0)
parsed_stderr = parse_mr_job_stderr(mr_job.stderr.getvalue())
self.assertEqual(parsed_stderr['counters'],
{'Foo': {'Bar': -1, 'Baz': 0}, 'Qux': {'Quux': 0}})
示例12: test_counters_and_status
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_counters_and_status(self):
mr_job = MRJob().sandbox()
mr_job.increment_counter("Foo", "Bar")
mr_job.set_status("Initializing qux gradients...")
mr_job.increment_counter("Foo", "Bar")
mr_job.increment_counter("Foo", "Baz", 20)
mr_job.set_status("Sorting metasyntactic variables...")
parsed_stderr = parse_mr_job_stderr(mr_job.stderr.getvalue())
self.assertEqual(
parsed_stderr,
{
"counters": {"Foo": {"Bar": 2, "Baz": 20}},
"statuses": ["Initializing qux gradients...", "Sorting metasyntactic variables..."],
"other": [],
},
)
示例13: test_unicode_counter
# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import increment_counter [as 别名]
def test_unicode_counter(self):
mr_job = MRJob().sandbox()
# shouldn't raise an exception
mr_job.increment_counter(u'💩', 'x', 1)