KeyType
- type of the key that will be passed inpublic interface Grouper<KeyType> extends Closeable
They work sort of like a map of KeyType to aggregated values, except they don't support random lookups.
Modifier and Type | Interface and Description |
---|---|
static class |
Grouper.Entry<T> |
static interface |
Grouper.KeyComparator |
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 |
---|---|
boolean |
aggregate(KeyType key)
Aggregate the current row with the provided key.
|
boolean |
aggregate(KeyType key,
int keyHash)
Aggregate the current row with the provided key.
|
void |
close()
Close the grouper and release associated resources.
|
void |
init()
Initialize the grouper.
|
boolean |
isInitialized()
Check this grouper is initialized or not.
|
Iterator<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()
boolean aggregate(KeyType key, int keyHash)
key
- key objectkeyHash
- result of Groupers.hash(Object)
on the keyboolean aggregate(KeyType key)
key
- keyvoid reset()
void close()
close
in interface AutoCloseable
close
in interface Closeable
Iterator<Grouper.Entry<KeyType>> iterator(boolean sorted)
Once this method is called, writes are no longer safe. After you are done with the iterator returned by this
method, you should either call close()
(if you are done with the Grouper), reset()
(if you
want to reuse it), or iterator(boolean)
again if you want another iterator.
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 KeySerde#comparator()
on serialized objects. Woe be unto you
if these comparators are not equivalent.
sorted
- return sorted resultsCopyright © 2011–2017. All rights reserved.