use of org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesSketchIterator in project druid by druid-io.
the class ArrayOfDoublesSketchToVariancesPostAggregator method compute.
@Override
public double[] compute(final Map<String, Object> combinedAggregators) {
final ArrayOfDoublesSketch sketch = (ArrayOfDoublesSketch) getField().compute(combinedAggregators);
final SummaryStatistics[] stats = new SummaryStatistics[sketch.getNumValues()];
Arrays.setAll(stats, i -> new SummaryStatistics());
final ArrayOfDoublesSketchIterator it = sketch.iterator();
while (it.next()) {
final double[] values = it.getValues();
for (int i = 0; i < values.length; i++) {
stats[i].addValue(values[i]);
}
}
final double[] variances = new double[sketch.getNumValues()];
Arrays.setAll(variances, i -> stats[i].getVariance());
return variances;
}
use of org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesSketchIterator in project druid by druid-io.
the class ArrayOfDoublesSketchTTestPostAggregator method getStats.
private static SummaryStatistics[] getStats(final ArrayOfDoublesSketch sketch) {
final SummaryStatistics[] stats = new SummaryStatistics[sketch.getNumValues()];
Arrays.setAll(stats, i -> new SummaryStatistics());
final ArrayOfDoublesSketchIterator it = sketch.iterator();
while (it.next()) {
final double[] values = it.getValues();
for (int i = 0; i < values.length; i++) {
stats[i].addValue(values[i]);
}
}
return stats;
}
use of org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesSketchIterator in project druid by druid-io.
the class ArrayOfDoublesSketchToMeansPostAggregator method compute.
@Override
public double[] compute(final Map<String, Object> combinedAggregators) {
final ArrayOfDoublesSketch sketch = (ArrayOfDoublesSketch) getField().compute(combinedAggregators);
final SummaryStatistics[] stats = new SummaryStatistics[sketch.getNumValues()];
Arrays.setAll(stats, i -> new SummaryStatistics());
final ArrayOfDoublesSketchIterator it = sketch.iterator();
while (it.next()) {
final double[] values = it.getValues();
for (int i = 0; i < values.length; i++) {
stats[i].addValue(values[i]);
}
}
final double[] means = new double[sketch.getNumValues()];
Arrays.setAll(means, i -> stats[i].getMean());
return means;
}
use of org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesSketchIterator in project druid by druid-io.
the class ArrayOfDoublesSketchToQuantilesSketchPostAggregator method compute.
@Override
public DoublesSketch compute(final Map<String, Object> combinedAggregators) {
final ArrayOfDoublesSketch sketch = (ArrayOfDoublesSketch) getField().compute(combinedAggregators);
final UpdateDoublesSketch qs = DoublesSketch.builder().setK(k).build();
final ArrayOfDoublesSketchIterator it = sketch.iterator();
while (it.next()) {
// convert 1-based column number to zero-based index
qs.update(it.getValues()[column - 1]);
}
return qs;
}
Aggregations