Interface SegmentFileBuilder

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
FileSmoosher, SegmentFileBuilderV10

public interface SegmentFileBuilder extends Closeable
Builder for segment file(s) which are created on close() and later can be read with a SegmentFileMapper. At the lowest level, segment files are built by packing multiple chunks of data organized as internal files, into the same physical file to efficiently share file descriptors, At a higher level, Druid columns are composed of one or more files containing the column parts, which are stored in the segment during serialization using this builder.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cleanup any open resources in the event of an exception while building the segment files
    void
    add(String name, File fileToAdd)
    Add a File to the segment file as the specified name
    void
    add(String name, ByteBuffer bufferToAdd)
    Add a ByteBuffer to a segment file as the specified name
    void
    addColumn(String name, ColumnDescriptor columnDescriptor)
    Add a column to the metadata of this segment file
    addWithChannel(String name, long size)
    Creates a SegmentFileChannel to write data to the segment file as the specified name.
    void
    Close the segment file builder, writing the file(s) to the destination
    getExternalBuilder(String externalFile)
    Allow adding data to an 'external' segment container file which will be built in the same directory as this segment file.
  • Method Details

    • addColumn

      void addColumn(String name, ColumnDescriptor columnDescriptor)
      Add a column to the metadata of this segment file
    • add

      void add(String name, File fileToAdd) throws IOException
      Add a File to the segment file as the specified name
      Throws:
      IOException
    • add

      void add(String name, ByteBuffer bufferToAdd) throws IOException
      Add a ByteBuffer to a segment file as the specified name
      Throws:
      IOException
    • addWithChannel

      SegmentFileChannel addWithChannel(String name, long size) throws IOException
      Creates a SegmentFileChannel to write data to the segment file as the specified name. Callers must be sure to write the amount of data specified by the size parameter.
      Throws:
      IOException
    • getExternalBuilder

      default SegmentFileBuilder getExternalBuilder(String externalFile)
      Allow adding data to an 'external' segment container file which will be built in the same directory as this segment file. Legacy implementations of this method just return the same builder since they do not support this concept. This allows column implementations to use these methods, but also still work with older segment formats (assuming the older format otherwise supports the contents).
    • abort

      void abort()
      cleanup any open resources in the event of an exception while building the segment files
    • close

      void close() throws IOException
      Close the segment file builder, writing the file(s) to the destination
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException