public class PooledTopNAlgorithm extends BaseTopNAlgorithm<int[],BufferAggregator[],PooledTopNAlgorithm.PooledTopNParams>
TopNAlgorithm
is highly specialized for processing aggregates on string columns that are
ColumnCapabilities.isDictionaryEncoded()
and ColumnCapabilities.areDictionaryValuesUnique()
. This
algorithm is built around using a direct ByteBuffer
from the 'processing pool' of intermediary results
buffers, to aggregate using the dictionary id directly as the key, to defer looking up the value until is necessary.
At runtime, this implementation is specialized with wizardry to optimize for processing common top-n query shapes,
see computeSpecializedScanAndAggregateImplementations()
,
Generic1AggPooledTopNScanner
and Generic1AggPooledTopNScannerPrototype
,
Generic2AggPooledTopNScanner
and Generic2AggPooledTopNScannerPrototype
,
CalledFromHotLoop
,
HotLoopCallee
,
RuntimeShapeInspector
for more details.Modifier and Type | Class and Description |
---|---|
static class |
PooledTopNAlgorithm.PooledTopNParams |
BaseTopNAlgorithm.AggregatorArrayProvider, BaseTopNAlgorithm.BaseArrayProvider<T>
storageAdapter
EMPTY_ARRAY, INIT_POSITION_VALUE, SKIP_POSITION_VALUE
Constructor and Description |
---|
PooledTopNAlgorithm(StorageAdapter storageAdapter,
TopNQuery query,
NonBlockingPool<ByteBuffer> bufferPool) |
Modifier and Type | Method and Description |
---|---|
void |
cleanup(PooledTopNAlgorithm.PooledTopNParams params) |
protected void |
closeAggregators(BufferAggregator[] bufferAggregators) |
protected int |
computeNewLength(int[] dimValSelector,
int numProcessed,
int numToProcess)
Skip invalid value, calculate length to have enough valid value to process or hit the end.
|
protected BufferAggregator[] |
makeDimValAggregateStore(PooledTopNAlgorithm.PooledTopNParams params) |
protected int[] |
makeDimValSelector(PooledTopNAlgorithm.PooledTopNParams params,
int numProcessed,
int numToProcess) |
PooledTopNAlgorithm.PooledTopNParams |
makeInitParams(ColumnSelectorPlus selectorPlus,
Cursor cursor) |
protected long |
scanAndAggregate(PooledTopNAlgorithm.PooledTopNParams params,
int[] positions,
BufferAggregator[] theAggregators)
Returns the number of processed rows (i.
|
protected int[] |
updateDimValSelector(int[] dimValSelector,
int numProcessed,
int numToProcess) |
protected void |
updateResults(PooledTopNAlgorithm.PooledTopNParams params,
int[] positions,
BufferAggregator[] theAggregators,
TopNResultBuilder resultBuilder) |
makeAggregators, makeBufferAggregators, makeResultBuilder, run
public PooledTopNAlgorithm(StorageAdapter storageAdapter, TopNQuery query, NonBlockingPool<ByteBuffer> bufferPool)
public PooledTopNAlgorithm.PooledTopNParams makeInitParams(ColumnSelectorPlus selectorPlus, Cursor cursor)
protected int[] makeDimValSelector(PooledTopNAlgorithm.PooledTopNParams params, int numProcessed, int numToProcess)
makeDimValSelector
in class BaseTopNAlgorithm<int[],BufferAggregator[],PooledTopNAlgorithm.PooledTopNParams>
protected int computeNewLength(int[] dimValSelector, int numProcessed, int numToProcess)
BaseTopNAlgorithm
computeNewLength
in class BaseTopNAlgorithm<int[],BufferAggregator[],PooledTopNAlgorithm.PooledTopNParams>
dimValSelector
- the dim value selector which record value is valid or invalid.numProcessed
- the start position to processnumToProcess
- the number of valid value to processprotected int[] updateDimValSelector(int[] dimValSelector, int numProcessed, int numToProcess)
updateDimValSelector
in class BaseTopNAlgorithm<int[],BufferAggregator[],PooledTopNAlgorithm.PooledTopNParams>
protected BufferAggregator[] makeDimValAggregateStore(PooledTopNAlgorithm.PooledTopNParams params)
makeDimValAggregateStore
in class BaseTopNAlgorithm<int[],BufferAggregator[],PooledTopNAlgorithm.PooledTopNParams>
protected long scanAndAggregate(PooledTopNAlgorithm.PooledTopNParams params, int[] positions, BufferAggregator[] theAggregators)
BaseTopNAlgorithm
scanAndAggregate
in class BaseTopNAlgorithm<int[],BufferAggregator[],PooledTopNAlgorithm.PooledTopNParams>
protected void updateResults(PooledTopNAlgorithm.PooledTopNParams params, int[] positions, BufferAggregator[] theAggregators, TopNResultBuilder resultBuilder)
updateResults
in class BaseTopNAlgorithm<int[],BufferAggregator[],PooledTopNAlgorithm.PooledTopNParams>
protected void closeAggregators(BufferAggregator[] bufferAggregators)
closeAggregators
in class BaseTopNAlgorithm<int[],BufferAggregator[],PooledTopNAlgorithm.PooledTopNParams>
public void cleanup(PooledTopNAlgorithm.PooledTopNParams params)
Copyright © 2011–2021 The Apache Software Foundation. All rights reserved.