use of org.HdrHistogram.DoubleHistogram in project elasticsearch by elastic.
the class HDRPercentilesAggregator method buildEmptyAggregation.
@Override
public InternalAggregation buildEmptyAggregation() {
DoubleHistogram state;
state = new DoubleHistogram(numberOfSignificantValueDigits);
state.setAutoResize(true);
return new InternalHDRPercentiles(name, keys, state, keyed, format, pipelineAggregators(), metaData());
}
use of org.HdrHistogram.DoubleHistogram in project elasticsearch by elastic.
the class AbstractHDRPercentilesAggregator method getLeafCollector.
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException {
if (valuesSource == null) {
return LeafBucketCollector.NO_OP_COLLECTOR;
}
final BigArrays bigArrays = context.bigArrays();
final SortedNumericDoubleValues values = valuesSource.doubleValues(ctx);
return new LeafBucketCollectorBase(sub, values) {
@Override
public void collect(int doc, long bucket) throws IOException {
states = bigArrays.grow(states, bucket + 1);
DoubleHistogram state = states.get(bucket);
if (state == null) {
state = new DoubleHistogram(numberOfSignificantValueDigits);
// Set the histogram to autosize so it can resize itself as
// the data range increases. Resize operations should be
// rare as the histogram buckets are exponential (on the top
// level). In the future we could expose the range as an
// option on the request so the histogram can be fixed at
// initialisation and doesn't need resizing.
state.setAutoResize(true);
states.set(bucket, state);
}
values.setDocument(doc);
final int valueCount = values.count();
for (int i = 0; i < valueCount; i++) {
state.recordValue(values.valueAt(i));
}
}
};
}
use of org.HdrHistogram.DoubleHistogram in project elasticsearch by elastic.
the class AbstractInternalHDRPercentiles method doReduce.
@Override
public AbstractInternalHDRPercentiles doReduce(List<InternalAggregation> aggregations, ReduceContext reduceContext) {
DoubleHistogram merged = null;
for (InternalAggregation aggregation : aggregations) {
final AbstractInternalHDRPercentiles percentiles = (AbstractInternalHDRPercentiles) aggregation;
if (merged == null) {
merged = new DoubleHistogram(percentiles.state);
merged.setAutoResize(true);
}
merged.add(percentiles.state);
}
return createReduced(getName(), keys, merged, keyed, pipelineAggregators(), getMetaData());
}
use of org.HdrHistogram.DoubleHistogram in project elasticsearch by elastic.
the class HDRPercentileRanksAggregator method buildEmptyAggregation.
@Override
public InternalAggregation buildEmptyAggregation() {
DoubleHistogram state;
state = new DoubleHistogram(numberOfSignificantValueDigits);
state.setAutoResize(true);
return new InternalHDRPercentileRanks(name, keys, state, keyed, format, pipelineAggregators(), metaData());
}
use of org.HdrHistogram.DoubleHistogram in project elasticsearch by elastic.
the class InternalHDRPercentilesRanksTests method createTestInstance.
@Override
protected InternalHDRPercentileRanks createTestInstance(String name, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) {
double[] cdfValues = new double[] { 0.5 };
int numberOfSignificantValueDigits = 3;
DoubleHistogram state = new DoubleHistogram(numberOfSignificantValueDigits);
int numValues = randomInt(100);
for (int i = 0; i < numValues; ++i) {
state.recordValue(randomDouble());
}
boolean keyed = false;
DocValueFormat format = DocValueFormat.RAW;
return new InternalHDRPercentileRanks(name, cdfValues, state, keyed, format, pipelineAggregators, metaData);
}
Aggregations