java.lang.Object
org.apache.arrow.vector.dictionary.DictionaryEncoder
Encoder/decoder for Dictionary encoded
ValueVector
. Dictionary encoding produces an
integer ValueVector
. Each entry in the Vector is index into the dictionary which can hold
values of any type.-
Constructor Summary
ConstructorDescriptionDictionaryEncoder
(Dictionary dictionary, BufferAllocator allocator) Construct an instance.DictionaryEncoder
(Dictionary dictionary, BufferAllocator allocator, ArrowBufHasher hasher) Construct an instance. -
Method Summary
Modifier and TypeMethodDescriptiondecode
(ValueVector indices) Decodes a vector with the dictionary in this encoder.static ValueVector
decode
(ValueVector indices, Dictionary dictionary) Decodes a dictionary encoded array using the provided dictionary.static ValueVector
decode
(ValueVector indices, Dictionary dictionary, BufferAllocator allocator) Decodes a dictionary encoded array using the provided dictionary.encode
(ValueVector vector) Encodes a vector with the built hash table in this encoder.static ValueVector
encode
(ValueVector vector, Dictionary dictionary) Dictionary encodes a vector with a provided dictionary.static ArrowType.Int
getIndexType
(int valueCount) Get the indexType according to the dictionary vector valueCount.
-
Constructor Details
-
DictionaryEncoder
Construct an instance. -
DictionaryEncoder
Construct an instance.
-
-
Method Details
-
encode
Dictionary encodes a vector with a provided dictionary. The dictionary must contain all values in the vector.- Parameters:
vector
- vector to encodedictionary
- dictionary used for encoding- Returns:
- dictionary encoded vector
-
decode
Decodes a dictionary encoded array using the provided dictionary.- Parameters:
indices
- dictionary encoded values, must be int typedictionary
- dictionary used to decode the values- Returns:
- vector with values restored from dictionary
-
decode
public static ValueVector decode(ValueVector indices, Dictionary dictionary, BufferAllocator allocator) Decodes a dictionary encoded array using the provided dictionary.- Parameters:
indices
- dictionary encoded values, must be int typedictionary
- dictionary used to decode the valuesallocator
- allocator the decoded values use- Returns:
- vector with values restored from dictionary
-
getIndexType
Get the indexType according to the dictionary vector valueCount.- Parameters:
valueCount
- dictionary vector valueCount.- Returns:
- index type.
-
encode
Encodes a vector with the built hash table in this encoder. -
decode
Decodes a vector with the dictionary in this encoder.decode(ValueVector, Dictionary, BufferAllocator)
should be used instead if only decoding is required as it can avoid building theDictionaryHashTable
which only makes sense when encoding.
-