use of org.apache.druid.hll.HyperLogLogCollector in project druid by druid-io.
the class HyperUniquesBufferAggregator method aggregate.
@Override
public void aggregate(ByteBuffer buf, int position) {
HyperLogLogCollector collector = (HyperLogLogCollector) selector.getObject();
if (collector == null) {
return;
}
// Save position, limit and restore later instead of allocating a new ByteBuffer object
final int oldPosition = buf.position();
final int oldLimit = buf.limit();
buf.limit(position + HyperLogLogCollector.getLatestNumBytesForDenseStorage());
buf.position(position);
try {
HyperLogLogCollector.makeCollector(buf).fold(collector);
} finally {
buf.limit(oldLimit);
buf.position(oldPosition);
}
}
use of org.apache.druid.hll.HyperLogLogCollector in project druid by druid-io.
the class HyperUniquesVectorAggregator method aggregate.
@Override
public void aggregate(final ByteBuffer buf, final int position, final int startRow, final 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();
buf.limit(position + HyperLogLogCollector.getLatestNumBytesForDenseStorage());
buf.position(position);
try {
final HyperLogLogCollector collector = HyperLogLogCollector.makeCollector(buf);
final Object[] vector = selector.getObjectVector();
for (int i = startRow; i < endRow; i++) {
final HyperLogLogCollector otherCollector = (HyperLogLogCollector) vector[i];
if (otherCollector != null) {
collector.fold(otherCollector);
}
}
} finally {
buf.limit(oldLimit);
buf.position(oldPosition);
}
}
use of org.apache.druid.hll.HyperLogLogCollector in project druid by druid-io.
the class HyperUniquesVectorAggregator method aggregate.
@Override
public void aggregate(final ByteBuffer buf, final int numRows, final int[] positions, @Nullable final int[] rows, final int positionOffset) {
final Object[] vector = selector.getObjectVector();
for (int i = 0; i < numRows; i++) {
final HyperLogLogCollector otherCollector = (HyperLogLogCollector) vector[rows != null ? rows[i] : i];
if (otherCollector == null) {
continue;
}
final int position = positions[i] + positionOffset;
// Save position, limit and restore later instead of allocating a new ByteBuffer object
final int oldPosition = buf.position();
final int oldLimit = buf.limit();
buf.limit(position + HyperLogLogCollector.getLatestNumBytesForDenseStorage());
buf.position(position);
try {
HyperLogLogCollector.makeCollector(buf).fold(otherCollector);
} finally {
buf.limit(oldLimit);
buf.position(oldPosition);
}
}
}
use of org.apache.druid.hll.HyperLogLogCollector in project druid by druid-io.
the class CardinalityBufferAggregator method aggregate.
@Override
public void aggregate(ByteBuffer buf, int position) {
// Save position, limit and restore later instead of allocating a new ByteBuffer object
final int oldPosition = buf.position();
final int oldLimit = buf.limit();
try {
buf.limit(position + HyperLogLogCollector.getLatestNumBytesForDenseStorage());
buf.position(position);
final HyperLogLogCollector collector = HyperLogLogCollector.makeCollector(buf);
if (byRow) {
CardinalityAggregator.hashRow(selectorPluses, collector);
} else {
CardinalityAggregator.hashValues(selectorPluses, collector);
}
} finally {
buf.limit(oldLimit);
buf.position(oldPosition);
}
}
use of org.apache.druid.hll.HyperLogLogCollector in project druid by druid-io.
the class HyperLogLogCollectorAggregateCombiner method fold.
@Override
public void fold(ColumnValueSelector selector) {
HyperLogLogCollector other = (HyperLogLogCollector) selector.getObject();
if (other == null) {
return;
}
if (combined == null) {
combined = HyperLogLogCollector.makeLatestCollector();
}
combined.fold(other);
}
Aggregations