Package org.apache.drill.exec.record
Class VectorContainer
java.lang.Object
org.apache.drill.exec.record.VectorContainer
- All Implemented Interfaces:
Iterable<VectorWrapper<?>>
,VectorAccessible
- Direct Known Subclasses:
ExpandableHyperContainer
-
Field Summary
-
Constructor Summary
ConstructorDescriptionVectorContainer
(BufferAllocator allocator) VectorContainer
(BufferAllocator allocator, BatchSchema schema) Create a new vector container given a pre-defined schema.VectorContainer
(OperatorContext oContext) -
Method Summary
Modifier and TypeMethodDescriptionadd
(ValueVector vv) void
add
(ValueVector[] hyperVector) void
add
(ValueVector[] hyperVector, boolean releasable) void
addCollection
(Iterable<ValueVector> vectors) void
addHyperList
(List<ValueVector> vectors) void
addHyperList
(List<ValueVector> vectors, boolean releasable) <T extends ValueVector>
TaddOrGet
(String name, TypeProtos.MajorType type, Class<T> clazz) <T extends ValueVector>
TaddOrGet
(MaterializedField field) <T extends ValueVector>
TaddOrGet
(MaterializedField field, SchemaChangeCallBack callBack) This method should be called with MaterializedField which also has correct children field list specially when the field type is MAP.void
allocate
(int recordCount) void
boolean
void
allocatePrecomputedChildCount
(int valueCount, int bytesPerValue, int childValCount) int
appendRow
(VectorContainer srcContainer, int srcIndex) This works with non-hyperVectorContainer
s which have no selection vectors.void
buildFrom
(BatchSchema sourceSchema) void
void
clear()
void
copySchemaFrom
(VectorAccessible other) void
exchange
(VectorContainer other) Exchange buffers between two identical vector containers.getLast()
int
int
Get the number of records.Get the schema of the current RecordBatch.static VectorContainer
getTransferClone
(VectorAccessible incoming, BufferAllocator allocator) static VectorContainer
getTransferClone
(VectorAccessible incoming, OperatorContext oContext) Get a set of transferred clones of this container.static VectorContainer
getTransferClone
(VectorAccessible incoming, VectorWrapper<?>[] ignoreWrappers, OperatorContext oContext) getValueAccessorById
(Class<?> clazz, int... fieldIds) getValueVector
(int index) getValueVectorId
(SchemaPath path) Get the value vector type and id for the given schema path.boolean
boolean
int
Increment the record countboolean
iterator()
merge
(VectorContainer otherContainer) Merge two batches to create a single, combined, batch.prettyPrintRecord
(int index) This method create a pretty string for a record in theVectorContainer
.void
rawTransferIn
(VectorContainer containerIn) void
void
void
Indicate the schema changed.void
setEmpty()
Safely set this container to an empty batch.void
setRecordCount
(int recordCount) void
setValueCount
(int valueCount) toString()
void
transferIn
(VectorContainer containerIn) Transfer vectors from containerIn to this.void
transferOut
(VectorContainer containerOut) Transfer vectors from this to containerOutvoid
Clears the contained vectors.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
wrappers
-
-
Constructor Details
-
VectorContainer
public VectorContainer() -
VectorContainer
-
VectorContainer
-
VectorContainer
Create a new vector container given a pre-defined schema. Creates the corresponding vectors, but does not allocate memory for them. CallallocateNew()
orallocateNewSafe()
to allocate memory.Note that this method does the equivalent of
buildSchema(SelectionVectorMode)
using the schema provided.- Parameters:
allocator
- allocator to be used to allocate memory laterschema
- the schema that defines the vectors to create
-
-
Method Details
-
toString
-
getAllocator
-
isSchemaChanged
public boolean isSchemaChanged() -
schemaChanged
public void schemaChanged()Indicate the schema changed. Normally set by mutating this container. If schemas are built externally, call this if the schema contained here is different than the one provided in a previous batch. (Some operators don't trust OK_NEW_SCHEMA, and use the schema changed flag for the "real" truth. -
addHyperList
-
addHyperList
-
transferIn
Transfer vectors from containerIn to this. -
rawTransferIn
-
transferOut
Transfer vectors from this to containerOut -
addOrGet
-
addOrGet
This method should be called with MaterializedField which also has correct children field list specially when the field type is MAP. Otherwise after calling this method if caller is not creating TransferPair on the ValueVector, then the new ValueVector will not have information about it's list of children MaterializedField.- Type Parameters:
T
-- Parameters:
field
-callBack
-- Returns:
-
addOrGet
-
getTransferClone
Get a set of transferred clones of this container. Note that this guarantees that the vectors in the cloned container have the same TypedFieldIds as the existing container, allowing interchangeability in generated code. In the case of hyper vectors, this container actually doesn't do a full transfer, rather creating a clone vector wrapper only.- Parameters:
incoming
- The RecordBatch iterator the contains the batch we should take over.- Returns:
- A cloned vector container.
-
getTransferClone
public static VectorContainer getTransferClone(VectorAccessible incoming, BufferAllocator allocator) -
getTransferClone
public static VectorContainer getTransferClone(VectorAccessible incoming, VectorWrapper<?>[] ignoreWrappers, OperatorContext oContext) -
addCollection
-
appendRow
This works with non-hyperVectorContainer
s which have no selection vectors. Appends a row taken from a sourceVectorContainer
to thisVectorContainer
.- Parameters:
srcContainer
- TheVectorContainer
to copy a row from.srcIndex
- The index of the row to copy from the sourceVectorContainer
.- Returns:
- Position one above where the row was appended
-
add
-
getLast
-
add
-
add
-
remove
-
getValueVectorId
Description copied from interface:VectorAccessible
Get the value vector type and id for the given schema path. The TypedFieldId should store a fieldId which is the same as the ordinal position of the field within the Iterator provided this classes implementation ofIterable<ValueVector>
.
- Specified by:
getValueVectorId
in interfaceVectorAccessible
- Parameters:
path
- the path where the vector should be located.- Returns:
- the local field id associated with this vector. If no field matches this path, this will return a null TypedFieldId
-
getValueVector
-
getValueAccessorById
- Specified by:
getValueAccessorById
in interfaceVectorAccessible
-
hasSchema
public boolean hasSchema() -
getSchema
Description copied from interface:VectorAccessible
Get the schema of the current RecordBatch. This changes if and only if a *_NEW_SCHEMA IterOutcome is provided.- Specified by:
getSchema
in interfaceVectorAccessible
- Returns:
- schema of the current batch
-
buildSchema
-
iterator
- Specified by:
iterator
in interfaceIterable<VectorWrapper<?>>
-
clear
public void clear() -
removeAll
public void removeAll() -
setRecordCount
public void setRecordCount(int recordCount) -
incRecordCount
public int incRecordCount()Increment the record count- Returns:
- the new record count
-
getRecordCount
public int getRecordCount()Description copied from interface:VectorAccessible
Get the number of records.- Specified by:
getRecordCount
in interfaceVectorAccessible
- Returns:
- number of records
-
hasRecordCount
public boolean hasRecordCount() -
getSelectionVector2
- Specified by:
getSelectionVector2
in interfaceVectorAccessible
-
getSelectionVector4
- Specified by:
getSelectionVector4
in interfaceVectorAccessible
-
zeroVectors
public void zeroVectors()Clears the contained vectors. (SeeValueVector.clear()
). Note that the name zeroVector() in a value vector is used for the action to set all vectors to zero. Here it means to free the vector's memory. Sigh... -
getNumberOfColumns
public int getNumberOfColumns() -
allocate
public void allocate(int recordCount) -
allocateNew
public void allocateNew() -
allocateNewSafe
public boolean allocateNewSafe() -
setValueCount
public void setValueCount(int valueCount) -
merge
Merge two batches to create a single, combined, batch. Vectors appear in the order defined byBatchSchema.merge(BatchSchema)
. The two batches must have identical row counts. The pattern is that this container is the main part of the record batch, the other represents new columns to merge.Reference counts on the underlying buffers are unchanged. The client code is assumed to abandon the two input containers in favor of the merged container.
- Parameters:
otherContainer
- the container to merge with this one- Returns:
- a new, merged, container
-
exchange
Exchange buffers between two identical vector containers. The schemas must be identical in both column schemas and order. That is, after this call, data is exchanged between the containers. Requires that both containers be owned by the same allocator.- Parameters:
other
- the target container with buffers to swap
-
prettyPrintRecord
This method create a pretty string for a record in theVectorContainer
.- Parameters:
index
- The index of the record of interest.- Returns:
- The string representation of a record.
-
setEmpty
public void setEmpty()Safely set this container to an empty batch. An empty batch is not fully empty: offset vectors must contain a single 0 entry in their first position. -
copySchemaFrom
-
buildFrom
-
allocatePrecomputedChildCount
public void allocatePrecomputedChildCount(int valueCount, int bytesPerValue, int childValCount)
-