public Bucket(String key, double from, double to, long docCount, List<InternalAggregation> aggregations, boolean keyed, DocValueFormat formatter) { super(key, from, to, docCount, new InternalAggregations(aggregations), keyed, formatter); }
Bucket(String key, double from, double to, long docCount, List<InternalAggregation> aggregations, boolean keyed) { this(key, from, to, docCount, new InternalAggregations(aggregations), keyed); }
/** * Required method to build the child aggregations of the given bucket (identified by the bucket ordinal). */ protected final InternalAggregations bucketAggregations(long bucket) throws IOException { final InternalAggregation[] aggregations = new InternalAggregation[subAggregators.length]; for (int i = 0; i < subAggregators.length; i++) { aggregations[i] = subAggregators[i].buildAggregation(bucket); } return new InternalAggregations(Arrays.asList(aggregations)); }
protected final InternalAggregations buildEmptySubAggregations() { List<InternalAggregation> aggs = new ArrayList<>(); for (Aggregator aggregator : subAggregators) { aggs.add(aggregator.buildEmptyAggregation()); } return new InternalAggregations(aggs); }
public static InternalAggregations readAggregations(StreamInput in) throws IOException { InternalAggregations result = new InternalAggregations(); result.readFrom(in); return result; }
/** * Utility method to build empty aggregations of the sub aggregators. */ protected final InternalAggregations bucketEmptyAggregations() { final InternalAggregation[] aggregations = new InternalAggregation[subAggregators.length]; for (int i = 0; i < subAggregators.length; i++) { aggregations[i] = subAggregators[i].buildEmptyAggregation(); } return new InternalAggregations(Arrays.asList(aggregations)); }
private static InternalAggregations reduceAggs(List<InternalAggregations> aggregationsList, List<SiblingPipelineAggregator> pipelineAggregators, ReduceContext reduceContext) { InternalAggregations aggregations = InternalAggregations.reduce(aggregationsList, reduceContext); if (pipelineAggregators != null) { List<InternalAggregation> newAggs = StreamSupport.stream(aggregations.spliterator(), false) .map((p) -> (InternalAggregation) p) .collect(Collectors.toList()); for (SiblingPipelineAggregator pipelineAggregator : pipelineAggregators) { InternalAggregation newAgg = pipelineAggregator.doReduce(new InternalAggregations(newAggs), reduceContext); newAggs.add(newAgg); } return new InternalAggregations(newAggs); } return aggregations; }
reducedAggregations.add(first.reduce(aggregations, context)); return new InternalAggregations(reducedAggregations);
}).collect(Collectors.toList()); aggs.add(aggToAdd); InternalMultiBucketAggregation.InternalBucket newBucket = multiBucketsAgg.createBucket(new InternalAggregations(aggs), bucket); newBuckets.add(newBucket); }).collect(Collectors.toList()); aggs.add(aggToAdd); return singleBucketAgg.create(new InternalAggregations(aggs)); } else { throw new IllegalStateException("Aggregation [" + aggregation.getName() + "] must be a bucket aggregation ["
@Override public InternalAggregation reduce(InternalAggregation aggregation, ReduceContext reduceContext) { InternalMultiBucketAggregation<? extends InternalMultiBucketAggregation, ? extends InternalMultiBucketAggregation.InternalBucket> histo = (InternalMultiBucketAggregation<? extends InternalMultiBucketAggregation, ? extends InternalMultiBucketAggregation.InternalBucket>) aggregation; List<? extends InternalMultiBucketAggregation.InternalBucket> buckets = histo.getBuckets(); HistogramFactory factory = (HistogramFactory) histo; List<Bucket> newBuckets = new ArrayList<>(buckets.size()); double sum = 0; for (InternalMultiBucketAggregation.InternalBucket bucket : buckets) { Double thisBucketValue = resolveBucketValue(histo, bucket, bucketsPaths()[0], GapPolicy.INSERT_ZEROS); // Only increment the sum if it's a finite value, otherwise "increment by zero" is correct if (thisBucketValue != null && thisBucketValue.isInfinite() == false && thisBucketValue.isNaN() == false) { sum += thisBucketValue; } List<InternalAggregation> aggs = StreamSupport .stream(bucket.getAggregations().spliterator(), false) .map((p) -> (InternalAggregation) p) .collect(Collectors.toList()); aggs.add(new InternalSimpleValue(name(), sum, formatter, new ArrayList<>(), metaData())); Bucket newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs)); newBuckets.add(newBucket); } return factory.createAggregation(newBuckets); } }
(p) -> (InternalAggregation) p).collect(Collectors.toList()); aggs.add(new InternalSimpleValue(name(), returned.doubleValue(), formatter, new ArrayList<>(), metaData())); InternalMultiBucketAggregation.InternalBucket newBucket = originalAgg.createBucket(new InternalAggregations(aggs), bucket); newBuckets.add(newBucket);
}).collect(Collectors.toList()); aggs.add(new InternalDerivative(name(), gradient, xDiff, formatter, new ArrayList<PipelineAggregator>(), metaData())); Bucket newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs)); newBuckets.add(newBucket); } else {
(p) -> (InternalAggregation) p).collect(Collectors.toList()); aggs.add(new InternalSimpleValue(name(), diff, formatter, new ArrayList<>(), metaData())); newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs));
}).collect(Collectors.toList()); aggs.add(new InternalSimpleValue(name(), movavg, formatter, new ArrayList<PipelineAggregator>(), metaData())); newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs)); aggs.add(new InternalSimpleValue(name(), predictions[i], formatter, new ArrayList<PipelineAggregator>(), metaData())); Bucket newBucket = factory.createBucket(newKey, bucket.getDocCount(), new InternalAggregations(aggs)); aggs.add(new InternalSimpleValue(name(), predictions[i], formatter, new ArrayList<PipelineAggregator>(), metaData())); Bucket newBucket = factory.createBucket(newKey, 0, new InternalAggregations(aggs));
.collect(Collectors.toList()); aggs.add(new InternalSimpleValue(name(), movavg, formatter, new ArrayList<>(), metaData())); newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs)); values.offer(thisBucketValue);
context.queryResult().aggregations(new InternalAggregations(aggregations)); try { List<PipelineAggregator> pipelineAggregators = context.aggregations().factories().createPipelineAggregators();
/** * Required method to build the child aggregations of the given bucket (identified by the bucket ordinal). */ protected final InternalAggregations bucketAggregations(long bucket) throws IOException { final InternalAggregation[] aggregations = new InternalAggregation[subAggregators.length]; for (int i = 0; i < subAggregators.length; i++) { aggregations[i] = subAggregators[i].buildAggregation(bucket); } return new InternalAggregations(Arrays.asList(aggregations)); }
/** * Required method to build the child aggregations of the given bucket (identified by the bucket ordinal). */ protected final InternalAggregations bucketAggregations(long bucket) throws IOException { final InternalAggregation[] aggregations = new InternalAggregation[subAggregators.length]; for (int i = 0; i < subAggregators.length; i++) { aggregations[i] = subAggregators[i].buildAggregation(bucket); } return new InternalAggregations(Arrays.asList(aggregations)); }
/** * Utility method to build empty aggregations of the sub aggregators. */ protected final InternalAggregations bucketEmptyAggregations() { final InternalAggregation[] aggregations = new InternalAggregation[subAggregators.length]; for (int i = 0; i < subAggregators.length; i++) { aggregations[i] = subAggregators[i].buildEmptyAggregation(); } return new InternalAggregations(Arrays.asList(aggregations)); }
public static InternalAggregations readAggregations(StreamInput in) throws IOException { InternalAggregations result = new InternalAggregations(); result.readFrom(in); return result; }