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 SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionVectorContainer(BufferAllocator allocator) VectorContainer(BufferAllocator allocator, BatchSchema schema) Create a new vector container given a pre-defined schema.VectorContainer(OperatorContext oContext) 
- 
Method SummaryModifier and TypeMethodDescriptionadd(ValueVector vv) voidadd(ValueVector[] hyperVector) voidadd(ValueVector[] hyperVector, boolean releasable) voidaddCollection(Iterable<ValueVector> vectors) voidaddHyperList(List<ValueVector> vectors) voidaddHyperList(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.voidallocate(int recordCount) voidbooleanvoidallocatePrecomputedChildCount(int valueCount, int bytesPerValue, int childValCount) intappendRow(VectorContainer srcContainer, int srcIndex) This works with non-hyperVectorContainers which have no selection vectors.voidbuildFrom(BatchSchema sourceSchema) voidvoidclear()voidcopySchemaFrom(VectorAccessible other) voidexchange(VectorContainer other) Exchange buffers between two identical vector containers.getLast()intintGet the number of records.Get the schema of the current RecordBatch.static VectorContainergetTransferClone(VectorAccessible incoming, BufferAllocator allocator) static VectorContainergetTransferClone(VectorAccessible incoming, OperatorContext oContext) Get a set of transferred clones of this container.static VectorContainergetTransferClone(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.booleanbooleanintIncrement the record countbooleaniterator()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.voidrawTransferIn(VectorContainer containerIn) voidvoidvoidIndicate the schema changed.voidsetEmpty()Safely set this container to an empty batch.voidsetRecordCount(int recordCount) voidsetValueCount(int valueCount) toString()voidtransferIn(VectorContainer containerIn) Transfer vectors from containerIn to this.voidtransferOut(VectorContainer containerOut) Transfer vectors from this to containerOutvoidClears the contained vectors.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Field Details- 
wrappers
 
- 
- 
Constructor Details- 
VectorContainerpublic VectorContainer()
- 
VectorContainer
- 
VectorContainer
- 
VectorContainerCreate 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 later
- schema- the schema that defines the vectors to create
 
 
- 
- 
Method Details- 
toString
- 
getAllocator
- 
isSchemaChangedpublic boolean isSchemaChanged()
- 
schemaChangedpublic 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
- 
transferInTransfer vectors from containerIn to this.
- 
rawTransferIn
- 
transferOutTransfer vectors from this to containerOut
- 
addOrGet
- 
addOrGetThis 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
- 
getTransferCloneGet 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.
 
- 
getTransferClonepublic static VectorContainer getTransferClone(VectorAccessible incoming, BufferAllocator allocator) 
- 
getTransferClonepublic static VectorContainer getTransferClone(VectorAccessible incoming, VectorWrapper<?>[] ignoreWrappers, OperatorContext oContext) 
- 
addCollection
- 
appendRowThis works with non-hyperVectorContainers which have no selection vectors. Appends a row taken from a sourceVectorContainerto thisVectorContainer.- Parameters:
- srcContainer- The- VectorContainerto copy a row from.
- srcIndex- The index of the row to copy from the source- VectorContainer.
- Returns:
- Position one above where the row was appended
 
- 
add
- 
getLast
- 
add
- 
add
- 
remove
- 
getValueVectorIdDescription copied from interface:VectorAccessibleGet 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:
- getValueVectorIdin interface- VectorAccessible
- 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:
- getValueAccessorByIdin interface- VectorAccessible
 
- 
hasSchemapublic boolean hasSchema()
- 
getSchemaDescription copied from interface:VectorAccessibleGet the schema of the current RecordBatch. This changes if and only if a *_NEW_SCHEMA IterOutcome is provided.- Specified by:
- getSchemain interface- VectorAccessible
- Returns:
- schema of the current batch
 
- 
buildSchema
- 
iterator- Specified by:
- iteratorin interface- Iterable<VectorWrapper<?>>
 
- 
clearpublic void clear()
- 
removeAllpublic void removeAll()
- 
setRecordCountpublic void setRecordCount(int recordCount) 
- 
incRecordCountpublic int incRecordCount()Increment the record count- Returns:
- the new record count
 
- 
getRecordCountpublic int getRecordCount()Description copied from interface:VectorAccessibleGet the number of records.- Specified by:
- getRecordCountin interface- VectorAccessible
- Returns:
- number of records
 
- 
hasRecordCountpublic boolean hasRecordCount()
- 
getSelectionVector2- Specified by:
- getSelectionVector2in interface- VectorAccessible
 
- 
getSelectionVector4- Specified by:
- getSelectionVector4in interface- VectorAccessible
 
- 
zeroVectorspublic 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...
- 
getNumberOfColumnspublic int getNumberOfColumns()
- 
allocatepublic void allocate(int recordCount) 
- 
allocateNewpublic void allocateNew()
- 
allocateNewSafepublic boolean allocateNewSafe()
- 
setValueCountpublic void setValueCount(int valueCount) 
- 
mergeMerge 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
 
- 
exchangeExchange 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
 
- 
prettyPrintRecordThis 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.
 
- 
setEmptypublic 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
- 
allocatePrecomputedChildCountpublic void allocatePrecomputedChildCount(int valueCount, int bytesPerValue, int childValCount) 
 
-