本文整理汇总了Python中apache_beam.utils.timestamp.Timestamp.of方法的典型用法代码示例。如果您正苦于以下问题:Python Timestamp.of方法的具体用法?Python Timestamp.of怎么用?Python Timestamp.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apache_beam.utils.timestamp.Timestamp
的用法示例。
在下文中一共展示了Timestamp.of方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: finish_bundle
# 需要导入模块: from apache_beam.utils.timestamp import Timestamp [as 别名]
# 或者: from apache_beam.utils.timestamp.Timestamp import of [as 别名]
def finish_bundle(self):
data = self._read_from_pubsub(self.source.timestamp_attribute)
if data:
output_pcollection = list(self._outputs)[0]
bundle = self._evaluation_context.create_bundle(output_pcollection)
# TODO(ccy): Respect the PubSub source's id_label field.
for timestamp, message in data:
if self.source.with_attributes:
element = message
else:
element = message.data
bundle.output(
GlobalWindows.windowed_value(element, timestamp=timestamp))
bundles = [bundle]
else:
bundles = []
if self._applied_ptransform.inputs:
input_pvalue = self._applied_ptransform.inputs[0]
else:
input_pvalue = pvalue.PBegin(self._applied_ptransform.transform.pipeline)
unprocessed_bundle = self._evaluation_context.create_bundle(
input_pvalue)
# TODO(udim): Correct value for watermark hold.
return TransformResult(self, bundles, [unprocessed_bundle], None,
{None: Timestamp.of(time.time())})
示例2: __init__
# 需要导入模块: from apache_beam.utils.timestamp import Timestamp [as 别名]
# 或者: from apache_beam.utils.timestamp.Timestamp import of [as 别名]
def __init__(self, start, end):
if start is not None or end is not None:
self._start_object = Timestamp.of(start)
self._end_object = Timestamp.of(end)
try:
self._start_micros = self._start_object.micros
except OverflowError:
self._start_micros = (
MIN_TIMESTAMP.micros if self._start_object.micros < 0
else MAX_TIMESTAMP.micros)
try:
self._end_micros = self._end_object.micros
except OverflowError:
self._end_micros = (
MIN_TIMESTAMP.micros if self._end_object.micros < 0
else MAX_TIMESTAMP.micros)
else:
# Micros must be populated elsewhere.
self._start_object = self._end_object = None
示例3: __init__
# 需要导入模块: from apache_beam.utils.timestamp import Timestamp [as 别名]
# 或者: from apache_beam.utils.timestamp.Timestamp import of [as 别名]
def __init__(self, value, timestamp, windows):
# For performance reasons, only timestamp_micros is stored by default
# (as a C int). The Timestamp object is created on demand below.
self.value = value
if isinstance(timestamp, int):
self.timestamp_micros = timestamp * 1000000
else:
self.timestamp_object = (timestamp if isinstance(timestamp, Timestamp)
else Timestamp.of(timestamp))
self.timestamp_micros = self.timestamp_object.micros
self.windows = windows
示例4: finish_bundle
# 需要导入模块: from apache_beam.utils.timestamp import Timestamp [as 别名]
# 或者: from apache_beam.utils.timestamp.Timestamp import of [as 别名]
def finish_bundle(self):
data = self._read_from_pubsub()
if data:
output_pcollection = list(self._outputs)[0]
bundle = self._evaluation_context.create_bundle(output_pcollection)
# TODO(ccy): we currently do not use the PubSub message timestamp or
# respect the PubSub source's id_label field.
now = Timestamp.of(time.time())
for message_data in data:
bundle.output(GlobalWindows.windowed_value(message_data, timestamp=now))
bundles = [bundle]
else:
bundles = []
if self._applied_ptransform.inputs:
input_pvalue = self._applied_ptransform.inputs[0]
else:
input_pvalue = pvalue.PBegin(self._applied_ptransform.transform.pipeline)
unprocessed_bundle = self._evaluation_context.create_bundle(
input_pvalue)
return TransformResult(
self._applied_ptransform, bundles,
[unprocessed_bundle], None, {None: Timestamp.of(time.time())})
示例5: __init__
# 需要导入模块: from apache_beam.utils.timestamp import Timestamp [as 别名]
# 或者: from apache_beam.utils.timestamp.Timestamp import of [as 别名]
def __init__(self, size, period, offset=0):
if size <= 0:
raise ValueError('The size parameter must be strictly positive.')
self.size = Duration.of(size)
self.period = Duration.of(period)
self.offset = Timestamp.of(offset) % period
示例6: test_timestamps
# 需要导入模块: from apache_beam.utils.timestamp import Timestamp [as 别名]
# 或者: from apache_beam.utils.timestamp.Timestamp import of [as 别名]
def test_timestamps(self):
wv = windowed_value.WindowedValue(None, 3, ())
self.assertEqual(wv.timestamp, Timestamp.of(3))
self.assertTrue(wv.timestamp is wv.timestamp)
self.assertEqual(windowed_value.WindowedValue(None, -2.5, ()).timestamp,
Timestamp.of(-2.5))
示例7: test_of
# 需要导入模块: from apache_beam.utils.timestamp import Timestamp [as 别名]
# 或者: from apache_beam.utils.timestamp.Timestamp import of [as 别名]
def test_of(self):
interval = Timestamp(123)
self.assertEqual(id(interval), id(Timestamp.of(interval)))
self.assertEqual(interval, Timestamp.of(123.0))
with self.assertRaises(TypeError):
Timestamp.of(Duration(10))