KeyType
- type of the key that will be passed inpublic interface Grouper<KeyType> extends Closeable
VectorGrouper
for a vectorized version.Modifier and Type | Interface and Description |
---|---|
static interface |
Grouper.BufferComparator |
static interface |
Grouper.Entry<T> |
static interface |
Grouper.KeySerde<T>
Possibly-stateful object responsible for serde and comparison of keys.
|
static interface |
Grouper.KeySerdeFactory<T> |
Modifier and Type | Method and Description |
---|---|
default AggregateResult |
aggregate(KeyType key)
Aggregate the current row with the provided key.
|
AggregateResult |
aggregate(KeyType key,
int keyHash)
Aggregate the current row with the provided key.
|
void |
close()
Close the grouper and release associated resources.
|
default ToIntFunction<KeyType> |
hashFunction() |
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 |
reset()
Reset the grouper to its initial state.
|
void init()
aggregate(Object)
and aggregate(Object, int)
.boolean isInitialized()
AggregateResult aggregate(KeyType key, int keyHash)
key
- key objectkeyHash
- result of hashFunction()
on the keydefault AggregateResult aggregate(KeyType key)
key
- keyvoid reset()
default ToIntFunction<KeyType> hashFunction()
void close()
close
in interface AutoCloseable
close
in interface Closeable
CloseableIterator<Grouper.Entry<KeyType>> iterator(boolean sorted)
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.Entry
s immediately because some implementations can reuse the
key objects.
sorted
- return sorted resultsCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.