Class HashTableBasedDictionaryBuilder<V extends ElementAddressableVector>

java.lang.Object
org.apache.arrow.algorithm.dictionary.HashTableBasedDictionaryBuilder<V>
Type Parameters:
V - the dictionary vector type.
All Implemented Interfaces:
DictionaryBuilder<V>

public class HashTableBasedDictionaryBuilder<V extends ElementAddressableVector> extends Object implements DictionaryBuilder<V>
This class builds the dictionary based on a hash table. Each add operation can be finished in O(1) time, where n is the current dictionary size.
  • Constructor Details

    • HashTableBasedDictionaryBuilder

      public HashTableBasedDictionaryBuilder(V dictionary)
      Constructs a hash table based dictionary builder.
      Parameters:
      dictionary - the dictionary to populate.
    • HashTableBasedDictionaryBuilder

      public HashTableBasedDictionaryBuilder(V dictionary, boolean encodeNull)
      Constructs a hash table based dictionary builder.
      Parameters:
      dictionary - the dictionary to populate.
      encodeNull - if null values should be added to the dictionary.
    • HashTableBasedDictionaryBuilder

      public HashTableBasedDictionaryBuilder(V dictionary, boolean encodeNull, ArrowBufHasher hasher)
      Constructs a hash table based dictionary builder.
      Parameters:
      dictionary - the dictionary to populate.
      encodeNull - if null values should be added to the dictionary.
      hasher - the hasher used to compute the hash code.
  • Method Details

    • getDictionary

      public V getDictionary()
      Gets the dictionary built.
      Specified by:
      getDictionary in interface DictionaryBuilder<V extends ElementAddressableVector>
      Returns:
      the dictionary.
    • addValues

      public int addValues(V targetVector)
      Try to add all values from the target vector to the dictionary.
      Specified by:
      addValues in interface DictionaryBuilder<V extends ElementAddressableVector>
      Parameters:
      targetVector - the target vector containing values to probe.
      Returns:
      the number of values actually added to the dictionary.
    • addValue

      public int addValue(V targetVector, int targetIndex)
      Try to add an element from the target vector to the dictionary.
      Specified by:
      addValue in interface DictionaryBuilder<V extends ElementAddressableVector>
      Parameters:
      targetVector - the target vector containing new element.
      targetIndex - the index of the new element in the target vector.
      Returns:
      the index of the new element in the dictionary.