public final class DictVector extends AbstractRepeatedMapVector
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
).
Modifier and Type | Class and Description |
---|---|
class |
DictVector.Accessor |
class |
DictVector.Mutator |
RepeatedValueVector.RepeatedAccessor, RepeatedValueVector.RepeatedMutator
Modifier and Type | Field and Description |
---|---|
static String |
FIELD_KEY_NAME |
static String |
FIELD_VALUE_NAME |
static List<String> |
fieldNames |
static TypeProtos.MajorType |
TYPE |
emptyPopulator, offsets
allocator, callBack, field
DEFAULT_REPEAT_PER_RECORD
BITS_VECTOR_NAME, MAX_BUFFER_SIZE, MAX_ROW_COUNT, MIN_ROW_COUNT, OFFSETS_VECTOR_NAME, VALUES_VECTOR_NAME
Constructor and Description |
---|
DictVector(MaterializedField field,
BufferAllocator allocator,
CallBack callBack) |
DictVector(MaterializedField field,
BufferAllocator allocator,
CallBack callBack,
TypeProtos.MajorType keyType,
TypeProtos.MajorType valueType) |
Modifier and Type | Method and Description |
---|---|
void |
exchange(ValueVector other)
Exchange state with another value vector of the same type.
|
DictVector.Accessor |
getAccessor()
Returns an
accessor that is used to read from this vector
instance. |
ValueVector |
getChild(String name)
Returns a
ValueVector corresponding to the given field name if exists or null. |
<T extends ValueVector> |
getChild(String name,
Class<T> clazz)
Returns a
ValueVector instance of subtype of |
protected Collection<String> |
getChildFieldNames()
Returns a sequence of field names in the order that they show up in the schema.
|
VectorWithOrdinal |
getChildVectorWithOrdinal(String name)
Returns a vector with its corresponding ordinal mapping if field exists or null.
|
ValueVector |
getKeys() |
TypeProtos.MajorType |
getKeyType() |
DictVector.Mutator |
getMutator()
Returns an
mutator that is used to write to this vector
instance. |
SingleDictReaderImpl |
getReader()
Returns a
field reader that supports reading values
from this vector. |
TransferPair |
getTransferPair(BufferAllocator allocator)
Returns a
transfer pair , creating a new target vector of
the same type. |
TransferPair |
getTransferPair(String ref,
BufferAllocator allocator) |
ValueVector |
getValues() |
TypeProtos.MajorType |
getValueType() |
boolean |
isValueNullable() |
TransferPair |
makeTransferPair(DictVector to) |
TransferPair |
makeTransferPair(ValueVector to)
Returns a new
transfer 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) |
addOrGetVector, allocateNew, allocateNewSafe, allocateOffsetsNew, clear, close, collectLedgers, copyEntry, copyFromSafe, fieldNameIterator, getAllocatedSize, getBuffers, getBufferSize, getBufferSizeFor, getDataVector, getMetadata, getOffsetVector, getPayloadByteCount, getPrimitiveVectors, getTransferPairToSingleMap, getValueCapacity, load, setInitialCapacity, toNullable
addOrGet, getChildByOrdinal, getChildren, iterator, putVector, size
allocateNew, getAllocator, getField, supportsDirectRead, typeify
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
allocateNew, getAllocator, getField
forEach, iterator, spliterator
size
public static final TypeProtos.MajorType TYPE
public static final String FIELD_KEY_NAME
public static final String FIELD_VALUE_NAME
public DictVector(MaterializedField field, BufferAllocator allocator, CallBack callBack)
public DictVector(MaterializedField field, BufferAllocator allocator, CallBack callBack, TypeProtos.MajorType keyType, TypeProtos.MajorType valueType)
public SingleDictReaderImpl getReader()
ValueVector
field reader
that supports reading values
from this vector.protected Collection<String> getChildFieldNames()
AbstractContainerVector
getChildFieldNames
in class AbstractContainerVector
public void transferTo(DictVector target)
public TransferPair makeTransferPair(DictVector to)
public TransferPair getTransferPair(BufferAllocator allocator)
ValueVector
transfer pair
, creating a new target vector of
the same type.public TransferPair makeTransferPair(ValueVector to)
ValueVector
transfer pair
that is used to transfer underlying
buffers into the target vector.public TransferPair getTransferPair(String ref, BufferAllocator allocator)
public void putChild(String name, ValueVector vector)
name
is either FIELD_KEY_NAME
or FIELD_VALUE_NAME
and
that key is of primitive type.putChild
in class AbstractMapVector
name
- field namevector
- vector to be addedDrillRuntimeException
- if name
is not equal to FIELD_KEY_NAME
or FIELD_VALUE_NAME
or if name.equals(FIELD_KEY_NAME)
and vector is of repeated or complex type.public ValueVector getChild(String name)
ValueVector
corresponding to the given field name if exists or null.
Expects either FIELD_KEY_NAME
or FIELD_VALUE_NAME
.getChild
in class AbstractContainerVector
name
- field's namepublic void exchange(ValueVector other)
ValueVector
exchange
in interface ValueVector
exchange
in class AbstractRepeatedMapVector
public VectorWithOrdinal getChildVectorWithOrdinal(String name)
AbstractMapVector
getChildVectorWithOrdinal
in class AbstractMapVector
public <T extends ValueVector> T getChild(String name, Class<T> clazz)
AbstractMapVector
ValueVector
instance of subtype of getChild
in class AbstractMapVector
public DictVector.Accessor getAccessor()
ValueVector
accessor
that is used to read from this vector
instance.getAccessor
in interface RepeatedValueVector
getAccessor
in interface ValueVector
getAccessor
in class AbstractRepeatedMapVector
public DictVector.Mutator getMutator()
ValueVector
mutator
that is used to write to this vector
instance.public ValueVector getKeys()
public ValueVector getValues()
public TypeProtos.MajorType getKeyType()
public TypeProtos.MajorType getValueType()
public boolean isValueNullable()
Copyright © 1970 The Apache Software Foundation. All rights reserved.