Package org.apache.beam.sdk.io
Class AvroIO.Sink<ElementT>
- java.lang.Object
-
- org.apache.beam.sdk.io.AvroIO.Sink<ElementT>
-
- All Implemented Interfaces:
java.io.Serializable
,FileIO.Sink<ElementT>
- Enclosing class:
- AvroIO
public abstract static class AvroIO.Sink<ElementT> extends java.lang.Object implements FileIO.Sink<ElementT>
Implementation ofAvroIO.sink(java.lang.Class<ElementT>)
andAvroIO.sinkViaGenericRecords(org.apache.avro.Schema, org.apache.beam.sdk.io.AvroIO.RecordFormatter<ElementT>)
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Sink()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
Flushes the buffered state (if any) before the channel is closed.void
open(java.nio.channels.WritableByteChannel channel)
Initializes writing to the given channel.AvroIO.Sink<ElementT>
withCodec(org.apache.avro.file.CodecFactory codec)
Specifies to use the givenCodecFactory
for each generated file.AvroIO.Sink<ElementT>
withMetadata(java.util.Map<java.lang.String,java.lang.Object> metadata)
Specifies to put the given metadata into each generated file.void
write(ElementT element)
Appends a single element to the file.
-
-
-
Method Detail
-
withMetadata
public AvroIO.Sink<ElementT> withMetadata(java.util.Map<java.lang.String,java.lang.Object> metadata)
Specifies to put the given metadata into each generated file. By default, empty.
-
withCodec
public AvroIO.Sink<ElementT> withCodec(org.apache.avro.file.CodecFactory codec)
Specifies to use the givenCodecFactory
for each generated file. By default,CodecFactory.snappyCodec()
.
-
open
public void open(java.nio.channels.WritableByteChannel channel) throws java.io.IOException
Description copied from interface:FileIO.Sink
Initializes writing to the given channel. Will be invoked once on a givenFileIO.Sink
instance.- Specified by:
open
in interfaceFileIO.Sink<ElementT>
- Throws:
java.io.IOException
-
write
public void write(ElementT element) throws java.io.IOException
Description copied from interface:FileIO.Sink
Appends a single element to the file. May be invoked zero or more times.- Specified by:
write
in interfaceFileIO.Sink<ElementT>
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
Description copied from interface:FileIO.Sink
Flushes the buffered state (if any) before the channel is closed. Does not need to close the channel. Will be invoked once.- Specified by:
flush
in interfaceFileIO.Sink<ElementT>
- Throws:
java.io.IOException
-
-