public class LimitedBufferHashGrouper<KeyType> extends AbstractBufferHashGrouper<KeyType>
Modifier and Type | Class and Description |
---|---|
static class |
LimitedBufferHashGrouper.BufferGrouperOffsetHeapIndexUpdater |
Grouper.BufferComparator, Grouper.Entry<T>, Grouper.KeySerde<T>, Grouper.KeySerdeFactory<T>
aggregators, baseAggregatorOffset, bucketSize, bufferGrouperMaxSize, bufferSupplier, HASH_SIZE, hashTable, initialBuckets, keySerde, keySize, log, maxLoadFactor
Constructor and Description |
---|
LimitedBufferHashGrouper(com.google.common.base.Supplier<ByteBuffer> bufferSupplier,
Grouper.KeySerde<KeyType> keySerde,
AggregatorAdapters aggregators,
int bufferGrouperMaxSize,
float maxLoadFactor,
int initialBuckets,
int limit,
boolean sortHasNonGroupingFields) |
Modifier and Type | Method and Description |
---|---|
void |
afterAggregateHook(int bucketOffset)
Called after a row is aggregated.
|
boolean |
canSkipAggregate(int bucketOffset)
Called to check if it's possible to skip aggregation for a row.
|
int |
getLimit() |
void |
init()
Initialize the grouper.
|
boolean |
isInitialized()
Check this grouper is initialized or not.
|
CloseableIterator<Grouper.Entry<KeyType>> |
iterator(boolean sorted)
Iterate through entries.
|
void |
newBucketHook(int bucketOffset)
Called when a new bucket is used for an entry in the hash table.
|
void |
reset()
Reset the grouper to its initial state.
|
boolean |
validateBufferCapacity(int bufferCapacity) |
aggregate, bucketEntryForOffset, close, getBuckets, getGrowthCount, getMaxSize, getSize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
aggregate, hashFunction
public LimitedBufferHashGrouper(com.google.common.base.Supplier<ByteBuffer> bufferSupplier, Grouper.KeySerde<KeyType> keySerde, AggregatorAdapters aggregators, int bufferGrouperMaxSize, float maxLoadFactor, int initialBuckets, int limit, boolean sortHasNonGroupingFields)
public void init()
Grouper
Grouper.aggregate(Object)
and Grouper.aggregate(Object, int)
.public boolean isInitialized()
Grouper
public void newBucketHook(int bucketOffset)
AbstractBufferHashGrouper
newBucketHook
in class AbstractBufferHashGrouper<KeyType>
bucketOffset
- offset of the new bucket, within the buffer returned by hashTable.getTableBuffer()public boolean canSkipAggregate(int bucketOffset)
AbstractBufferHashGrouper
canSkipAggregate
in class AbstractBufferHashGrouper<KeyType>
bucketOffset
- Offset of the bucket containing this row's entry in the hash table,
within the buffer returned by hashTable.getTableBuffer()public void afterAggregateHook(int bucketOffset)
AbstractBufferHashGrouper
afterAggregateHook
in class AbstractBufferHashGrouper<KeyType>
bucketOffset
- Offset of the bucket containing the row that was aggregated,
within the buffer returned by hashTable.getTableBuffer()public void reset()
Grouper
public CloseableIterator<Grouper.Entry<KeyType>> iterator(boolean sorted)
Grouper
Some implementations allow writes even after this method is called. After you are done with the iterator
returned by this method, you should either call Grouper.close()
(if you are done with the Grouper) or
Grouper.reset()
(if you want to reuse it). Some implementations allow calling Grouper.iterator(boolean)
again if
you want another iterator. But, this method must not be called by multiple threads concurrently.
If "sorted" is true then the iterator will return sorted results. It will use KeyType's natural ordering on
deserialized objects, and will use the Grouper.KeySerde.bufferComparator()
on serialized objects. Woe be unto you
if these comparators are not equivalent.
Callers must process and discard the returned Grouper.Entry
s immediately because some implementations can reuse the
key objects.
sorted
- return sorted resultspublic int getLimit()
public boolean validateBufferCapacity(int bufferCapacity)
Copyright © 2011–2021 The Apache Software Foundation. All rights reserved.