public class BufferArrayGrouper extends Object implements IntGrouper
The buffer is divided into 2 separate regions, i.e., used flag buffer and value buffer. The used flag buffer is a
bit set to represent which keys are valid. If a bit of an index is set, that key is valid. Finally, the value
buffer is used to store aggregated values. The first index is reserved for
GroupByColumnSelectorStrategy.GROUP_BY_MISSING_VALUE
.
This grouper is available only when the grouping key is a single indexed dimension of a known cardinality because it directly uses the dimension value as the index for array access. Since the cardinality for the grouping key across different segments cannot be currently retrieved, this grouper can be used only when performing per-segment query execution.
IntGrouper.IntGrouperHashFunction
Grouper.BufferComparator, Grouper.Entry<T>, Grouper.KeySerde<T>, Grouper.KeySerdeFactory<T>
Constructor and Description |
---|
BufferArrayGrouper(com.google.common.base.Supplier<ByteBuffer> bufferSupplier,
ColumnSelectorFactory columnSelectorFactory,
AggregatorFactory[] aggregatorFactories,
int cardinality) |
Modifier and Type | Method and Description |
---|---|
AggregateResult |
aggregateKeyHash(int dimIndex) |
void |
close()
Close the grouper and release associated resources.
|
IntGrouper.IntGrouperHashFunction |
hashFunction() |
void |
init()
Initialize the grouper.
|
boolean |
isInitialized()
Check this grouper is initialized or not.
|
CloseableIterator<Grouper.Entry<Integer>> |
iterator(boolean sorted)
Iterate through entries.
|
void |
reset()
Reset the grouper to its initial state.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
aggregate, aggregate, aggregate
public BufferArrayGrouper(com.google.common.base.Supplier<ByteBuffer> bufferSupplier, ColumnSelectorFactory columnSelectorFactory, AggregatorFactory[] aggregatorFactories, int cardinality)
public void init()
Grouper
Grouper.aggregate(Object)
and Grouper.aggregate(Object, int)
.public boolean isInitialized()
Grouper
isInitialized
in interface Grouper<Integer>
public AggregateResult aggregateKeyHash(int dimIndex)
aggregateKeyHash
in interface IntGrouper
public void reset()
Grouper
public IntGrouper.IntGrouperHashFunction hashFunction()
hashFunction
in interface Grouper<Integer>
hashFunction
in interface IntGrouper
public void close()
Grouper
public CloseableIterator<Grouper.Entry<Integer>> iterator(boolean sorted)
Grouper
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 Grouper.close()
(if you are done with the Grouper) or
Grouper.reset()
(if you want to reuse it). Some implementations allow calling Grouper.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 KeySerde#comparator()
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.
Copyright © 2011–2018. All rights reserved.