Package org.apache.flink.formats.avro
Class AvroOutputFormat<E>
- java.lang.Object
-
- org.apache.flink.api.common.io.RichOutputFormat<IT>
-
- org.apache.flink.api.common.io.FileOutputFormat<E>
-
- org.apache.flink.formats.avro.AvroOutputFormat<E>
-
- Type Parameters:
E
-
- All Implemented Interfaces:
Serializable
,CleanupWhenUnsuccessful
,InitializeOnMaster
,OutputFormat<E>
public class AvroOutputFormat<E> extends FileOutputFormat<E> implements Serializable
FileOutputFormat
for Avro records.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AvroOutputFormat.Codec
Wrapper which encapsulates the supported codec and a related serialization byte.-
Nested classes/interfaces inherited from class org.apache.flink.api.common.io.FileOutputFormat
FileOutputFormat.OutputDirectoryMode
-
Nested classes/interfaces inherited from interface org.apache.flink.api.common.io.OutputFormat
OutputFormat.InitializationContext
-
-
Field Summary
-
Fields inherited from class org.apache.flink.api.common.io.FileOutputFormat
outputFilePath, stream
-
-
Constructor Summary
Constructors Constructor Description AvroOutputFormat(Class<E> type)
AvroOutputFormat(Path filePath, Class<E> type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Method that marks the end of the life-cycle of parallel output instance.protected String
getDirectoryFileName(int taskNumber)
void
open(OutputFormat.InitializationContext context)
Opens a parallel instance of the output format to store the result of its parallel instance.void
setCodec(AvroOutputFormat.Codec codec)
Set avro codec for compression.void
setSchema(org.apache.avro.Schema schema)
void
writeRecord(E record)
Adds a record to the output.-
Methods inherited from class org.apache.flink.api.common.io.FileOutputFormat
configure, getOutputDirectoryMode, getOutputFilePath, getWriteMode, initDefaultsFromConfiguration, initializeGlobal, setOutputDirectoryMode, setOutputFilePath, setWriteMode, tryCleanupOnError
-
Methods inherited from class org.apache.flink.api.common.io.RichOutputFormat
getRuntimeContext, setRuntimeContext
-
-
-
-
Method Detail
-
getDirectoryFileName
protected String getDirectoryFileName(int taskNumber)
- Overrides:
getDirectoryFileName
in classFileOutputFormat<E>
-
setSchema
public void setSchema(org.apache.avro.Schema schema)
-
setCodec
public void setCodec(AvroOutputFormat.Codec codec)
Set avro codec for compression.- Parameters:
codec
- avro codec.
-
writeRecord
public void writeRecord(E record) throws IOException
Description copied from interface:OutputFormat
Adds a record to the output.When this method is called, the output format it guaranteed to be opened.
- Specified by:
writeRecord
in interfaceOutputFormat<E>
- Parameters:
record
- The records to add to the output.- Throws:
IOException
- Thrown, if the records could not be added due to an I/O problem.
-
open
public void open(OutputFormat.InitializationContext context) throws IOException
Description copied from interface:OutputFormat
Opens a parallel instance of the output format to store the result of its parallel instance.When this method is called, the output format it guaranteed to be configured.
- Specified by:
open
in interfaceOutputFormat<E>
- Overrides:
open
in classFileOutputFormat<E>
- Parameters:
context
- The context to get task parallel infos.- Throws:
IOException
- Thrown, if the output could not be opened due to an I/O problem.
-
close
public void close() throws IOException
Description copied from interface:OutputFormat
Method that marks the end of the life-cycle of parallel output instance. Should be used to close channels and streams and release resources. After this method returns without an error, the output is assumed to be correct.When this method is called, the output format it guaranteed to be opened.
- Specified by:
close
in interfaceOutputFormat<E>
- Overrides:
close
in classFileOutputFormat<E>
- Throws:
IOException
- Thrown, if the input could not be closed properly.
-
-