Interface DictionaryWriter<T>

All Superinterfaces:
Serializer
All Known Implementing Classes:
EncodedStringDictionaryWriter, FixedIndexedWriter, FrontCodedIndexedWriter, FrontCodedIntArrayIndexedWriter, GenericIndexedWriter

public interface DictionaryWriter<T> extends Serializer
  • Method Summary

    Modifier and Type
    Method
    Description
    get(int dictId)
    Returns an object that has already been written via the write(T) method.
    int
    Returns the number of items that have been written so far in this dictionary.
    boolean
     
    void
    Prepares the writer for writing
    int
    write(T objectToWrite)
    Writes an object to the dictionary.

    Methods inherited from interface org.apache.druid.segment.serde.Serializer

    getSerializedSize, writeTo
  • Method Details

    • isSorted

      boolean isSorted()
    • open

      void open() throws IOException
      Prepares the writer for writing
      Throws:
      IOException - if there is a problem with IO
    • write

      int write(@Nullable T objectToWrite) throws IOException
      Writes an object to the dictionary.

      Returns the index of the value that was just written. This is defined as the `int` value that can be passed into get(int) such that it will return the same value back.

      Parameters:
      objectToWrite - object to be written to the dictionary
      Returns:
      index of the value that was just written
      Throws:
      IOException - if there is a problem with IO
    • get

      @Nullable T get(int dictId) throws IOException
      Returns an object that has already been written via the write(T) method.
      Parameters:
      dictId - index of the object to return
      Returns:
      the object identified by the given index
      Throws:
      IOException - if there is a problem with IO
    • getCardinality

      int getCardinality()
      Returns the number of items that have been written so far in this dictionary. Any number lower than this cardinality can be passed into get(int) and a value will be returned. If a value greater than or equal to the cardinality is passed into get(int) all sorts of things could happen, but likely none of them are good.
      Returns:
      the number of items that have been written so far