use of org.apache.druid.query.aggregation.ObjectAggregateCombiner in project druid by druid-io.
the class HllSketchAggregatorFactory method makeAggregateCombiner.
@Override
public AggregateCombiner makeAggregateCombiner() {
return new ObjectAggregateCombiner<HllSketch>() {
private final Union union = new Union(lgK);
@Override
public void reset(final ColumnValueSelector selector) {
union.reset();
fold(selector);
}
@Override
public void fold(final ColumnValueSelector selector) {
final HllSketch sketch = (HllSketch) selector.getObject();
union.update(sketch);
}
@Nullable
@Override
public HllSketch getObject() {
return union.getResult(tgtHllType);
}
@Override
public Class<HllSketch> classOfObject() {
return HllSketch.class;
}
};
}
use of org.apache.druid.query.aggregation.ObjectAggregateCombiner in project druid by druid-io.
the class DoublesSketchAggregatorFactory method makeAggregateCombiner.
@Override
public AggregateCombiner makeAggregateCombiner() {
return new ObjectAggregateCombiner<DoublesSketch>() {
private final DoublesUnion union = DoublesUnion.builder().setMaxK(k).build();
@Override
public void reset(final ColumnValueSelector selector) {
union.reset();
fold(selector);
}
@Override
public void fold(final ColumnValueSelector selector) {
final DoublesSketch sketch = (DoublesSketch) selector.getObject();
union.update(sketch);
}
@Nullable
@Override
public DoublesSketch getObject() {
return union.getResult();
}
@Override
public Class<DoublesSketch> classOfObject() {
return DoublesSketch.class;
}
};
}
use of org.apache.druid.query.aggregation.ObjectAggregateCombiner in project druid by druid-io.
the class TDigestSketchAggregatorFactory method makeAggregateCombiner.
@Override
public AggregateCombiner makeAggregateCombiner() {
return new ObjectAggregateCombiner<MergingDigest>() {
private MergingDigest combined = new MergingDigest(compression);
@Override
public void reset(final ColumnValueSelector selector) {
combined = null;
fold(selector);
}
@Override
public void fold(final ColumnValueSelector selector) {
MergingDigest other = (MergingDigest) selector.getObject();
if (other == null) {
return;
}
if (combined == null) {
combined = new MergingDigest(compression);
}
combined.add(other);
}
@Nullable
@Override
public MergingDigest getObject() {
return combined;
}
@Override
public Class<MergingDigest> classOfObject() {
return MergingDigest.class;
}
};
}
use of org.apache.druid.query.aggregation.ObjectAggregateCombiner in project druid by druid-io.
the class ArrayOfDoublesSketchAggregatorFactory method makeAggregateCombiner.
@Override
public AggregateCombiner makeAggregateCombiner() {
return new ObjectAggregateCombiner<ArrayOfDoublesSketch>() {
private final ArrayOfDoublesUnion union = new ArrayOfDoublesSetOperationBuilder().setNominalEntries(nominalEntries).setNumberOfValues(numberOfValues).buildUnion();
@Override
public void reset(final ColumnValueSelector selector) {
union.reset();
fold(selector);
}
@Override
public void fold(final ColumnValueSelector selector) {
final ArrayOfDoublesSketch sketch = (ArrayOfDoublesSketch) selector.getObject();
union.union(sketch);
}
@Override
public ArrayOfDoublesSketch getObject() {
return union.getResult();
}
@Override
public Class<ArrayOfDoublesSketch> classOfObject() {
return ArrayOfDoublesSketch.class;
}
};
}
Aggregations