Class AvroIO.Sink<ElementT>
java.lang.Object
org.apache.beam.sdk.extensions.avro.io.AvroIO.Sink<ElementT>
- All Implemented Interfaces:
Serializable
,FileIO.Sink<ElementT>
- Enclosing class:
AvroIO
Implementation of
AvroIO.sink(java.lang.Class<ElementT>)
and AvroIO.sinkViaGenericRecords(org.apache.avro.Schema, org.apache.beam.sdk.extensions.avro.io.AvroIO.RecordFormatter<ElementT>)
.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
flush()
Flushes the buffered state (if any) before the channel is closed.void
open
(WritableByteChannel channel) Initializes writing to the given channel.withCodec
(CodecFactory codec) Specifies to use the givenCodecFactory
for each generated file.withDatumWriterFactory
(AvroSink.DatumWriterFactory<ElementT> datumWriterFactory) Sets a customAvroSource.DatumReaderFactory
for writing.withMetadata
(Map<String, Object> metadata) Specifies to put the given metadata into each generated file.void
Appends a single element to the file.
-
Constructor Details
-
Sink
public Sink()
-
-
Method Details
-
withMetadata
Specifies to put the given metadata into each generated file. By default, empty. -
withCodec
Specifies to use the givenCodecFactory
for each generated file. By default,CodecFactory.snappyCodec()
. -
withDatumWriterFactory
public AvroIO.Sink<ElementT> withDatumWriterFactory(AvroSink.DatumWriterFactory<ElementT> datumWriterFactory) Sets a customAvroSource.DatumReaderFactory
for writing. -
open
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:
IOException
-
write
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:
IOException
-
flush
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:
IOException
-