[ 
https://issues.apache.org/jira/browse/BEAM-11482?focusedWorklogId=526596&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-526596
 ]

ASF GitHub Bot logged work on BEAM-11482:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Dec/20 20:43
            Start Date: 20/Dec/20 20:43
    Worklog Time Spent: 10m 
      Work Description: ccciudatu commented on a change in pull request #13572:
URL: https://github.com/apache/beam/pull/13572#discussion_r546433681



##########
File path: 
sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoMessageSchema.java
##########
@@ -130,28 +129,12 @@ public SchemaUserTypeCreator schemaTypeCreator(Class<?> 
targetClass, Schema sche
     "unchecked"
   })
   public static <T> SimpleFunction<byte[], Row> getProtoBytesToRowFn(Class<T> 
clazz) {
-    checkForMessageType(clazz);
-    return new ProtoBytesToRowFn(clazz);
-  }
-
-  private static class ProtoBytesToRowFn<T extends Message> extends 
SimpleFunction<byte[], Row> {
-    private final ProtoCoder<T> protoCoder;
-    private final SerializableFunction<T, Row> toRowFunction;
-
-    public ProtoBytesToRowFn(Class<T> clazz) {
-      this.protoCoder = ProtoCoder.of(clazz);
-      this.toRowFunction = new 
ProtoMessageSchema().toRowFunction(TypeDescriptor.of(clazz));
-    }
-
-    @Override
-    public Row apply(byte[] bytes) {
-      try {
-        T message = protoCoder.getParser().parseFrom(bytes);
-        return toRowFunction.apply(message);
-      } catch (IOException e) {
-        throw new IllegalArgumentException("Could not decode row from proto 
payload.", e);
-      }
-    }
+    Class<Message> protoClass = ensureMessageType(clazz);
+    ProtoCoder<Message> protoCoder = ProtoCoder.of(protoClass);
+    return new SqlRows.BytesToRowFn<>(
+        new ProtoMessageSchema(),
+        TypeDescriptor.of(protoClass),
+        bytes -> protoCoder.getParser().parseFrom(bytes));

Review comment:
       this can't be a method reference (`protoCoder.getParser()::parseFrom`) 
because the protobuf `Parser` is not `Serializable`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 526596)
    Time Spent: 10.5h  (was: 10h 20m)

> Thrift support for KafkaTableProvider
> -------------------------------------
>
>                 Key: BEAM-11482
>                 URL: https://issues.apache.org/jira/browse/BEAM-11482
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql, io-java-kafka
>            Reporter: Costi Ciudatu
>            Assignee: Costi Ciudatu
>            Priority: P2
>          Time Spent: 10.5h
>  Remaining Estimate: 0h
>
> Kafka table provider can leverage the Thrift coder and schema provider 
> defined in the IO package to handle thrift input/output.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to