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
Modifier and TypeFieldDescriptionprotected final BufferAllocator
protected VectorContainer
protected int
This 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static void
closeAll
(Collection<? extends BatchGroup> groups) int
int
Get the number of records.Get the schema of the current RecordBatch.int
getValueAccessorById
(Class<?> clazz, int... ids) getValueVectorId
(SchemaPath path) Get the value vector type and id for the given schema path.iterator()
void
setSchema
(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, wait
Methods 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:
close
in interfaceAutoCloseable
- Throws:
IOException
-
getValueAccessorById
- Specified by:
getValueAccessorById
in interfaceVectorAccessible
-
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
-
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
-
getRecordCount
public int getRecordCount()Description copied from interface:VectorAccessible
Get the number of records.- Specified by:
getRecordCount
in interfaceVectorAccessible
- Returns:
- number of records
-
getUnfilteredRecordCount
public int getUnfilteredRecordCount() -
iterator
- Specified by:
iterator
in interfaceIterable<VectorWrapper<?>>
-
getSelectionVector2
- Specified by:
getSelectionVector2
in interfaceVectorAccessible
-
getSelectionVector4
- Specified by:
getSelectionVector4
in interfaceVectorAccessible
-
closeAll
-