Interface Grouper<KeyType>
- Type Parameters:
KeyType- type of the key that will be passed in
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Subinterfaces:
IntGrouper
- All Known Implementing Classes:
AbstractBufferHashGrouper,BufferArrayGrouper,BufferHashGrouper,ConcurrentGrouper,LimitedBufferHashGrouper,SpillingGrouper,StreamingMergeSortedGrouper
VectorGrouper for a vectorized version.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interfacestatic interfacePossibly-stateful object responsible for serde and comparison of keys.static interface -
Method Summary
Modifier and TypeMethodDescriptiondefault AggregateResultAggregate the current row with the provided key.Aggregate the current row with the provided key.voidclose()Close the grouper and release associated resources.default ToIntFunction<KeyType> voidinit()Initialize the grouper.booleanCheck this grouper is initialized or not.iterator(boolean sorted) Iterate through entries.voidreset()Reset the grouper to its initial state.
-
Method Details
-
init
void init()Initialize the grouper. This method needs to be called before callingaggregate(Object)andaggregate(Object, int). -
isInitialized
boolean isInitialized()Check this grouper is initialized or not.- Returns:
- true if the grouper is already initialized, otherwise false.
-
aggregate
Aggregate the current row with the provided key. Some implementations are thread-safe and some are not.- Parameters:
key- key objectkeyHash- result ofhashFunction()on the key- Returns:
- result that is ok if the row was aggregated, not ok if a resource limit was hit
-
aggregate
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. -
hashFunction
-
close
void close()Close the grouper and release associated resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
iterator
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) orreset()(if you want to reuse it). Some implementations allow callingiterator(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
-