use of org.apache.druid.hll.HyperLogLogCollector in project druid by druid-io.
the class DoubleCardinalityVectorProcessor method aggregate.
@Override
public void aggregate(ByteBuffer buf, int position, int startRow, int endRow) {
// Save position, limit and restore later instead of allocating a new ByteBuffer object
final int oldPosition = buf.position();
final int oldLimit = buf.limit();
try {
final double[] vector = selector.getDoubleVector();
final boolean[] nullVector = selector.getNullVector();
buf.limit(position + HyperLogLogCollector.getLatestNumBytesForDenseStorage());
buf.position(position);
final HyperLogLogCollector collector = HyperLogLogCollector.makeCollector(buf);
for (int i = startRow; i < endRow; i++) {
if (NullHandling.replaceWithDefault() || nullVector == null || !nullVector[i]) {
DoubleCardinalityAggregatorColumnSelectorStrategy.addDoubleToCollector(collector, vector[i]);
}
}
} finally {
buf.limit(oldLimit);
buf.position(oldPosition);
}
}
use of org.apache.druid.hll.HyperLogLogCollector in project druid by druid-io.
the class LongCardinalityVectorProcessor method aggregate.
@Override
public void aggregate(ByteBuffer buf, int position, int startRow, int endRow) {
// Save position, limit and restore later instead of allocating a new ByteBuffer object
final int oldPosition = buf.position();
final int oldLimit = buf.limit();
try {
final long[] vector = selector.getLongVector();
final boolean[] nullVector = selector.getNullVector();
buf.limit(position + HyperLogLogCollector.getLatestNumBytesForDenseStorage());
buf.position(position);
final HyperLogLogCollector collector = HyperLogLogCollector.makeCollector(buf);
for (int i = startRow; i < endRow; i++) {
if (NullHandling.replaceWithDefault() || nullVector == null || !nullVector[i]) {
LongCardinalityAggregatorColumnSelectorStrategy.addLongToCollector(collector, vector[i]);
}
}
} finally {
buf.limit(oldLimit);
buf.position(oldPosition);
}
}
use of org.apache.druid.hll.HyperLogLogCollector in project druid by druid-io.
the class SingleValueStringCardinalityVectorProcessor method aggregate.
@Override
public void aggregate(ByteBuffer buf, int position, int startRow, int endRow) {
// Save position, limit and restore later instead of allocating a new ByteBuffer object
final int oldPosition = buf.position();
final int oldLimit = buf.limit();
try {
final int[] vector = selector.getRowVector();
buf.limit(position + HyperLogLogCollector.getLatestNumBytesForDenseStorage());
buf.position(position);
final HyperLogLogCollector collector = HyperLogLogCollector.makeCollector(buf);
for (int i = startRow; i < endRow; i++) {
final String value = selector.lookupName(vector[i]);
StringCardinalityAggregatorColumnSelectorStrategy.addStringToCollector(collector, value);
}
} finally {
buf.limit(oldLimit);
buf.position(oldPosition);
}
}
use of org.apache.druid.hll.HyperLogLogCollector in project druid by druid-io.
the class FloatCardinalityVectorProcessor method aggregate.
@Override
public void aggregate(ByteBuffer buf, int position, int startRow, int endRow) {
// Save position, limit and restore later instead of allocating a new ByteBuffer object
final int oldPosition = buf.position();
final int oldLimit = buf.limit();
try {
final float[] vector = selector.getFloatVector();
final boolean[] nullVector = selector.getNullVector();
buf.limit(position + HyperLogLogCollector.getLatestNumBytesForDenseStorage());
buf.position(position);
final HyperLogLogCollector collector = HyperLogLogCollector.makeCollector(buf);
for (int i = startRow; i < endRow; i++) {
if (NullHandling.replaceWithDefault() || nullVector == null || !nullVector[i]) {
FloatCardinalityAggregatorColumnSelectorStrategy.addFloatToCollector(collector, vector[i]);
}
}
} finally {
buf.limit(oldLimit);
buf.position(oldPosition);
}
}
use of org.apache.druid.hll.HyperLogLogCollector in project druid by druid-io.
the class MultiValueStringCardinalityVectorProcessor method aggregate.
@Override
public void aggregate(ByteBuffer buf, int position, int startRow, int endRow) {
// Save position, limit and restore later instead of allocating a new ByteBuffer object
final int oldPosition = buf.position();
final int oldLimit = buf.limit();
try {
final IndexedInts[] vector = selector.getRowVector();
buf.limit(position + HyperLogLogCollector.getLatestNumBytesForDenseStorage());
buf.position(position);
final HyperLogLogCollector collector = HyperLogLogCollector.makeCollector(buf);
for (int i = startRow; i < endRow; i++) {
final IndexedInts ids = vector[i];
final int sz = ids.size();
for (int j = 0; j < sz; j++) {
final String value = selector.lookupName(ids.get(j));
StringCardinalityAggregatorColumnSelectorStrategy.addStringToCollector(collector, value);
}
}
} finally {
buf.limit(oldLimit);
buf.position(oldPosition);
}
}
Aggregations