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


Python Timestamp.of方法代码示例

本文整理汇总了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())})
开发者ID:charlesccychen,项目名称:incubator-beam,代码行数:28,代码来源:transform_evaluator.py

示例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
开发者ID:eralmas7,项目名称:beam,代码行数:21,代码来源:windowed_value.py

示例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
开发者ID:amitsela,项目名称:incubator-beam,代码行数:13,代码来源:windowed_value.py

示例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())})
开发者ID:gamars,项目名称:beam,代码行数:24,代码来源:transform_evaluator.py

示例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
开发者ID:dpmills,项目名称:incubator-beam,代码行数:8,代码来源:window.py

示例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))
开发者ID:JavierRoger,项目名称:beam,代码行数:8,代码来源:windowed_value_test.py

示例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))
开发者ID:aaltay,项目名称:incubator-beam,代码行数:8,代码来源:timestamp_test.py


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