Class AbstractBufferHashGrouper<KeyType>
java.lang.Object
org.apache.druid.query.groupby.epinephelinae.AbstractBufferHashGrouper<KeyType>
- All Implemented Interfaces:
Closeable,AutoCloseable,Grouper<KeyType>
- Direct Known Subclasses:
BufferHashGrouper,LimitedBufferHashGrouper
-
Nested Class Summary
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
FieldsModifier and TypeFieldDescriptionprotected final AggregatorAdaptersprotected final intprotected intprotected final intprotected final com.google.common.base.Supplier<ByteBuffer> protected static final intprotected ByteBufferHashTableprotected ByteBufferprotected intprotected final Grouper.KeySerde<KeyType> protected final intprotected static final Loggerprotected float -
Constructor Summary
ConstructorsConstructorDescriptionAbstractBufferHashGrouper(com.google.common.base.Supplier<ByteBuffer> bufferSupplier, Grouper.KeySerde<KeyType> keySerde, AggregatorAdapters aggregators, int baseAggregatorOffset, int bufferGrouperMaxSize) -
Method Summary
Modifier and TypeMethodDescriptionabstract voidafterAggregateHook(int bucketOffset) Called after a row is aggregated.Aggregate the current row with the provided key.abstract booleancanSkipAggregate(int bucketOffset) Called to check if it's possible to skip aggregation for a row.voidclose()Close the grouper and release associated resources.intintintintgetSize()abstract voidnewBucketHook(int bucketOffset) Called when a new bucket is used for an entry in the hash table.protected Grouper.Entry<KeyType> populateBucketEntryForOffset(ReusableEntry<KeyType> reusableEntry, int bucketOffset) Populate aReusableEntrywith values from a particular bucket.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.druid.query.groupby.epinephelinae.Grouper
aggregate, hashFunction, init, isInitialized, iterator, reset
-
Field Details
-
HASH_SIZE
protected static final int HASH_SIZE- See Also:
-
log
-
bufferSupplier
-
keySerde
-
keySize
protected final int keySize -
aggregators
-
baseAggregatorOffset
protected final int baseAggregatorOffset -
bufferGrouperMaxSize
protected final int bufferGrouperMaxSize -
maxLoadFactor
protected float maxLoadFactor -
initialBuckets
protected int initialBuckets -
bucketSize
protected int bucketSize -
hashTable
-
hashTableBuffer
-
-
Constructor Details
-
AbstractBufferHashGrouper
public AbstractBufferHashGrouper(com.google.common.base.Supplier<ByteBuffer> bufferSupplier, Grouper.KeySerde<KeyType> keySerde, AggregatorAdapters aggregators, int baseAggregatorOffset, int bufferGrouperMaxSize)
-
-
Method Details
-
newBucketHook
public abstract void newBucketHook(int bucketOffset) 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.- Parameters:
bucketOffset- offset of the new bucket, within the buffer returned by hashTable.getTableBuffer()
-
canSkipAggregate
public abstract boolean canSkipAggregate(int bucketOffset) Called to check if it's possible to skip aggregation for a row.- 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 abstract void afterAggregateHook(int bucketOffset) 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.- Parameters:
bucketOffset- Offset of the bucket containing the row that was aggregated, within the buffer returned by hashTable.getTableBuffer()
-
getGrowthCount
public int getGrowthCount() -
getSize
public int getSize() -
getBuckets
public int getBuckets() -
getMaxSize
public int getMaxSize() -
aggregate
Description copied from interface:GrouperAggregate the current row with the provided key. Some implementations are thread-safe and some are not.- Specified by:
aggregatein interfaceGrouper<KeyType>- Parameters:
key- key objectkeyHash- result ofGrouper.hashFunction()on the key- Returns:
- result that is ok if the row was aggregated, not ok if a resource limit was hit
-
close
public void close()Description copied from interface:GrouperClose the grouper and release associated resources. -
populateBucketEntryForOffset
protected Grouper.Entry<KeyType> populateBucketEntryForOffset(ReusableEntry<KeyType> reusableEntry, int bucketOffset) Populate aReusableEntrywith values from a particular bucket.
-