@Override public double metric(long owningBucketOrd) { if (valuesSource == null || owningBucketOrd >= maxes.size()) { return Double.NEGATIVE_INFINITY; } return maxes.get(owningBucketOrd); }
@Override public double metric(long owningBucketOrd) { if (valuesSource == null || owningBucketOrd >= sums.size()) { return 0.0; } return sums.get(owningBucketOrd); }
@Override public double metric(long owningBucketOrd) { if (valuesSource == null || owningBucketOrd >= mins.size()) { return Double.POSITIVE_INFINITY; } return mins.get(owningBucketOrd); }
@Override public double metric(long owningBucketOrd) { if (valuesSources == null || owningBucketOrd >= sums.size()) { return Double.NaN; } return sums.get(owningBucketOrd) / weights.get(owningBucketOrd); }
/** Grow an array to a size that is larger than <code>minSize</code>, * preserving content, and potentially reusing part of the provided array. */ public DoubleArray grow(DoubleArray array, long minSize) { if (minSize <= array.size()) { return array; } final long newSize = overSize(minSize, PageCacheRecycler.LONG_PAGE_SIZE, Long.BYTES); return resize(array, newSize); }
@Override public double metric(long owningBucketOrd) { if (valuesSource == null || owningBucketOrd >= sums.size()) { return Double.NaN; } return sums.get(owningBucketOrd) / counts.get(owningBucketOrd); }
@Override public void collect(int doc, long bucket) throws IOException { if (bucket >= maxes.size()) { long from = maxes.size(); maxes = bigArrays.grow(maxes, bucket + 1); maxes.fill(from, maxes.size(), Double.NEGATIVE_INFINITY); } if (values.advanceExact(doc)) { final double value = values.doubleValue(); double max = maxes.get(bucket); max = Math.max(max, value); maxes.set(bucket, max); } }
@Override public void collect(int doc, long bucket) throws IOException { if (bucket >= mins.size()) { long from = mins.size(); mins = bigArrays.grow(mins, bucket + 1); mins.fill(from, mins.size(), Double.POSITIVE_INFINITY); } if (values.advanceExact(doc)) { final double value = values.doubleValue(); double min = mins.get(bucket); min = Math.min(min, value); mins.set(bucket, min); } }
protected GeoBoundsAggregator(String name, SearchContext aggregationContext, Aggregator parent, ValuesSource.GeoPoint valuesSource, boolean wrapLongitude, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.wrapLongitude = wrapLongitude; if (valuesSource != null) { final BigArrays bigArrays = context.bigArrays(); tops = bigArrays.newDoubleArray(1, false); tops.fill(0, tops.size(), Double.NEGATIVE_INFINITY); bottoms = bigArrays.newDoubleArray(1, false); bottoms.fill(0, bottoms.size(), Double.POSITIVE_INFINITY); posLefts = bigArrays.newDoubleArray(1, false); posLefts.fill(0, posLefts.size(), Double.POSITIVE_INFINITY); posRights = bigArrays.newDoubleArray(1, false); posRights.fill(0, posRights.size(), Double.NEGATIVE_INFINITY); negLefts = bigArrays.newDoubleArray(1, false); negLefts.fill(0, negLefts.size(), Double.POSITIVE_INFINITY); negRights = bigArrays.newDoubleArray(1, false); negRights.fill(0, negRights.size(), Double.NEGATIVE_INFINITY); } }
/** Resize the array to the exact provided size. */ public DoubleArray resize(DoubleArray array, long size) { if (array instanceof BigDoubleArray) { return resizeInPlace((BigDoubleArray) array, size); } else { AbstractArray arr = (AbstractArray) array; final DoubleArray newArray = newDoubleArray(size, arr.clearOnResize); for (long i = 0, end = Math.min(size, array.size()); i < end; ++i) { newArray.set(i, array.get(i)); } array.close(); return newArray; } }
@Override public InternalAggregation buildAggregation(long bucket) { if (valuesSource == null || bucket >= sums.size()) { return buildEmptyAggregation(); } return new InternalSum(name, sums.get(bucket), format, pipelineAggregators(), metaData()); }
public StatsAggregator(String name, ValuesSource.Numeric valuesSource, DocValueFormat format, SearchContext context, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; if (valuesSource != null) { final BigArrays bigArrays = context.bigArrays(); counts = bigArrays.newLongArray(1, true); sums = bigArrays.newDoubleArray(1, true); compensations = bigArrays.newDoubleArray(1, true); mins = bigArrays.newDoubleArray(1, false); mins.fill(0, mins.size(), Double.POSITIVE_INFINITY); maxes = bigArrays.newDoubleArray(1, false); maxes.fill(0, maxes.size(), Double.NEGATIVE_INFINITY); } this.format = format; }
@Override public InternalAggregation buildAggregation(long bucket) { if (valuesSource == null || bucket >= mins.size()) { return buildEmptyAggregation(); } return new InternalMin(name, mins.get(bucket), format, pipelineAggregators(), metaData()); }
@Override public InternalAggregation buildAggregation(long bucket) { if (valuesSource == null || bucket >= maxes.size()) { return buildEmptyAggregation(); } return new InternalMax(name, maxes.get(bucket), formatter, pipelineAggregators(), metaData()); }
@Override public InternalAggregation buildAggregation(long bucket) { if (valuesSources == null || bucket >= sums.size()) { return buildEmptyAggregation(); } return new InternalWeightedAvg(name, sums.get(bucket), weights.get(bucket), format, pipelineAggregators(), metaData()); }
@Override public InternalAggregation buildAggregation(long bucket) { if (valuesSource == null || bucket >= sums.size()) { return buildEmptyAggregation(); } return new InternalAvg(name, sums.get(bucket), counts.get(bucket), format, pipelineAggregators(), metaData()); }
public ExtendedStatsAggregator(String name, ValuesSource.Numeric valuesSource, DocValueFormat formatter, SearchContext context, Aggregator parent, double sigma, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.format = formatter; this.sigma = sigma; if (valuesSource != null) { final BigArrays bigArrays = context.bigArrays(); counts = bigArrays.newLongArray(1, true); sums = bigArrays.newDoubleArray(1, true); compensations = bigArrays.newDoubleArray(1, true); mins = bigArrays.newDoubleArray(1, false); mins.fill(0, mins.size(), Double.POSITIVE_INFINITY); maxes = bigArrays.newDoubleArray(1, false); maxes.fill(0, maxes.size(), Double.NEGATIVE_INFINITY); sumOfSqrs = bigArrays.newDoubleArray(1, true); compensationOfSqrs = bigArrays.newDoubleArray(1, true); } }
@Override public InternalAggregation buildAggregation(long bucket) { if (valuesSource == null || bucket >= sums.size()) { return buildEmptyAggregation(); } return new InternalStats(name, counts.get(bucket), sums.get(bucket), mins.get(bucket), maxes.get(bucket), format, pipelineAggregators(), metaData()); }
MaxAggregator(String name, ValuesSourceConfig<ValuesSource.Numeric> config, ValuesSource.Numeric valuesSource, SearchContext context, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; if (valuesSource != null) { maxes = context.bigArrays().newDoubleArray(1, false); maxes.fill(0, maxes.size(), Double.NEGATIVE_INFINITY); } this.formatter = config.format(); this.pointConverter = getPointReaderOrNull(context, parent, config); if (pointConverter != null) { pointField = config.fieldContext().field(); } else { pointField = null; } }
MinAggregator(String name, ValuesSourceConfig<ValuesSource.Numeric> config, ValuesSource.Numeric valuesSource, SearchContext context, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; if (valuesSource != null) { mins = context.bigArrays().newDoubleArray(1, false); mins.fill(0, mins.size(), Double.POSITIVE_INFINITY); } this.format = config.format(); this.pointConverter = getPointReaderOrNull(context, parent, config); if (pointConverter != null) { pointField = config.fieldContext().field(); } else { pointField = null; } }