Class BinaryWriter

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

public class BinaryWriter extends AbstractWriter
Writes raw binary data to a filesystem. This can be used to write any arbitrary data file as long as the original source filename is known. The raw binary data is written either into a single file or into multiple files.

The writer must be provided the name of the file to be written including the original extension if applicable and the field that contains the raw binary data. If writing multiple files a folder must be provided and the multiple property must be enabled. Additionally the filename field must be specified when writing multiple files.

  • Constructor Details

    • BinaryWriter

      public BinaryWriter()
      Writes an empty target with default settings. The target must be set before execution or an error will be raised.
      See Also:
    • BinaryWriter

      public BinaryWriter(String targetFilePath, WriteMode mode)
      Writes the binary data to the specified path in the given mode

      If writing multiple files, 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.

      Parameters:
      targetFilePath - the target to write
      mode - how to handle existing files
  • Method Details

    • getFilenameField

      public String getFilenameField()
      Gets the name of the field containing the output filenames to use when extracting the data.
      Returns:
      name of the file name field.
    • setFilenameField

      public void setFilenameField(String filenameField)
      Sets the name of the field containing the output filenames to use when extracting the data.
      Parameters:
      filenameField -
    • getMultiple

      public boolean getMultiple()
      Get whether the data is written as a single file or multiple files.
      Returns:
      whether the data is written as a single or multiple files.
    • setMultiple

      public void setMultiple(boolean multiple)
      Sets whether the data is written as a single file or multiple files.
      Parameters:
      multiple -
    • getBinaryField

      public String getBinaryField()
      Gets the name of the field containing the raw binary.
      Returns:
      name of the raw binary field
    • setBinaryField

      public void setBinaryField(String binaryField)
      Sets the name of the field containing the raw binary.
      Parameters:
      binaryField -
    • computeFormat

      protected DataFormat computeFormat(CompositionContext ctx)
      Description copied from class: AbstractWriter
      Determines the data format for the target. The returned format is used during composition to construct a WriteSink operator. If an implementation supports schema discovery, it must be performed in this method.
      Specified by:
      computeFormat in class AbstractWriter
      Parameters:
      ctx - the composition context for the current invocation of AbstractWriter.compose(CompositionContext)
      Returns:
      the target format to use