當前位置: 首頁>>代碼示例>>Python>>正文


Python DataflowRunner.flatten_input_visitor方法代碼示例

本文整理匯總了Python中apache_beam.runners.DataflowRunner.flatten_input_visitor方法的典型用法代碼示例。如果您正苦於以下問題:Python DataflowRunner.flatten_input_visitor方法的具體用法?Python DataflowRunner.flatten_input_visitor怎麽用?Python DataflowRunner.flatten_input_visitor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apache_beam.runners.DataflowRunner的用法示例。


在下文中一共展示了DataflowRunner.flatten_input_visitor方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _test_flatten_input_visitor

# 需要導入模塊: from apache_beam.runners import DataflowRunner [as 別名]
# 或者: from apache_beam.runners.DataflowRunner import flatten_input_visitor [as 別名]
  def _test_flatten_input_visitor(self, input_type, output_type, num_inputs):
    p = TestPipeline()
    inputs = []
    for _ in range(num_inputs):
      input_pcoll = PCollection(p)
      input_pcoll.element_type = input_type
      inputs.append(input_pcoll)
    output_pcoll = PCollection(p)
    output_pcoll.element_type = output_type

    flatten = AppliedPTransform(None, beam.Flatten(), "label", inputs)
    flatten.add_output(output_pcoll, None)
    DataflowRunner.flatten_input_visitor().visit_transform(flatten)
    for _ in range(num_inputs):
      self.assertEqual(inputs[0].element_type, output_type)
開發者ID:aaltay,項目名稱:incubator-beam,代碼行數:17,代碼來源:dataflow_runner_test.py

示例2: test_gbk_then_flatten_input_visitor

# 需要導入模塊: from apache_beam.runners import DataflowRunner [as 別名]
# 或者: from apache_beam.runners.DataflowRunner import flatten_input_visitor [as 別名]
  def test_gbk_then_flatten_input_visitor(self):
    p = TestPipeline(
        runner=DataflowRunner(),
        options=PipelineOptions(self.default_properties))
    none_str_pc = p | 'c1' >> beam.Create({None: 'a'})
    none_int_pc = p | 'c2' >> beam.Create({None: 3})
    flat = (none_str_pc, none_int_pc) | beam.Flatten()
    _ = flat | beam.GroupByKey()

    # This may change if type inference changes, but we assert it here
    # to make sure the check below is not vacuous.
    self.assertNotIsInstance(flat.element_type, typehints.TupleConstraint)

    p.visit(DataflowRunner.group_by_key_input_visitor())
    p.visit(DataflowRunner.flatten_input_visitor())

    # The dataflow runner requires gbk input to be tuples *and* flatten
    # inputs to be equal to their outputs. Assert both hold.
    self.assertIsInstance(flat.element_type, typehints.TupleConstraint)
    self.assertEqual(flat.element_type, none_str_pc.element_type)
    self.assertEqual(flat.element_type, none_int_pc.element_type)
開發者ID:aaltay,項目名稱:incubator-beam,代碼行數:23,代碼來源:dataflow_runner_test.py


注:本文中的apache_beam.runners.DataflowRunner.flatten_input_visitor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。