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


Python Gauged.value方法代码示例

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


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

示例1: test_rewrite_append_only_violation

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_rewrite_append_only_violation(self):
     gauged = Gauged(self.driver, append_only_violation=Gauged.REWRITE)
     with gauged.writer as writer:
         writer.add('foo', 123, timestamp=2000)
         writer.add('foo', 456, timestamp=1000)
     self.assertIsNone(gauged.value('foo', timestamp=1000))
     self.assertEqual(gauged.value('foo', timestamp=2000), 456)
开发者ID:chriso,项目名称:gauged,代码行数:9,代码来源:test_gauged.py

示例2: test_look_behind

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_look_behind(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000, max_look_behind=10000)
     with gauged.writer as writer:
         writer.add('foo', 123, timestamp=10000)
         writer.add('bar', 123, timestamp=40000)
     self.assertEqual(gauged.value('foo', timestamp=10000), 123)
     self.assertEqual(gauged.value('foo', timestamp=20000), 123)
     self.assertEqual(gauged.value('foo', timestamp=30000), None)
开发者ID:lessc0de,项目名称:gauged,代码行数:10,代码来源:test_gauged.py

示例3: test_append_only_violation

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_append_only_violation(self):
     gauged = Gauged(self.driver)
     with gauged.writer as writer:
         writer.add('foo', 123, timestamp=2000)
         with self.assertRaises(GaugedAppendOnlyError):
             writer.add('foo', 456, timestamp=1000)
     self.assertIsNone(gauged.value('foo', timestamp=1000))
     self.assertEqual(gauged.value('foo', timestamp=2000), 123)
开发者ID:chriso,项目名称:gauged,代码行数:10,代码来源:test_gauged.py

示例4: test_coercing_non_string_keys

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_coercing_non_string_keys(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000)
     with gauged.writer as writer:
         writer.add(1234, 100, timestamp=10000)
         writer.add(True, 100, timestamp=10000)
         writer.add(u'foo', 100, timestamp=10000)
     self.assertEqual(gauged.value('1234', timestamp=10000), 100)
     self.assertEqual(gauged.value('True', timestamp=10000), 100)
     self.assertEqual(gauged.value('foo', timestamp=10000), 100)
开发者ID:pyarnold,项目名称:gauged,代码行数:11,代码来源:test_gauged.py

示例5: test_flush_flushes_last_complete_block

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_flush_flushes_last_complete_block(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000)
     with gauged.writer as writer:
         writer.add('foo', 1, timestamp=1000)
         writer.add('foo', 2, timestamp=2000)
         writer.add('foo', 3, timestamp=3000)
         self.assertEqual(gauged.value('foo', timestamp=3000), None)
         writer.flush()
         self.assertEqual(gauged.value('foo', timestamp=3000), 2)
     self.assertEqual(gauged.value('foo', timestamp=3000), 3)
开发者ID:pyarnold,项目名称:gauged,代码行数:12,代码来源:test_gauged.py

示例6: test_gauge_nan

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_gauge_nan(self):
     gauged = Gauged(self.driver, block_size=50000)
     with gauged.writer as writer:
         with self.assertRaises(GaugedNaNError):
             writer.add('foobar', 'baz')
     self.assertEqual(gauged.value('foobar'), None)
     gauged = Gauged(self.driver, block_size=50000, gauge_nan=Gauged.IGNORE)
     with gauged.writer as writer:
         writer.add('foobar', 'baz')
     self.assertEqual(gauged.value('foobar'), None)
开发者ID:pyarnold,项目名称:gauged,代码行数:12,代码来源:test_gauged.py

示例7: test_relative_dates

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_relative_dates(self):
     now = long(time() * 1000)
     gauged = Gauged(self.driver, defaults={'start': -4 * Gauged.DAY})
     with gauged.writer as writer:
         writer.add('foo', 1, timestamp=now - 6 * Gauged.DAY)
         writer.add('foo', 2, timestamp=now - 5 * Gauged.DAY)
         writer.add('foo', 3, timestamp=now - 3 * Gauged.DAY)
         writer.add('foo', 4, timestamp=now - 2 * Gauged.DAY)
         writer.add('foo', 5, timestamp=now - Gauged.DAY)
     self.assertEqual(gauged.value('foo'), 5)
     self.assertEqual(gauged.value('foo', timestamp=-1.5 * Gauged.DAY), 4)
开发者ID:pyarnold,项目名称:gauged,代码行数:13,代码来源:test_gauged.py

示例8: test_interim_flushing

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_interim_flushing(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000)
     with gauged.writer as writer:
         writer.add('foo', 123, timestamp=1000)
         writer.flush()
         writer.add('bar', 456, timestamp=2000)
         writer.flush()
         writer.add('baz', 789, timestamp=10000)
     self.assertEqual(gauged.value('foo', timestamp=10000), 123)
     self.assertEqual(gauged.value('bar', timestamp=10000), 456)
     self.assertEqual(gauged.value('baz', timestamp=10000), 789)
开发者ID:pyarnold,项目名称:gauged,代码行数:13,代码来源:test_gauged.py

示例9: test_auto_flush

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_auto_flush(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000, flush_seconds=0.001)
     with gauged.writer as writer:
         writer.add('foo', 1, timestamp=1000)
         self.assertEqual(gauged.value('foo', timestamp=2000), None)
         sleep(0.002)
         self.assertEqual(gauged.value('foo', timestamp=2000), None)
         # note: the next write triggers the flush() of all prior writes
         writer.add('foo', 2, timestamp=2000)
         sleep(0.002)
         self.assertEqual(gauged.value('foo', timestamp=2000), 1)
     self.assertEqual(gauged.value('foo', timestamp=2000), 2)
开发者ID:lessc0de,项目名称:gauged,代码行数:14,代码来源:test_gauged.py

示例10: test_ignore_append_only_violation

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_ignore_append_only_violation(self):
     gauged = Gauged(self.driver, append_only_violation=Gauged.IGNORE)
     with gauged.writer as writer:
         writer.add('foo', 123, timestamp=2000)
         writer.add('foo', 456, timestamp=1000)
     self.assertEqual(gauged.value('foo', timestamp=1000), None)
     self.assertEqual(gauged.value('foo', timestamp=2000), 123)
开发者ID:pyarnold,项目名称:gauged,代码行数:9,代码来源:test_gauged.py

示例11: test_config_instance

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_config_instance(self):
     config = Config(append_only_violation=Gauged.REWRITE,
                     resolution=1000, block_size=10000)
     gauged = Gauged(self.driver, config=config)
     with gauged.writer as writer:
         writer.add('foo', 1, timestamp=2000)
         writer.add('foo', 2, timestamp=1000)
     self.assertEqual(gauged.value('foo', timestamp=2000), 2)
开发者ID:pyarnold,项目名称:gauged,代码行数:10,代码来源:test_gauged.py

示例12: test_no_data

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_no_data(self):
     gauged = Gauged(self.driver)
     self.assertEqual(len(gauged.namespaces()), 0)
     self.assertEqual(len(gauged.value_series('foo')), 0)
     self.assertEqual(len(gauged.aggregate_series('foo', Gauged.SUM)), 0)
     self.assertEqual(gauged.value('foo'), None)
     self.assertEqual(gauged.aggregate('foo', Gauged.SUM), None)
     self.assertEqual(len(gauged.keys()), 0)
     stats = gauged.statistics()
     for attr in ['data_points', 'byte_count']:
         self.assertEqual(getattr(stats, attr), 0)
开发者ID:pyarnold,项目名称:gauged,代码行数:13,代码来源:test_gauged.py

示例13: test_accepting_data_as_string

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_accepting_data_as_string(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000,
         key_overflow=Gauged.IGNORE, gauge_nan=Gauged.IGNORE)
     with gauged.writer as writer:
         writer.add('foo=123.456&bar=-15.98&qux=0&invalid=foobar\n', timestamp=20000)
     self.assertAlmostEqual(123.456, gauged.value('foo', timestamp=20000), 5)
     self.assertAlmostEqual(-15.98, gauged.value('bar', timestamp=20000), 5)
     self.assertEqual(gauged.value('qux', timestamp=20000), 0)
     self.assertEqual(gauged.value('invalid', timestamp=20000), None)
     stats = gauged.statistics()
     self.assertEqual(stats.data_points, 3)
     self.assertEqual(stats.byte_count, 24)
     stats = gauged.statistics(end=25000)
     self.assertEqual(stats.data_points, 3)
     self.assertEqual(stats.byte_count, 24)
     gauged = Gauged(self.driver, resolution=1000, block_size=10000,
         key_overflow=Gauged.IGNORE)
     with self.assertRaises(GaugedNaNError):
         with gauged.writer as writer:
             writer.add(u'foo=123.456&bar=-15.98&qux=0&invalid=foobar\n', timestamp=20000)
开发者ID:lessc0de,项目名称:gauged,代码行数:22,代码来源:test_gauged.py

示例14: test_add_debug

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_add_debug(self):
     context = dict(called=False)
     gauged = Gauged(self.driver)
     def mock_debug(*_):
         context['called'] = True
     with gauged.writer as writer:
         writer.debug = mock_debug
         writer.add('foo', 123, timestamp=10000, debug=True)
         writer.add('foo=123', timestamp=10000, debug=True)
     self.assertEqual(gauged.value('foo', timestamp=10000), None)
     self.assertTrue(context['called'])
开发者ID:lessc0de,项目名称:gauged,代码行数:13,代码来源:test_gauged.py

示例15: test_clear_from

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import value [as 别名]
 def test_clear_from(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000)
     with gauged.writer as writer:
         writer.add('foo', 1, timestamp=10000)
         writer.add('foo', 2, timestamp=20000)
         writer.add('foo', 3, timestamp=30000)
         writer.add('foo', 4, timestamp=40000, namespace=1)
     with gauged.writer as writer:
         self.assertEqual(writer.resume_from(), 41000)
     self.assertEqual(gauged.value('foo', timestamp=40000), 3)
     self.assertEqual(gauged.value('foo', timestamp=40000, namespace=1), 4)
     with gauged.writer as writer:
         with self.assertRaises(ValueError):
             # note: must be cleared from nearest block boundary (20000)
             writer.clear_from(25000)
         writer.clear_from(20000)
     self.assertEqual(gauged.value('foo', timestamp=40000), 1)
     self.assertEqual(
         gauged.value('foo', timestamp=40000, namespace=1), None)
     with gauged.writer as writer:
         self.assertEqual(writer.resume_from(), 21000)
         writer.add('foo', 5, timestamp=30000)
         writer.add('foo', 6, timestamp=30000, namespace=1)
     self.assertEqual(gauged.value('foo', timestamp=40000), 5)
     self.assertEqual(gauged.value('foo', timestamp=40000, namespace=1), 6)
开发者ID:pyarnold,项目名称:gauged,代码行数:27,代码来源:test_gauged.py


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