Search in sources :

Example 1 with DoubleHistogram

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());
}
Also used : DoubleHistogram(org.HdrHistogram.DoubleHistogram)

Example 2 with DoubleHistogram

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));
            }
        }
    };
}
Also used : BigArrays(org.elasticsearch.common.util.BigArrays) DoubleHistogram(org.HdrHistogram.DoubleHistogram) LeafBucketCollectorBase(org.elasticsearch.search.aggregations.LeafBucketCollectorBase) SortedNumericDoubleValues(org.elasticsearch.index.fielddata.SortedNumericDoubleValues)

Example 3 with DoubleHistogram

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());
}
Also used : InternalAggregation(org.elasticsearch.search.aggregations.InternalAggregation) DoubleHistogram(org.HdrHistogram.DoubleHistogram)

Example 4 with DoubleHistogram

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());
}
Also used : DoubleHistogram(org.HdrHistogram.DoubleHistogram)

Example 5 with DoubleHistogram

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);
}
Also used : DoubleHistogram(org.HdrHistogram.DoubleHistogram) DocValueFormat(org.elasticsearch.search.DocValueFormat) InternalHDRPercentileRanks(org.elasticsearch.search.aggregations.metrics.percentiles.hdr.InternalHDRPercentileRanks)

Aggregations

DoubleHistogram (org.HdrHistogram.DoubleHistogram)5 BigArrays (org.elasticsearch.common.util.BigArrays)1 SortedNumericDoubleValues (org.elasticsearch.index.fielddata.SortedNumericDoubleValues)1 DocValueFormat (org.elasticsearch.search.DocValueFormat)1 InternalAggregation (org.elasticsearch.search.aggregations.InternalAggregation)1 LeafBucketCollectorBase (org.elasticsearch.search.aggregations.LeafBucketCollectorBase)1 InternalHDRPercentileRanks (org.elasticsearch.search.aggregations.metrics.percentiles.hdr.InternalHDRPercentileRanks)1