Class ThriftIO

java.lang.Object
org.apache.beam.sdk.io.thrift.ThriftIO

public class ThriftIO extends Object
PTransforms for reading and writing files containing Thrift encoded data.

Reading Thrift Files

For reading each file in a PCollection of FileIO.ReadableFile, use the readFiles(Class) transform.

For example:


 PCollection<FileIO.ReadableFile> files = pipeline
   .apply(FileIO.match().filepattern(options.getInputFilepattern())
   .apply(FileIO.readMatches());

 PCollection<ExampleType> examples = files.apply(ThriftIO.readFiles(ExampleType.class).withProtocol(thriftProto);
 

Writing Thrift Files

ThriftIO.Sink allows for a PCollection of TBase to be written to Thrift files. It can be used with the general-purpose FileIO transforms with FileIO.write/writeDynamic specifically.

For example:


 pipeline
   .apply(...) // PCollection<ExampleType>
   .apply(FileIO
     .<ExampleType>write()
     .via(ThriftIO.sink(thriftProto))
     .to("destination/path");