Class OutputFormatBase<OUT,​V>

  • Type Parameters:
    OUT - Type of the elements to write.
    All Implemented Interfaces:
    Serializable, OutputFormat<OUT>

    @Experimental
    public abstract class OutputFormatBase<OUT,​V>
    extends RichOutputFormat<OUT>
    OutputFormatBase is the common abstract class for output formats. It implements a flush mechanism and has a maximum number of concurrent requests.
    See Also:
    Serialized Form
    • Constructor Detail

      • OutputFormatBase

        protected OutputFormatBase​(int maxConcurrentRequests,
                                   java.time.Duration maxConcurrentRequestsTimeout)
    • Method Detail

      • open

        public final void open​(int taskNumber,
                               int numTasks)
        Open the format and initializes the flush system.
        Parameters:
        taskNumber - The number of the parallel instance.
        numTasks - The number of parallel tasks.
      • postOpen

        protected void postOpen()
        Initialize the OutputFormat. This method is called at the end of open(int, int).
      • writeRecord

        public final void writeRecord​(OUT record)
                               throws IOException
        Asynchronously write a record and deal with maxConcurrentRequests. To specify how a record is written, please override the send(Object) method.
        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.
      • send

        protected abstract CompletionStage<V> send​(OUT record)
        Send the actual record for writing.
        Returns:
        a CompletionStage that represents the writing task.
      • close

        public final void close()
                         throws IOException
        Close the format waiting for pending writes and reports errors.
        Throws:
        IOException - Thrown, if the input could not be closed properly.
      • postClose

        protected void postClose()
        Tear down the OutputFormat. This method is called at the end of close().