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


Python MRJob.increment_counter方法代码示例

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

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

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

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

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

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

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

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

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

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

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

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

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


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