コード例 #1
0
ファイル: snowflake.py プロジェクト: fernando-wizeline/beam
 def expand(self, pbegin):
     return (pbegin
             | 'User data mapper' >> beam.Map(
                 self.user_data_mapper).with_output_types(List[bytes])
             | ExternalTransform(self.URN,
                                 NamedTupleBasedPayloadBuilder(self.params),
                                 self.expansion_service))
コード例 #2
0
ファイル: snowflake.py プロジェクト: zhoufek/beam
 def expand(self, pbegin):
   return (
       pbegin
       | ExternalTransform(
           self.URN,
           NamedTupleBasedPayloadBuilder(self.params),
           self.expansion_service,
       )
       | 'CSV to array mapper' >> beam.Map(lambda csv: csv.split(b','))
       | 'CSV mapper' >> beam.Map(self.csv_mapper))
コード例 #3
0
ファイル: pubsub.py プロジェクト: wanwanzhu/beam
    def expand(self, pbegin):
        pcoll = pbegin.apply(
            ExternalTransform(self.URN,
                              NamedTupleBasedPayloadBuilder(self.params),
                              self.expansion_service))

        if self.params.with_attributes:
            pcoll = pcoll | 'FromProto' >> Map(
                pubsub.PubsubMessage._from_proto_str)
            pcoll.element_type = pubsub.PubsubMessage
        else:
            pcoll.element_type = bytes
        return pcoll
コード例 #4
0
ファイル: pubsub.py プロジェクト: wanwanzhu/beam
    def expand(self, pvalue):
        if self.with_attributes:
            pcoll = pvalue | 'ToProto' >> Map(
                pubsub.WriteToPubSub.to_proto_str)
        else:
            pcoll = pvalue | 'ToProto' >> Map(
                lambda x: pubsub.PubsubMessage(x, {})._to_proto_str())
        pcoll.element_type = bytes

        return pcoll.apply(
            ExternalTransform(self.URN,
                              NamedTupleBasedPayloadBuilder(self.params),
                              self.expansion_service))
コード例 #5
0
    def test_generate_sequence_java_class_lookup_payload_builder(self):
        port = os.environ.get('EXPANSION_PORT')
        address = 'localhost:%s' % port

        with TestPipeline() as p:
            payload_builder = JavaClassLookupPayloadBuilder(
                'org.apache.beam.sdk.io.GenerateSequence')
            payload_builder.with_constructor_method('from', 1)
            payload_builder.add_builder_method('to', 10)

            res = (p
                   | ExternalTransform(
                       None, payload_builder, expansion_service=address))
            assert_that(res, equal_to(list(range(1, 10))))
コード例 #6
0
ファイル: debezium.py プロジェクト: piter75/apache-beam
 def expand(self, pbegin):
     return (pbegin | ExternalTransform(
         self.URN,
         NamedTupleBasedPayloadBuilder(self.params),
         self.expansion_service,
     ) | ParDo(_JsonStringToDictionaries()))