Class MSortTemplate
java.lang.Object
org.apache.drill.exec.physical.impl.xsort.MSortTemplate
- All Implemented Interfaces:
MSorter
,org.apache.hadoop.util.IndexedSortable
-
Field Summary
Fields inherited from interface org.apache.drill.exec.physical.impl.xsort.MSorter
TEMPLATE_DEFINITION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
int
compare
(int leftIndex, int rightIndex) abstract int
doEval
(int leftIndex, int rightIndex) abstract void
doSetup
(FragmentContext context, VectorContainer incoming, RecordBatch outgoing) getSV4()
static long
memoryNeeded
(int recordCount) For given recordCount how much memory does MSorter needs for its own purpose.protected int
merge
(int leftStart, int rightStart, int rightEnd, int outStart) Given two regions within the selection vector 4 (a left and a right), merge the two regions to produce a combined output region in the auxiliary selection vector.void
setup
(FragmentContext context, BufferAllocator allocator, SelectionVector4 vector4, VectorContainer hyperBatch, int outputBatchSize, int desiredBatchSize) void
sort()
Merge a set of pre-sorted runs to produce a combined result set.void
swap
(int sv0, int sv1)
-
Constructor Details
-
MSortTemplate
public MSortTemplate()
-
-
Method Details
-
setup
public void setup(FragmentContext context, BufferAllocator allocator, SelectionVector4 vector4, VectorContainer hyperBatch, int outputBatchSize, int desiredBatchSize) throws SchemaChangeException - Specified by:
setup
in interfaceMSorter
- Throws:
SchemaChangeException
-
memoryNeeded
public static long memoryNeeded(int recordCount) For given recordCount how much memory does MSorter needs for its own purpose. This is used in ExternalSortBatch to make decisions about whether to spill or not. -
merge
protected int merge(int leftStart, int rightStart, int rightEnd, int outStart) Given two regions within the selection vector 4 (a left and a right), merge the two regions to produce a combined output region in the auxiliary selection vector. -
getSV4
-
sort
public void sort()Merge a set of pre-sorted runs to produce a combined result set. Merging is done in the selection vector, record data does not move.Runs are merge pairwise in multiple passes, providing performance of O(n * m * log(n)), where n = number of runs, m = number of records per run.
-
swap
public void swap(int sv0, int sv1) - Specified by:
swap
in interfaceorg.apache.hadoop.util.IndexedSortable
-
compare
public int compare(int leftIndex, int rightIndex) - Specified by:
compare
in interfaceorg.apache.hadoop.util.IndexedSortable
-
clear
public void clear() -
doSetup
public abstract void doSetup(@Named("context") FragmentContext context, @Named("incoming") VectorContainer incoming, @Named("outgoing") RecordBatch outgoing) throws SchemaChangeException - Throws:
SchemaChangeException
-
doEval
public abstract int doEval(@Named("leftIndex") int leftIndex, @Named("rightIndex") int rightIndex) throws SchemaChangeException - Throws:
SchemaChangeException
-