Interface DataFormat.DataFormatter

  • All Known Implementing Classes:
    AbstractRecordFormatter
    Enclosing interface:
    DataFormat

    public static interface DataFormat.DataFormatter
    A formatter for converting record data to binary or text format. A DataFormatter bridges the gap between records within and outside of a dataflow graph An implementation represents such a mapping for some concrete external format.
    See Also:
    DataFormat.DataParser
    • Method Detail

      • bindInput

        void bindInput​(SteppableRecordValued source)
        Called to provide the source port from which records to format are read.

        This method is called once, before writeData(ByteSink, WriteMode) is called. Any one-time initialization for the formatter should be performed within the implementation of this method.

        Parameters:
        source - the input port providing records
      • writeData

        void writeData​(ByteSink sink,
                       WriteMode mode)
        Called to write records to the provided sink in the specified mode.

        This method is called once. The implementation is expected to read records from the input passed to #bindInput(RecordInput) and write them to the given sink as requested. The call must not return until end of data has been signaled on the input. Failure to do so will result in an error in the executing graph. Streams opened on the sink are not required to be closed on exit, but it is strongly recommended.

        Parameters:
        sink - the data sink to which formatted records are to be written
        mode - the access mode for the write
      • close

        void close()
        Called to signal that writing is complete. If #bindInput(RecordInput) has returned successfully, it is guaranteed that this method will be called, even if errors occur.

        This method is called once, after the last call to writeData(ByteSink, WriteMode) Any allocated resources which need to be released should be handled within the implementation of this method.