Package org.apache.flink.api.common.io
Interface OutputFormat<IT>
-
- Type Parameters:
IT- The type of the consumed records.
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
BinaryOutputFormat,FileOutputFormat,OutputFormatBase,RichOutputFormat,SerializedOutputFormat
@Public public interface OutputFormat<IT> extends Serializable
The base interface for outputs that consumes records. The output format describes how to store the final records, for example in a file.The life cycle of an output format is the following:
- configure() is invoked a single time. The method can be used to implement initialization from the parameters (configuration) that may be attached upon instantiation.
- Each parallel output task creates an instance, configures it and opens it.
- All records of its parallel instance are handed to the output format.
- The output format is closed
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceOutputFormat.InitializationContextThe context exposes some runtime info for initializing output format.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidclose()Method that marks the end of the life-cycle of parallel output instance.voidconfigure(Configuration parameters)Configures this output format.default voidopen(int taskNumber, int numTasks)Deprecated.Useopen(InitializationContext)insteaddefault voidopen(OutputFormat.InitializationContext context)Opens a parallel instance of the output format to store the result of its parallel instance.voidwriteRecord(IT record)Adds a record to the output.
-
-
-
Method Detail
-
configure
void configure(Configuration parameters)
Configures this output format. Since output formats are instantiated generically and hence parameterless, this method is the place where the output formats set their basic fields based on configuration values.This method is always called first on a newly instantiated output format.
- Parameters:
parameters- The configuration with all parameters.
-
open
@Deprecated default void open(int taskNumber, int numTasks) throws IOException
Deprecated.Useopen(InitializationContext)insteadOpens 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.
- Parameters:
taskNumber- The number of the parallel instance.numTasks- The number of parallel tasks.- Throws:
IOException- Thrown, if the output could not be opened due to an I/O problem.
-
open
default void open(OutputFormat.InitializationContext context) throws IOException
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.
- 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.
-
writeRecord
void writeRecord(IT record) throws IOException
Adds a record to the output.When this method is called, the output format it guaranteed to be opened.
- 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.
-
close
void close() throws IOExceptionMethod 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.
- Throws:
IOException- Thrown, if the input could not be closed properly.
-
-