Class UnionVector
java.lang.Object
org.apache.drill.exec.vector.complex.UnionVector
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<ValueVector>,ValueVector
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final intstatic final intstatic final Stringstatic final TypeProtos.MajorType[]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
ConstructorsConstructorDescriptionUnionVector(MaterializedField field, BufferAllocator allocator, CallBack callBack) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddType(ValueVector vector) Add an externally-created subtype vector.Add a vector that matches the argument.voidAllocate new buffers.voidallocateNew(int rowCount) booleanAllocates new buffers.voidclear()Release the underlying DrillBuf and reset the ValueVector to empty.voidclose()Alternative to clear().voidcollectLedgers(Set<AllocationManager.BufferLedger> ledgers) Add the ledgers underlying the buffers underlying the components of the vector to the set provided.voidcopyEntry(int toIndex, ValueVector from, int fromIndex) voidcopyFrom(int inIndex, int outIndex, UnionVector from) voidcopyFromSafe(int inIndex, int outIndex, UnionVector from) voidexchange(ValueVector other) Exchange state with another value vector of the same type.Returns anaccessorthat is used to read from this vector instance.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.intgetBufferSizeFor(int valueCount) Returns the number of bytes that is used by this vector if it holds the given number of values.getDict()getField()Get information about how this field is materialized.getList()getMap()Add or get a type member given the type.Get the metadata for this field.Returns anmutatorthat is used to write to this vector instance.intgetPayloadByteCount(int valueCount) Return the number of value bytes consumed by actual data.Returns afield readerthat 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.intgetTypeValue(int index) intReturns the maximum number of values that can be stored in this vector instance.iterator()voidload(UserBitShared.SerializedField metadata, DrillBuf buffer) Load the data provided in the buffer.makeTransferPair(ValueVector target) Returns a newtransfer pairthat is used to transfer underlying buffers into the target vector.<T extends ValueVector>
Tmember(TypeProtos.MinorType type) setFirstType(ValueVector v, int newValueCount) voidsetInitialCapacity(int numRecords) Set the initial record capacity<T extends ValueVector>
Tsubtype(TypeProtos.MinorType type) voidtoNullable(ValueVector nullableVector) Convert a non-nullable vector to nullable by shuffling the data from one to the other.voidtransferTo(UnionVector target) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
NULL_MARKER
public static final int NULL_MARKER- See Also:
-
TYPE_VECTOR_NAME
- See Also:
-
INTERNAL_MAP_NAME
- See Also:
-
TYPE_COUNT
public static final int TYPE_COUNT -
TYPES
-
-
Constructor Details
-
UnionVector
-
-
Method Details
-
getAllocator
- Specified by:
getAllocatorin interfaceValueVector
-
getSubTypes
-
subtype
-
addType
Add an externally-created subtype vector. The vector must represent a type that does not yet exist in the union, and must be of OPTIONAL mode. Does not call the callback since the client (presumably) knows that it is adding the type. The caller must also allocate the buffer for the vector.- Parameters:
vector- subtype vector to add
-
addSubType
-
getMap
-
getDict
-
getList
-
getTinyIntVector
-
getUInt1Vector
-
getUInt2Vector
-
getSmallIntVector
-
getIntVector
-
getUInt4Vector
-
getFloat4Vector
-
getTimeVector
-
getIntervalYearVector
-
getBigIntVector
-
getUInt8Vector
-
getFloat8Vector
-
getDateVector
-
getTimeStampVector
-
getIntervalDayVector
-
getIntervalVector
-
getVarBinaryVector
-
getVarCharVector
-
getVar16CharVector
-
getVarDecimalVector
-
getBitVector
-
getMember
Add or get a type member given the type.- Parameters:
type- the type of the vector to retrieve- Returns:
- the (potentially newly created) vector that backs the given type
-
member
-
getTypeValue
public int getTypeValue(int index) -
getTypeVector
-
getTypeMap
-
allocateNew
Description copied from interface:ValueVectorAllocate new buffers. ValueVector implements logic to determine how much to allocate.- Specified by:
allocateNewin interfaceValueVector- Throws:
OutOfMemoryException- Thrown if no memory can be allocated.
-
allocateNew
- Throws:
OutOfMemoryException
-
allocateNewSafe
public boolean allocateNewSafe()Description copied from interface:ValueVectorAllocates new buffers. ValueVector implements logic to determine how much to allocate.- Specified by:
allocateNewSafein interfaceValueVector- Returns:
- Returns true if allocation was successful.
-
setInitialCapacity
public void setInitialCapacity(int numRecords) Description copied from interface:ValueVectorSet the initial record capacity- Specified by:
setInitialCapacityin interfaceValueVector- Parameters:
numRecords-
-
getValueCapacity
public int getValueCapacity()Description copied from interface:ValueVectorReturns the maximum number of values that can be stored in this vector instance.- Specified by:
getValueCapacityin interfaceValueVector
-
close
public void close()Description copied from interface:ValueVectorAlternative to clear(). Allows use as an AutoCloseable in try-with-resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceValueVector
-
clear
public void clear()Description copied from interface:ValueVectorRelease the underlying DrillBuf and reset the ValueVector to empty.- Specified by:
clearin interfaceValueVector
-
getField
Description copied from interface:ValueVectorGet information about how this field is materialized.- Specified by:
getFieldin interfaceValueVector
-
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.- Specified by:
collectLedgersin interfaceValueVector- 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.- Specified by:
getPayloadByteCountin interfaceValueVector
-
getTransferPair
Description copied from interface:ValueVectorReturns atransfer pair, creating a new target vector of the same type.- Specified by:
getTransferPairin interfaceValueVector
-
getTransferPair
- Specified by:
getTransferPairin interfaceValueVector
-
makeTransferPair
Description copied from interface:ValueVectorReturns a newtransfer pairthat is used to transfer underlying buffers into the target vector.- Specified by:
makeTransferPairin interfaceValueVector
-
transferTo
-
copyFrom
-
copyFromSafe
-
copyEntry
- Specified by:
copyEntryin interfaceValueVector
-
addVector
Add a vector that matches the argument. Transfer the buffer from the argument to the new vector.- Parameters:
v- the vector to clone and add- Returns:
- the cloned vector that now holds the data from the argument
-
setFirstType
-
toNullable
Description copied from interface:ValueVectorConvert a non-nullable vector to nullable by shuffling the data from one to the other. Avoids the need to generate copy code just to change mode. If this vector is non-nullable, accepts a nullable dual (same minor type, different mode.) If the vector is non-nullable, or non-scalar, then throws an exception.- Specified by:
toNullablein interfaceValueVector- Parameters:
nullableVector- nullable vector of the same minor type as this vector
-
getAccessor
Description copied from interface:ValueVectorReturns anaccessorthat is used to read from this vector instance.- Specified by:
getAccessorin interfaceValueVector
-
getMutator
Description copied from interface:ValueVectorReturns anmutatorthat is used to write to this vector instance.- Specified by:
getMutatorin interfaceValueVector
-
getReader
Description copied from interface:ValueVectorReturns afield readerthat supports reading values from this vector.- Specified by:
getReaderin interfaceValueVector
-
getWriter
-
getMetadata
Description copied from interface:ValueVectorGet the metadata for this field. Used in serialization- Specified by:
getMetadatain interfaceValueVector- Returns:
- FieldMetadata for this field.
-
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.- Specified by:
getBufferSizein interfaceValueVector
-
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.- Specified by:
getAllocatedSizein interfaceValueVector- Returns:
- allocated buffer size, in bytes
-
getBufferSizeFor
public int getBufferSizeFor(int valueCount) Description copied from interface:ValueVectorReturns the number of bytes that is used by this vector if it holds the given number of values. The result will be the same as if Mutator.setValueCount() were called, followed by calling getBufferSize(), but without any of the closing side-effects that setValueCount() implies wrt finishing off the population of a vector. Some operations might wish to use this to determine how much memory has been used by a vector so far, even though it is not finished being populated.- Specified by:
getBufferSizeForin interfaceValueVector- Parameters:
valueCount- the number of values to assume this vector contains- Returns:
- the buffer size if this vector is holding valueCount values
-
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).- Specified by:
getBuffersin interfaceValueVector- 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.
-
iterator
- Specified by:
iteratorin interfaceIterable<ValueVector>
-
exchange
Description copied from interface:ValueVectorExchange state with another value vector of the same type. Used to implement look-ahead writers.- Specified by:
exchangein interfaceValueVector
-