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

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

                Author: ASF GitHub Bot
            Created on: 11/Feb/20 06:08
            Start Date: 11/Feb/20 06:08
    Worklog Time Spent: 10m 
      Work Description: pabloem commented on pull request #10290: [BEAM-8561] 
Add ThriftIO to support IO for Thrift files
URL: https://github.com/apache/beam/pull/10290#discussion_r377417741
 
 

 ##########
 File path: 
sdks/java/io/thrift/src/main/java/org/apache/beam/sdk/io/thrift/ThriftCoder.java
 ##########
 @@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.thrift;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import org.apache.beam.sdk.coders.CoderException;
+import org.apache.beam.sdk.coders.CustomCoder;
+
+public class ThriftCoder<T> extends CustomCoder<T> {
+
+  public static <T> ThriftCoder<T> of() {
+    return new ThriftCoder<>();
+  }
+
+  /**
+   * Encodes the given value of type {@code T} onto the given output stream.
+   *
+   * @param value {@link org.apache.thrift.TBase} to encode.
+   * @param outStream stream to output encoded value to.
+   * @throws IOException if writing to the {@code OutputStream} fails for some 
reason
+   * @throws CoderException if the value could not be encoded for some reason
+   */
+  @Override
+  public void encode(T value, OutputStream outStream) throws CoderException, 
IOException {
+    ObjectOutputStream oos = new ObjectOutputStream(outStream);
+    oos.writeObject(value);
+    oos.flush();
+  }
 
 Review comment:
   It seems that the coder simply does Java serialization. Is that right?
 
----------------------------------------------------------------
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:
us...@infra.apache.org


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

    Worklog Id:     (was: 384984)
    Time Spent: 9h 50m  (was: 9h 40m)

> Add ThriftIO to Support IO for Thrift Files
> -------------------------------------------
>
>                 Key: BEAM-8561
>                 URL: https://issues.apache.org/jira/browse/BEAM-8561
>             Project: Beam
>          Issue Type: New Feature
>          Components: io-java-files
>            Reporter: Chris Larsen
>            Assignee: Chris Larsen
>            Priority: Major
>          Time Spent: 9h 50m
>  Remaining Estimate: 0h
>
> Similar to AvroIO it would be very useful to support reading and writing 
> to/from Thrift files with a native connector. 
> Functionality would include:
>  # read() - Reading from one or more Thrift files.
>  # write() - Writing to one or more Thrift files.



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

Reply via email to