Class LimitedBufferHashGrouper<KeyType>

    • 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

      • 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 class AbstractBufferHashGrouper<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 class AbstractBufferHashGrouper<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 class AbstractBufferHashGrouper<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) 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.Entrys 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)