Module org.apache.arrow.algorithm
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 Summary
ConstructorDescriptionHashTableBasedDictionaryBuilder
(V dictionary) Constructs a hash table based dictionary builder.HashTableBasedDictionaryBuilder
(V dictionary, boolean encodeNull) Constructs a hash table based dictionary builder.HashTableBasedDictionaryBuilder
(V dictionary, boolean encodeNull, ArrowBufHasher hasher) Constructs a hash table based dictionary builder. -
Method Summary
-
Constructor Details
-
HashTableBasedDictionaryBuilder
Constructs a hash table based dictionary builder.- Parameters:
dictionary
- the dictionary to populate.
-
HashTableBasedDictionaryBuilder
Constructs a hash table based dictionary builder.- Parameters:
dictionary
- the dictionary to populate.encodeNull
- if null values should be added to the dictionary.
-
HashTableBasedDictionaryBuilder
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
Gets the dictionary built.- Specified by:
getDictionary
in interfaceDictionaryBuilder<V extends ElementAddressableVector>
- Returns:
- the dictionary.
-
addValues
Try to add all values from the target vector to the dictionary.- Specified by:
addValues
in interfaceDictionaryBuilder<V extends ElementAddressableVector>
- Parameters:
targetVector
- the target vector containing values to probe.- Returns:
- the number of values actually added to the dictionary.
-
addValue
Try to add an element from the target vector to the dictionary.- Specified by:
addValue
in interfaceDictionaryBuilder<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.
-