Class AbstractMapVector
java.lang.Object
org.apache.drill.exec.vector.complex.AbstractContainerVector
org.apache.drill.exec.vector.complex.AbstractMapVector
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<ValueVector>
,ValueVector
- Direct Known Subclasses:
AbstractRepeatedMapVector
,MapVector
Base class for MapVectors. Currently used by AbstractRepeatedMapVector and MapVector
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.drill.exec.vector.ValueVector
ValueVector.Accessor, ValueVector.Mutator
-
Field Summary
Fields inherited from class org.apache.drill.exec.vector.complex.AbstractContainerVector
allocator, callBack, field
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
ModifierConstructorDescriptionprotected
AbstractMapVector
(MaterializedField field, BufferAllocator allocator, CallBack callBack) -
Method Summary
Modifier and TypeMethodDescription<T extends ValueVector>
TaddOrGet
(String name, TypeProtos.MajorType type, Class<T> clazz) Adds a new field with the given parameters or replaces the existing one and consequently returns the resultantValueVector
.boolean
Allocates new buffers.void
close()
Clears out all underlying child vectors.void
collectLedgers
(Set<AllocationManager.BufferLedger> ledgers) Add the ledgers underlying the buffers underlying the components of the vector to the set provided.void
exchange
(ValueVector other) Exchange state with another value vector of the same type.int
Returns the total size of buffers allocated by this vector.DrillBuf[]
getBuffers
(boolean clear) Return the underlying buffers associated with this vector.int
Returns the number of bytes that is used by this vector instance.<T extends ValueVector>
TReturns aValueVector
instance of subtype ofcorresponding to the given field name if exists or null. getChildByOrdinal
(int id) Returns aValueVector
corresponding to the given ordinal identifier.protected Collection<ValueVector>
Returns a sequence of underlying child vectors.Returns a vector with its corresponding ordinal mapping if field exists or null.int
getPayloadByteCount
(int valueCount) Return the number of value bytes consumed by actual data.Returns a list of scalar child vectors recursing the entire vector hierarchy.iterator()
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.protected void
putVector
(String name, ValueVector vector) Inserts the input vector into the map if it does not exist, replaces if it exists alreadyint
size()
Returns the number of underlying child vectors.Methods inherited from class org.apache.drill.exec.vector.complex.AbstractContainerVector
allocateNew, getAllocator, getChild, getChildFieldNames, 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 java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.apache.drill.exec.vector.ValueVector
clear, copyEntry, getAccessor, getBufferSizeFor, getMetadata, getMutator, getReader, getTransferPair, getTransferPair, getValueCapacity, load, makeTransferPair, setInitialCapacity, toNullable
-
Constructor Details
-
AbstractMapVector
-
-
Method Details
-
close
public void close()Description copied from class:AbstractContainerVector
Clears out all underlying child vectors.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceValueVector
- Overrides:
close
in classAbstractContainerVector
-
allocateNewSafe
public boolean allocateNewSafe()Description copied from interface:ValueVector
Allocates new buffers. ValueVector implements logic to determine how much to allocate.- Returns:
- Returns true if allocation was successful.
-
addOrGet
Adds a new field with the given parameters or replaces the existing one and consequently returns the resultantValueVector
. Execution takes place in the following order:- if field is new, create and insert a new vector of desired type.
- if field exists and existing vector is of desired vector type, return the vector.
- if field exists and null filled, clear the existing vector; create and insert a new vector of desired type.
-
otherwise, throw an
IllegalStateException
- Specified by:
addOrGet
in classAbstractContainerVector
- Type Parameters:
T
- class type of expected vector type- Parameters:
name
- name of the fieldtype
- type of the fieldclazz
- class of expected vector type- Returns:
- resultant
ValueVector
- Throws:
IllegalStateException
- raised if there is a hard schema change
-
getChildByOrdinal
Returns aValueVector
corresponding to the given ordinal identifier. -
getChild
Returns aValueVector
instance of subtype ofcorresponding to the given field name if exists or null. - Specified by:
getChild
in classAbstractContainerVector
-
putChild
Inserts the vector with the given name if it does not exist else replaces it with the new value. Note that this method does not enforce any vector type check nor throws a schema change exception. -
putVector
Inserts the input vector into the map if it does not exist, replaces if it exists already- Parameters:
name
- field namevector
- vector to be inserted
-
getChildren
Returns a sequence of underlying child vectors. -
size
public int size()Returns the number of underlying child vectors.- Specified by:
size
in classAbstractContainerVector
-
iterator
-
getPrimitiveVectors
Returns a list of scalar child vectors recursing the entire vector hierarchy. -
getChildVectorWithOrdinal
Returns a vector with its corresponding ordinal mapping if field exists or null.- Specified by:
getChildVectorWithOrdinal
in classAbstractContainerVector
-
getBuffers
Description copied from interface:ValueVector
Return the underlying buffers associated with this vector. Note that this doesn't impact the reference counts for this buffer so it only should be used for in-context access. Also note that this buffer changes regularly thus external classes shouldn't hold a reference to it (unless they change it).- Parameters:
clear
- Whether to clear vector before returning; the buffers will still be refcounted; but the returned array will be the only reference to them- Returns:
- The underlying
buffers
that is used by this vector instance.
-
getBufferSize
public int getBufferSize()Description copied from interface:ValueVector
Returns the number of bytes that is used by this vector instance. This is a bit of a misnomer. Returns the number of bytes used by data in this instance. -
getAllocatedSize
public int getAllocatedSize()Description copied from interface:ValueVector
Returns the total size of buffers allocated by this vector. Has meaning only when vectors are directly allocated and each vector has its own buffer. Does not have meaning for vectors deserialized from the network or disk in which multiple vectors share the same vector.- Returns:
- allocated buffer size, in bytes
-
collectLedgers
Description copied from interface:ValueVector
Add the ledgers underlying the buffers underlying the components of the vector to the set provided. Used to determine actual memory allocation.- Parameters:
ledgers
- set of ledgers to which to add ledgers for this vector
-
getPayloadByteCount
public int getPayloadByteCount(int valueCount) Description copied from interface:ValueVector
Return the number of value bytes consumed by actual data. -
exchange
Description copied from interface:ValueVector
Exchange state with another value vector of the same type. Used to implement look-ahead writers.
-