Interface Grouper<KeyType>

    • Method Detail

      • isInitialized

        boolean isInitialized()
        Check this grouper is initialized or not.
        Returns:
        true if the grouper is already initialized, otherwise false.
      • aggregate

        AggregateResult aggregate​(KeyType key,
                                  int keyHash)
        Aggregate the current row with the provided key. Some implementations are thread-safe and some are not.
        Parameters:
        key - key object
        keyHash - result of hashFunction() on the key
        Returns:
        result that is ok if the row was aggregated, not ok if a resource limit was hit
      • aggregate

        default AggregateResult aggregate​(KeyType key)
        Aggregate the current row with the provided key. Some implementations are thread-safe and some are not.
        Parameters:
        key - key
        Returns:
        result that is ok if the row was aggregated, not ok if a resource limit was hit
      • reset

        void reset()
        Reset the grouper to its initial state.
      • close

        void close()
        Close the grouper and release associated resources.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
      • iterator

        CloseableIterator<Grouper.Entry<KeyType>> iterator​(boolean sorted)
        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 close() (if you are done with the Grouper) or reset() (if you want to reuse it). Some implementations allow calling 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