Class BatchGroup
java.lang.Object
org.apache.drill.exec.physical.impl.xsort.BatchGroup
- All Implemented Interfaces:
AutoCloseable,Iterable<VectorWrapper<?>>,VectorAccessible
- Direct Known Subclasses:
InputBatch,SpilledRun
Represents a group of batches spilled to disk.
The batches are defined by a schema which can change over time. When the schema changes, all existing and new batches are coerced into the new schema. Provides a uniform way to iterate over records for one or more batches whether the batches are in memory or on disk.
The BatchGroup operates in two modes as given by the two
subclasses:
- Input mode
InputBatch: Used to buffer in-memory batches prior to spilling. - Spill mode
SpilledRun: Holds a "memento" to a set of batches written to disk. Acts as both a reader and writer for those batches.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BufferAllocatorprotected VectorContainerprotected intThis class acts as both "holder" for a vector container and an iterator into that container when the sort enters the merge phase.protected BatchSchema -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static voidcloseAll(Collection<? extends BatchGroup> groups) intintGet the number of records.Get the schema of the current RecordBatch.intgetValueAccessorById(Class<?> clazz, int... ids) getValueVectorId(SchemaPath path) Get the value vector type and id for the given schema path.iterator()voidsetSchema(BatchSchema schema) Updates the schema for this batch group.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
-
allocator
-
currentContainer
-
mergeIndex
protected int mergeIndexThis class acts as both "holder" for a vector container and an iterator into that container when the sort enters the merge phase. (This should be revisited.) This field keeps track of the next record to merge during the merge phase. -
schema
-
-
Constructor Details
-
BatchGroup
-
-
Method Details
-
setSchema
Updates the schema for this batch group. The current as well as any deserialized batches will be coerced to this schema.- Parameters:
schema-
-
getNextIndex
public int getNextIndex() -
getContainer
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
getValueAccessorById
- Specified by:
getValueAccessorByIdin interfaceVectorAccessible
-
getValueVectorId
Description 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 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
-
getSchema
Description 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 interfaceVectorAccessible- Returns:
- schema of the current batch
-
getRecordCount
public int getRecordCount()Description copied from interface:VectorAccessibleGet the number of records.- Specified by:
getRecordCountin interfaceVectorAccessible- Returns:
- number of records
-
getUnfilteredRecordCount
public int getUnfilteredRecordCount() -
iterator
- Specified by:
iteratorin interfaceIterable<VectorWrapper<?>>
-
getSelectionVector2
- Specified by:
getSelectionVector2in interfaceVectorAccessible
-
getSelectionVector4
- Specified by:
getSelectionVector4in interfaceVectorAccessible
-
closeAll
-