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, fieldFields 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
ConstructorsModifierConstructorDescriptionprotectedAbstractMapVector(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.booleanAllocates new buffers.voidclose()Clears out all underlying child vectors.voidcollectLedgers(Set<AllocationManager.BufferLedger> ledgers) Add the ledgers underlying the buffers underlying the components of the vector to the set provided.voidexchange(ValueVector other) Exchange state with another value vector of the same type.intReturns the total size of buffers allocated by this vector.DrillBuf[]getBuffers(boolean clear) Return the underlying buffers associated with this vector.intReturns the number of bytes that is used by this vector instance.<T extends ValueVector>
TReturns aValueVectorinstance of subtype ofcorresponding to the given field name if exists or null. getChildByOrdinal(int id) Returns aValueVectorcorresponding 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.intgetPayloadByteCount(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()voidputChild(String name, ValueVector vector) Inserts the vector with the given name if it does not exist else replaces it with the new value.protected voidputVector(String name, ValueVector vector) Inserts the input vector into the map if it does not exist, replaces if it exists alreadyintsize()Returns the number of underlying child vectors.Methods inherited from class org.apache.drill.exec.vector.complex.AbstractContainerVector
allocateNew, getAllocator, getChild, getChildFieldNames, getField, supportsDirectRead, typeifyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods 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:AbstractContainerVectorClears out all underlying child vectors.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceValueVector- Overrides:
closein classAbstractContainerVector
-
allocateNewSafe
public boolean allocateNewSafe()Description copied from interface:ValueVectorAllocates 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:
addOrGetin 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 aValueVectorcorresponding to the given ordinal identifier. -
getChild
Returns aValueVectorinstance of subtype ofcorresponding to the given field name if exists or null. - Specified by:
getChildin 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:
sizein 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:
getChildVectorWithOrdinalin classAbstractContainerVector
-
getBuffers
Description copied from interface:ValueVectorReturn 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
buffersthat is used by this vector instance.
-
getBufferSize
public int getBufferSize()Description copied from interface:ValueVectorReturns 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:ValueVectorReturns 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:ValueVectorAdd 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:ValueVectorReturn the number of value bytes consumed by actual data. -
exchange
Description copied from interface:ValueVectorExchange state with another value vector of the same type. Used to implement look-ahead writers.
-