public class SpillingGrouper<KeyType extends Comparable<KeyType>> extends Object implements Grouper<KeyType>
BufferGrouper. Not thread-safe.
When the underlying grouper is full, its contents are sorted and written to temporary files using "spillMapper".Grouper.Entry<T>, Grouper.KeyComparator, Grouper.KeySerde<T>, Grouper.KeySerdeFactory<T>| Constructor and Description |
|---|
SpillingGrouper(ByteBuffer buffer,
Grouper.KeySerdeFactory<KeyType> keySerdeFactory,
ColumnSelectorFactory columnSelectorFactory,
AggregatorFactory[] aggregatorFactories,
int bufferGrouperMaxSize,
float bufferGrouperMaxLoadFactor,
int bufferGrouperInitialBuckets,
LimitedTemporaryStorage temporaryStorage,
com.fasterxml.jackson.databind.ObjectMapper spillMapper,
boolean spillingAllowed) |
| 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.
|
Iterator<Grouper.Entry<KeyType>> |
iterator(boolean sorted)
Iterate through entries.
|
void |
reset()
Reset the grouper to its initial state.
|
void |
setSpillingAllowed(boolean spillingAllowed) |
public SpillingGrouper(ByteBuffer buffer, Grouper.KeySerdeFactory<KeyType> keySerdeFactory, ColumnSelectorFactory columnSelectorFactory, AggregatorFactory[] aggregatorFactories, int bufferGrouperMaxSize, float bufferGrouperMaxLoadFactor, int bufferGrouperInitialBuckets, LimitedTemporaryStorage temporaryStorage, com.fasterxml.jackson.databind.ObjectMapper spillMapper, boolean spillingAllowed)
public boolean aggregate(KeyType key, int keyHash)
Grouperaggregate in interface Grouper<KeyType extends Comparable<KeyType>>key - key objectkeyHash - result of Groupers.hash(Object) on the keypublic boolean aggregate(KeyType key)
Grouperaggregate in interface Grouper<KeyType extends Comparable<KeyType>>key - keypublic void reset()
Grouperreset in interface Grouper<KeyType extends Comparable<KeyType>>public void close()
Grouperclose in interface Grouper<KeyType extends Comparable<KeyType>>close in interface Closeableclose in interface AutoCloseablepublic void setSpillingAllowed(boolean spillingAllowed)
public Iterator<Grouper.Entry<KeyType>> iterator(boolean sorted)
GrouperGrouper.close() (if you are done with the Grouper), Grouper.reset() (if you
want to reuse it), or Grouper.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 Grouper.KeySerde.comparator() on serialized objects. Woe be unto you
if these comparators are not equivalent.iterator in interface Grouper<KeyType extends Comparable<KeyType>>sorted - return sorted resultsCopyright © 2011–2016. All rights reserved.