0

I am trying to read data with version 2.4.0 of Apache Beam using the standard TextIO.read(). The data has to be read as a ByteString.

Unfortunately, it doesn't seem like Apache Beam supports .withCoder() in the same way Dataflow does. I can't seem to find an alternative way to introduce a coder. Furthermore, it seems like ByteStringCoder is no longer included in the coders of Apache Beam.

What's the best way to get the same result of Dataflow's .withCoder(ByteStringCoder.of()) with the latest version of Apache Beam? Coders are still present in Apache Beam so there has to be some way to use them.

1 Answer 1

1

ByteStringCoder is located in beam-sdks-java-extensions-protobuf module so you need to include dependency

https://mvnrepository.com/artifact/org.apache.beam/beam-sdks-java-extensions-protobuf

As for the TextIO: It uses StringUtf8Coder so you probably need to write your own BoundedSource/UnboundedSource. And then use:

pipeline.apply(Read.from(yourCreatedSource))

You could take inspiration of current TextSource, where you can probably only change type String of FileBasedSource for ByteString.

https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/io/TextSource.java

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.