Class DictVector
java.lang.Object
org.apache.drill.exec.vector.complex.AbstractContainerVector
org.apache.drill.exec.vector.complex.AbstractMapVector
org.apache.drill.exec.vector.complex.AbstractRepeatedMapVector
org.apache.drill.exec.vector.complex.DictVector
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<ValueVector>
,ContainerVectorLike
,RepeatedValueVector
,ValueVector
A
ValueVector
holding key-value pairs.
This vector is essentially a RepeatedMapVector
but with constraints:
it may have 2 children only, named FIELD_KEY_NAME
and FIELD_VALUE_NAME
.
The FIELD_KEY_NAME
can be of primitive type only and its values should not be null
,
while the other, FIELD_VALUE_NAME
, field can be either of primitive or complex type.
Value field can hold null
values.
This vector has it's own FieldReader
and
FieldWriter
to ensure data is read and written correctly.
In addition, the reader is responsible for getting a value for a given key.
Additionally, Object
representation is changed in DictVector.Accessor.getObject(int)
to represent it as JsonStringHashMap
with appropriate key
and value
types.
(The structure corresponds to Java's notion of Map
).
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.drill.exec.vector.complex.RepeatedValueVector
RepeatedValueVector.RepeatedAccessor, RepeatedValueVector.RepeatedMutator
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final TypeProtos.MajorType
Fields inherited from class org.apache.drill.exec.vector.complex.AbstractRepeatedMapVector
emptyPopulator, offsets
Fields inherited from class org.apache.drill.exec.vector.complex.AbstractContainerVector
allocator, callBack, field
Fields inherited from interface org.apache.drill.exec.vector.complex.RepeatedValueVector
DEFAULT_REPEAT_PER_RECORD
Fields inherited from interface org.apache.drill.exec.vector.ValueVector
BITS_VECTOR_NAME, MAX_BUFFER_SIZE, MAX_ROW_COUNT, MIN_ROW_COUNT, OFFSETS_VECTOR_NAME, VALUES_VECTOR_NAME
-
Constructor Summary
ConstructorDescriptionDictVector
(MaterializedField field, BufferAllocator allocator, CallBack callBack) DictVector
(MaterializedField field, BufferAllocator allocator, CallBack callBack, TypeProtos.MajorType keyType, TypeProtos.MajorType valueType) -
Method Summary
Modifier and TypeMethodDescriptionvoid
exchange
(ValueVector other) Exchange state with another value vector of the same type.Returns anaccessor
that is used to read from this vector instance.Returns aValueVector
corresponding to the given field name if exists or null.<T extends ValueVector>
TReturns aValueVector
instance of subtype ofcorresponding to the given field name if exists or null. protected Collection<String>
Returns a sequence of field names in the order that they show up in the schema.Returns a vector with its corresponding ordinal mapping if field exists or null.getKeys()
Returns anmutator
that is used to write to this vector instance.Returns afield reader
that supports reading values from this vector.getTransferPair
(String ref, BufferAllocator allocator) getTransferPair
(BufferAllocator allocator) Returns atransfer pair
, creating a new target vector of the same type.boolean
Returns a newtransfer pair
that is used to transfer underlying buffers into the target vector.void
putChild
(String name, ValueVector vector) Inserts the vector with the given name if it does not exist else replaces it with the new value.void
transferTo
(DictVector target) Methods inherited from class org.apache.drill.exec.vector.complex.AbstractRepeatedMapVector
addOrGetVector, allocateNew, allocateNewSafe, allocateOffsetsNew, clear, close, collectLedgers, copyEntry, copyFromSafe, fieldNameIterator, getAllocatedSize, getBuffers, getBufferSize, getBufferSizeFor, getDataVector, getMetadata, getOffsetVector, getPayloadByteCount, getPrimitiveVectors, getTransferPairToSingleMap, getValueCapacity, load, setInitialCapacity, toNullable
Methods inherited from class org.apache.drill.exec.vector.complex.AbstractMapVector
addOrGet, getChildByOrdinal, getChildren, iterator, putVector, size
Methods inherited from class org.apache.drill.exec.vector.complex.AbstractContainerVector
allocateNew, getAllocator, getField, supportsDirectRead, typeify
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.drill.exec.vector.complex.ContainerVectorLike
size
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface org.apache.drill.exec.vector.ValueVector
allocateNew, getAllocator, getField
-
Field Details
-
TYPE
-
FIELD_KEY_NAME
- See Also:
-
FIELD_VALUE_NAME
- See Also:
-
fieldNames
-
-
Constructor Details
-
DictVector
-
DictVector
public DictVector(MaterializedField field, BufferAllocator allocator, CallBack callBack, TypeProtos.MajorType keyType, TypeProtos.MajorType valueType)
-
-
Method Details
-
getReader
Description copied from interface:ValueVector
Returns afield reader
that supports reading values from this vector. -
getChildFieldNames
Description copied from class:AbstractContainerVector
Returns a sequence of field names in the order that they show up in the schema.- Overrides:
getChildFieldNames
in classAbstractContainerVector
-
transferTo
-
makeTransferPair
-
getTransferPair
Description copied from interface:ValueVector
Returns atransfer pair
, creating a new target vector of the same type. -
makeTransferPair
Description copied from interface:ValueVector
Returns a newtransfer pair
that is used to transfer underlying buffers into the target vector. -
getTransferPair
-
putChild
Inserts the vector with the given name if it does not exist else replaces it with the new value. If the vector is replaced, old and new type are expected to be equal. Validates that thename
is eitherFIELD_KEY_NAME
orFIELD_VALUE_NAME
and that key is of primitive type.- Overrides:
putChild
in classAbstractMapVector
- Parameters:
name
- field namevector
- vector to be added- Throws:
DrillRuntimeException
- ifname
is not equal toFIELD_KEY_NAME
orFIELD_VALUE_NAME
or ifname.equals(FIELD_KEY_NAME)
and vector is of repeated or complex type.
-
getChild
Returns aValueVector
corresponding to the given field name if exists or null. Expects eitherFIELD_KEY_NAME
orFIELD_VALUE_NAME
.- Overrides:
getChild
in classAbstractContainerVector
- Parameters:
name
- field's name
-
exchange
Description copied from interface:ValueVector
Exchange state with another value vector of the same type. Used to implement look-ahead writers.- Specified by:
exchange
in interfaceValueVector
- Overrides:
exchange
in classAbstractRepeatedMapVector
-
getChildVectorWithOrdinal
Description copied from class:AbstractMapVector
Returns a vector with its corresponding ordinal mapping if field exists or null.- Overrides:
getChildVectorWithOrdinal
in classAbstractMapVector
-
getChild
Description copied from class:AbstractMapVector
Returns aValueVector
instance of subtype ofcorresponding to the given field name if exists or null. - Overrides:
getChild
in classAbstractMapVector
-
getAccessor
Description copied from interface:ValueVector
Returns anaccessor
that is used to read from this vector instance.- Specified by:
getAccessor
in interfaceRepeatedValueVector
- Specified by:
getAccessor
in interfaceValueVector
- Specified by:
getAccessor
in classAbstractRepeatedMapVector
-
getMutator
Description copied from interface:ValueVector
Returns anmutator
that is used to write to this vector instance. -
getKeys
-
getValues
-
getKeyType
-
getValueType
-
isValueNullable
public boolean isValueNullable()
-