Class WriteFixedText

  • All Implemented Interfaces:
    LogicalOperator, RecordSinkOperator, SinkOperator<RecordPort>

    public class WriteFixedText
    extends AbstractTextWriter
    Writes a record dataflow as a text file of fixed-width records. The writer requires a FixedWidthTextRecord to determine how field values are formatted. Fields are mapped by name; all fields defined in the schema must be present in the input (and vice-versa), although they need not be in the same order. The order of fields in the formatted record is determined by the order in the supplied schema. Records in the file are separated by a non-empty, user-defined character sequence.

    The record schema can be manually constructed via the API provided, although though this metadata is often persisted externally. Support for Pervasive DataIntegrator structured schema descriptors (.schema files) is provided with StructuredSchemaReader.

    • Constructor Detail

      • WriteFixedText

        public WriteFixedText​(String path,
                              WriteMode mode)
        Writes fixed text to the specified path in the given mode, using default settings.

        If the writer is parallelized, this is interpreted as a directory in which each partition will write a fragment of the entire input stream. Otherwise, it is interpreted as the file to write.

        The schema must be set before execution or an error will be raised.

        Parameters:
        path - the path to write
        mode - how to handle existing files
        See Also:
        setSchema(FixedWidthTextRecord)
      • WriteFixedText

        public WriteFixedText​(Path path,
                              WriteMode mode)
        Writes fixed text to the specified path in the given mode, using default settings.

        If the writer is parallelized, this is interpreted as a directory in which each partition will write a fragment of the entire input stream. Otherwise, it is interpreted as the file to write.

        The schema must be set before execution or an error will be raised.

        Parameters:
        path - the path to write
        mode - how to handle existing files
        See Also:
        setSchema(FixedWidthTextRecord)
      • WriteFixedText

        public WriteFixedText​(ByteSink target,
                              WriteMode mode)
        Writes text to the specified target sink in the given mode.

        The writer can only be parallelized if the sink is fragmentable. In this case, each partition will be written as an independent sink. Otherwise, the writer will run non-parallel.

        The schema must be set before execution or an error will be raised.

        Parameters:
        target - the data sink to which to write
        mode - how to handle an existing sink
        See Also:
        setSchema(FixedWidthTextRecord)
    • Method Detail

      • setRecordSeparator

        public void setRecordSeparator​(String separator)
        Set the record separator. This string will be output at the end of each record written. The default value is the system dependent record separator.
        Parameters:
        separator - text separating records
      • getRecordSeparator

        public String getRecordSeparator()
        Get the record separator.
        Returns:
        record separator
      • setSchema

        public void setSchema​(FixedWidthTextRecord schema)
        Set the schema to use for formatting output records. The schema is required. The schema defines the field names, types, positions, sizes and formatting specifications.
        Parameters:
        schema - format of output records