Class LimitedBufferHashGrouper<KeyType>
- java.lang.Object
-
- org.apache.druid.query.groupby.epinephelinae.AbstractBufferHashGrouper<KeyType>
-
- org.apache.druid.query.groupby.epinephelinae.LimitedBufferHashGrouper<KeyType>
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Grouper<KeyType>
public class LimitedBufferHashGrouper<KeyType> extends AbstractBufferHashGrouper<KeyType>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LimitedBufferHashGrouper.BufferGrouperOffsetHeapIndexUpdater
-
Nested classes/interfaces inherited from interface org.apache.druid.query.groupby.epinephelinae.Grouper
Grouper.BufferComparator, Grouper.Entry<T>, Grouper.KeySerde<T>, Grouper.KeySerdeFactory<T>
-
-
Field Summary
-
Fields inherited from class org.apache.druid.query.groupby.epinephelinae.AbstractBufferHashGrouper
aggregators, baseAggregatorOffset, bucketSize, bufferGrouperMaxSize, bufferSupplier, HASH_SIZE, hashTable, initialBuckets, keySerde, keySize, log, maxLoadFactor
-
-
Constructor Summary
Constructors Constructor 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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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)
-
Methods inherited from class org.apache.druid.query.groupby.epinephelinae.AbstractBufferHashGrouper
aggregate, close, getBuckets, getGrowthCount, getMaxSize, getSize, populateBucketEntryForOffset
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.query.groupby.epinephelinae.Grouper
aggregate, hashFunction
-
-
-
-
Constructor Detail
-
LimitedBufferHashGrouper
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)
-
-
Method Detail
-
init
public void init()
Description copied from interface:Grouper
Initialize the grouper. This method needs to be called before callingGrouper.aggregate(Object)
andGrouper.aggregate(Object, int)
.
-
isInitialized
public boolean isInitialized()
Description copied from interface:Grouper
Check this grouper is initialized or not.- Returns:
- true if the grouper is already initialized, otherwise false.
-
newBucketHook
public void newBucketHook(int bucketOffset)
Description copied from class:AbstractBufferHashGrouper
Called when a new bucket is used for an entry in the hash table. An implementing BufferHashGrouper class can use this to update its own state, e.g. tracking bucket offsets in a structure outside of the hash table.- Specified by:
newBucketHook
in classAbstractBufferHashGrouper<KeyType>
- Parameters:
bucketOffset
- offset of the new bucket, within the buffer returned by hashTable.getTableBuffer()
-
canSkipAggregate
public boolean canSkipAggregate(int bucketOffset)
Description copied from class:AbstractBufferHashGrouper
Called to check if it's possible to skip aggregation for a row.- Specified by:
canSkipAggregate
in classAbstractBufferHashGrouper<KeyType>
- Parameters:
bucketOffset
- Offset of the bucket containing this row's entry in the hash table, within the buffer returned by hashTable.getTableBuffer()- Returns:
- true if aggregation can be skipped, false otherwise.
-
afterAggregateHook
public void afterAggregateHook(int bucketOffset)
Description copied from class:AbstractBufferHashGrouper
Called after a row is aggregated. An implementing BufferHashGrouper class can use this to update its own state, e.g. reading the new aggregated values for the row's key and acting on that information.- Specified by:
afterAggregateHook
in classAbstractBufferHashGrouper<KeyType>
- Parameters:
bucketOffset
- Offset of the bucket containing the row that was aggregated, within the buffer returned by hashTable.getTableBuffer()
-
reset
public void reset()
Description copied from interface:Grouper
Reset the grouper to its initial state.
-
iterator
public CloseableIterator<Grouper.Entry<KeyType>> iterator(boolean sorted)
Description copied from interface:Grouper
Iterate through entries.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) orGrouper.reset()
(if you want to reuse it). Some implementations allow callingGrouper.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.- Parameters:
sorted
- return sorted results- Returns:
- entry iterator
-
getLimit
public int getLimit()
-
validateBufferCapacity
public boolean validateBufferCapacity(int bufferCapacity)
-
-