Deduplicate Empty InternalAggregations (#58386)

Working through a heap dump for an unrelated issue I found that we can easily rack up
tens of MBs of duplicate empty instances in some cases.
I moved to a static constructor to guard against that in all cases.
This commit is contained in:
Armin Braun 2020-06-26 19:48:06 +02:00 committed by GitHub
parent 74f336c3c8
commit f20699ead5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 107 additions and 125 deletions

View file

@ -49,7 +49,7 @@ public class TransportNoopSearchAction extends HandledTransportAction<SearchRequ
listener.onResponse(new SearchResponse(new InternalSearchResponse( listener.onResponse(new SearchResponse(new InternalSearchResponse(
new SearchHits( new SearchHits(
new SearchHit[0], new TotalHits(0L, TotalHits.Relation.EQUAL_TO), 0.0f), new SearchHit[0], new TotalHits(0L, TotalHits.Relation.EQUAL_TO), 0.0f),
new InternalAggregations(Collections.emptyList()), InternalAggregations.EMPTY,
new Suggest(Collections.emptyList()), new Suggest(Collections.emptyList()),
new SearchProfileShardResults(Collections.emptyMap()), false, false, 1), new SearchProfileShardResults(Collections.emptyMap()), false, false, 1),
"", 1, 1, 0, 0, ShardSearchFailure.EMPTY_ARRAY, SearchResponse.Clusters.EMPTY)); "", 1, 1, 0, 0, ShardSearchFailure.EMPTY_ARRAY, SearchResponse.Clusters.EMPTY));

View file

@ -706,7 +706,7 @@ public final class SearchPhaseController {
InternalAggregations reduced = InternalAggregations reduced =
InternalAggregations.topLevelReduce(aggs, aggReduceContextBuilder.forPartialReduction()); InternalAggregations.topLevelReduce(aggs, aggReduceContextBuilder.forPartialReduction());
reducedAggs = aggsBuffer[0] = DelayableWriteable.referencing(reduced) reducedAggs = aggsBuffer[0] = DelayableWriteable.referencing(reduced)
.asSerialized(InternalAggregations::new, namedWriteableRegistry); .asSerialized(InternalAggregations::readFrom, namedWriteableRegistry);
long previousBufferSize = aggsCurrentBufferSize; long previousBufferSize = aggsCurrentBufferSize;
aggsMaxBufferSize = Math.max(aggsMaxBufferSize, aggsCurrentBufferSize); aggsMaxBufferSize = Math.max(aggsMaxBufferSize, aggsCurrentBufferSize);
aggsCurrentBufferSize = aggsBuffer[0].ramBytesUsed(); aggsCurrentBufferSize = aggsBuffer[0].ramBytesUsed();
@ -729,7 +729,7 @@ public final class SearchPhaseController {
} }
final int i = index++; final int i = index++;
if (hasAggs) { if (hasAggs) {
aggsBuffer[i] = querySearchResult.consumeAggs().asSerialized(InternalAggregations::new, namedWriteableRegistry); aggsBuffer[i] = querySearchResult.consumeAggs().asSerialized(InternalAggregations::readFrom, namedWriteableRegistry);
aggsCurrentBufferSize += aggsBuffer[i].ramBytesUsed(); aggsCurrentBufferSize += aggsBuffer[i].ramBytesUsed();
} }
if (hasTopDocs) { if (hasTopDocs) {

View file

@ -130,7 +130,7 @@ public class AggregationPhase implements SearchPhase {
throw new AggregationExecutionException("Failed to build aggregation [" + aggregator.name() + "]", e); throw new AggregationExecutionException("Failed to build aggregation [" + aggregator.name() + "]", e);
} }
} }
context.queryResult().aggregations(new InternalAggregations(aggregations)); context.queryResult().aggregations(InternalAggregations.from(aggregations));
// disable aggregations so that they don't run on next pages in case of scrolling // disable aggregations so that they don't run on next pages in case of scrolling
context.aggregations(null); context.aggregations(null);

View file

@ -259,7 +259,7 @@ public abstract class AggregatorBase extends Aggregator {
for (Aggregator aggregator : subAggregators) { for (Aggregator aggregator : subAggregators) {
aggs.add(aggregator.buildEmptyAggregation()); aggs.add(aggregator.buildEmptyAggregation());
} }
return new InternalAggregations(aggs); return InternalAggregations.from(aggs);
} }
@Override @Override

View file

@ -56,12 +56,19 @@ public final class InternalAggregations extends Aggregations implements Writeabl
/** /**
* Constructs a new aggregation. * Constructs a new aggregation.
*/ */
public InternalAggregations(List<InternalAggregation> aggregations) { private InternalAggregations(List<InternalAggregation> aggregations) {
super(aggregations); super(aggregations);
} }
public InternalAggregations(StreamInput in) throws IOException { public static InternalAggregations from(List<InternalAggregation> aggregations) {
super(in.readList(stream -> in.readNamedWriteable(InternalAggregation.class))); if (aggregations.isEmpty()) {
return EMPTY;
}
return new InternalAggregations(aggregations);
}
public static InternalAggregations readFrom(StreamInput in) throws IOException {
return from(in.readList(stream -> in.readNamedWriteable(InternalAggregation.class)));
} }
@Override @Override
@ -117,10 +124,10 @@ public final class InternalAggregations extends Aggregations implements Writeabl
for (PipelineAggregator pipelineAggregator : context.pipelineTreeRoot().aggregators()) { for (PipelineAggregator pipelineAggregator : context.pipelineTreeRoot().aggregators()) {
SiblingPipelineAggregator sib = (SiblingPipelineAggregator) pipelineAggregator; SiblingPipelineAggregator sib = (SiblingPipelineAggregator) pipelineAggregator;
InternalAggregation newAgg = sib.doReduce(new InternalAggregations(reducedInternalAggs), context); InternalAggregation newAgg = sib.doReduce(from(reducedInternalAggs), context);
reducedInternalAggs.add(newAgg); reducedInternalAggs.add(newAgg);
} }
return new InternalAggregations(reducedInternalAggs); return from(reducedInternalAggs);
} }
return reduced; return reduced;
} }
@ -157,6 +164,6 @@ public final class InternalAggregations extends Aggregations implements Writeabl
reducedAggregations.add(first.reduce(aggregations, context)); reducedAggregations.add(first.reduce(aggregations, context));
} }
return new InternalAggregations(reducedAggregations); return from(reducedAggregations);
} }
} }

View file

@ -192,7 +192,7 @@ public abstract class InternalMultiBucketAggregation<A extends InternalMultiBuck
PipelineTree subTree = pipelineTree.subTree(agg.getName()); PipelineTree subTree = pipelineTree.subTree(agg.getName());
aggs.add(((InternalAggregation)agg).reducePipelines((InternalAggregation)agg, reduceContext, subTree)); aggs.add(((InternalAggregation)agg).reducePipelines((InternalAggregation)agg, reduceContext, subTree));
} }
reducedBuckets.add(createBucket(new InternalAggregations(aggs), bucket)); reducedBuckets.add(createBucket(InternalAggregations.from(aggs), bucket));
} }
return reducedBuckets; return reducedBuckets;
} }

View file

@ -178,7 +178,7 @@ public abstract class BucketsAggregator extends AggregatorBase {
slice[i] = aggregations[i][ord]; slice[i] = aggregations[i][ord];
} }
final int thisOrd = ord; final int thisOrd = ord;
result[ord] = new InternalAggregations(new AbstractList<InternalAggregation>() { result[ord] = InternalAggregations.from(new AbstractList<InternalAggregation>() {
@Override @Override
public InternalAggregation get(int index) { public InternalAggregation get(int index) {
return aggregations[index][thisOrd]; return aggregations[index][thisOrd];
@ -353,17 +353,6 @@ public abstract class BucketsAggregator extends AggregatorBase {
InternalAggregation build(long owninigBucketOrd, List<B> buckets); InternalAggregation build(long owninigBucketOrd, List<B> buckets);
} }
/**
* 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));
}
@Override @Override
public final void close() { public final void close() {
try (Releasable releasable = docCounts) { try (Releasable releasable = docCounts) {

View file

@ -64,7 +64,7 @@ public abstract class InternalSingleBucketAggregation extends InternalAggregatio
protected InternalSingleBucketAggregation(StreamInput in) throws IOException { protected InternalSingleBucketAggregation(StreamInput in) throws IOException {
super(in); super(in);
docCount = in.readVLong(); docCount = in.readVLong();
aggregations = new InternalAggregations(in); aggregations = InternalAggregations.readFrom(in);
} }
@Override @Override
@ -128,7 +128,7 @@ public abstract class InternalSingleBucketAggregation extends InternalAggregatio
PipelineTree subTree = pipelineTree.subTree(agg.getName()); PipelineTree subTree = pipelineTree.subTree(agg.getName());
aggs.add(((InternalAggregation)agg).reducePipelines((InternalAggregation)agg, reduceContext, subTree)); aggs.add(((InternalAggregation)agg).reducePipelines((InternalAggregation)agg, reduceContext, subTree));
} }
InternalAggregations reducedSubAggs = new InternalAggregations(aggs); InternalAggregations reducedSubAggs = InternalAggregations.from(aggs);
reduced = create(reducedSubAggs); reduced = create(reducedSubAggs);
} }
return super.reducePipelines(reduced, reduceContext, pipelineTree); return super.reducePipelines(reduced, reduceContext, pipelineTree);

View file

@ -56,7 +56,7 @@ public class InternalAdjacencyMatrix
public InternalBucket(StreamInput in) throws IOException { public InternalBucket(StreamInput in) throws IOException {
key = in.readOptionalString(); key = in.readOptionalString();
docCount = in.readVLong(); docCount = in.readVLong();
aggregations = new InternalAggregations(in); aggregations = InternalAggregations.readFrom(in);
} }
@Override @Override

View file

@ -286,7 +286,7 @@ public class InternalComposite
InternalBucket(StreamInput in, List<String> sourceNames, List<DocValueFormat> formats, int[] reverseMuls) throws IOException { InternalBucket(StreamInput in, List<String> sourceNames, List<DocValueFormat> formats, int[] reverseMuls) throws IOException {
this.key = new CompositeKey(in); this.key = new CompositeKey(in);
this.docCount = in.readVLong(); this.docCount = in.readVLong();
this.aggregations = new InternalAggregations(in); this.aggregations = InternalAggregations.readFrom(in);
this.reverseMuls = reverseMuls; this.reverseMuls = reverseMuls;
this.sourceNames = sourceNames; this.sourceNames = sourceNames;
this.formats = formats; this.formats = formats;

View file

@ -56,7 +56,7 @@ public class InternalFilters extends InternalMultiBucketAggregation<InternalFilt
this.keyed = keyed; this.keyed = keyed;
key = in.readOptionalString(); key = in.readOptionalString();
docCount = in.readVLong(); docCount = in.readVLong();
aggregations = new InternalAggregations(in); aggregations = InternalAggregations.readFrom(in);
} }
@Override @Override

View file

@ -50,7 +50,7 @@ public abstract class InternalGeoGridBucket<B extends InternalGeoGridBucket>
public InternalGeoGridBucket(StreamInput in) throws IOException { public InternalGeoGridBucket(StreamInput in) throws IOException {
hashAsLong = in.readLong(); hashAsLong = in.readLong();
docCount = in.readVLong(); docCount = in.readVLong();
aggregations = new InternalAggregations(in); aggregations = InternalAggregations.readFrom(in);
} }
@Override @Override

View file

@ -72,7 +72,7 @@ public final class InternalAutoDateHistogram extends
this.format = format; this.format = format;
key = in.readLong(); key = in.readLong();
docCount = in.readVLong(); docCount = in.readVLong();
aggregations = new InternalAggregations(in); aggregations = InternalAggregations.readFrom(in);
} }
@Override @Override
@ -163,7 +163,7 @@ public final class InternalAutoDateHistogram extends
roundingInfos[i] = new RoundingInfo(in); roundingInfos[i] = new RoundingInfo(in);
} }
roundingIdx = in.readVInt(); roundingIdx = in.readVInt();
emptySubAggregations = new InternalAggregations(in); emptySubAggregations = InternalAggregations.readFrom(in);
} }
void writeTo(StreamOutput out) throws IOException { void writeTo(StreamOutput out) throws IOException {

View file

@ -76,7 +76,7 @@ public final class InternalDateHistogram extends InternalMultiBucketAggregation<
this.keyed = keyed; this.keyed = keyed;
key = in.readLong(); key = in.readLong();
docCount = in.readVLong(); docCount = in.readVLong();
aggregations = new InternalAggregations(in); aggregations = InternalAggregations.readFrom(in);
} }
@Override @Override
@ -174,7 +174,7 @@ public final class InternalDateHistogram extends InternalMultiBucketAggregation<
EmptyBucketInfo(StreamInput in) throws IOException { EmptyBucketInfo(StreamInput in) throws IOException {
rounding = Rounding.read(in); rounding = Rounding.read(in);
subAggregations = new InternalAggregations(in); subAggregations = InternalAggregations.readFrom(in);
bounds = in.readOptionalWriteable(ExtendedBounds::new); bounds = in.readOptionalWriteable(ExtendedBounds::new);
} }

View file

@ -72,7 +72,7 @@ public final class InternalHistogram extends InternalMultiBucketAggregation<Inte
this.keyed = keyed; this.keyed = keyed;
key = in.readDouble(); key = in.readDouble();
docCount = in.readVLong(); docCount = in.readVLong();
aggregations = new InternalAggregations(in); aggregations = InternalAggregations.readFrom(in);
} }
@Override @Override
@ -166,7 +166,7 @@ public final class InternalHistogram extends InternalMultiBucketAggregation<Inte
} }
EmptyBucketInfo(StreamInput in) throws IOException { EmptyBucketInfo(StreamInput in) throws IOException {
this(in.readDouble(), in.readDouble(), in.readDouble(), in.readDouble(), new InternalAggregations(in)); this(in.readDouble(), in.readDouble(), in.readDouble(), in.readDouble(), InternalAggregations.readFrom(in));
} }
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {

View file

@ -77,7 +77,7 @@ public final class InternalBinaryRange
BytesRef from = in.readBoolean() ? in.readBytesRef() : null; BytesRef from = in.readBoolean() ? in.readBytesRef() : null;
BytesRef to = in.readBoolean() ? in.readBytesRef() : null; BytesRef to = in.readBoolean() ? in.readBytesRef() : null;
long docCount = in.readLong(); long docCount = in.readLong();
InternalAggregations aggregations = new InternalAggregations(in); InternalAggregations aggregations = InternalAggregations.readFrom(in);
return new Bucket(format, keyed, key, from, to, docCount, aggregations); return new Bucket(format, keyed, key, from, to, docCount, aggregations);
} }

View file

@ -37,7 +37,7 @@ public class InternalDateRange extends InternalRange<InternalDateRange.Bucket, I
public Bucket(String key, double from, double to, long docCount, List<InternalAggregation> aggregations, boolean keyed, public Bucket(String key, double from, double to, long docCount, List<InternalAggregation> aggregations, boolean keyed,
DocValueFormat formatter) { DocValueFormat formatter) {
super(key, from, to, docCount, new InternalAggregations(aggregations), keyed, formatter); super(key, from, to, docCount, InternalAggregations.from(aggregations), keyed, formatter);
} }
public Bucket(String key, double from, double to, long docCount, InternalAggregations aggregations, boolean keyed, public Bucket(String key, double from, double to, long docCount, InternalAggregations aggregations, boolean keyed,

View file

@ -20,7 +20,6 @@ package org.elasticsearch.search.aggregations.bucket.range;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.aggregations.InternalAggregation;
import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.InternalAggregations;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValueType; import org.elasticsearch.search.aggregations.support.ValueType;
@ -35,10 +34,6 @@ public class InternalGeoDistance extends InternalRange<InternalGeoDistance.Bucke
static class Bucket extends InternalRange.Bucket { static class Bucket extends InternalRange.Bucket {
Bucket(String key, double from, double to, long docCount, List<InternalAggregation> aggregations, boolean keyed) {
this(key, from, to, docCount, new InternalAggregations(aggregations), keyed);
}
Bucket(String key, double from, double to, long docCount, InternalAggregations aggregations, boolean keyed) { Bucket(String key, double from, double to, long docCount, InternalAggregations aggregations, boolean keyed) {
super(key, from, to, docCount, aggregations, keyed, DocValueFormat.RAW); super(key, from, to, docCount, aggregations, keyed, DocValueFormat.RAW);
} }

View file

@ -241,7 +241,7 @@ public class InternalRange<B extends InternalRange.Bucket, R extends InternalRan
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
String key = in.readString(); String key = in.readString();
ranges.add(getFactory().createBucket(key, in.readDouble(), in.readDouble(), in.readVLong(), ranges.add(getFactory().createBucket(key, in.readDouble(), in.readDouble(), in.readVLong(),
new InternalAggregations(in), keyed, format)); InternalAggregations.readFrom(in), keyed, format));
} }
this.ranges = ranges; this.ranges = ranges;
} }

View file

@ -68,7 +68,7 @@ public abstract class InternalRareTerms<A extends InternalRareTerms<A, B>, B ext
protected Bucket(StreamInput in, DocValueFormat formatter) throws IOException { protected Bucket(StreamInput in, DocValueFormat formatter) throws IOException {
this.format = formatter; this.format = formatter;
docCount = in.readVLong(); docCount = in.readVLong();
aggregations = new InternalAggregations(in); aggregations = InternalAggregations.readFrom(in);
} }
@Override @Override

View file

@ -84,7 +84,7 @@ public abstract class InternalTerms<A extends InternalTerms<A, B>, B extends Int
if (showDocCountError) { if (showDocCountError) {
docCountError = in.readLong(); docCountError = in.readLong();
} }
aggregations = new InternalAggregations(in); aggregations = InternalAggregations.readFrom(in);
} }
@Override @Override

View file

@ -53,7 +53,7 @@ public class SignificantLongTerms extends InternalMappedSignificantTerms<Signifi
supersetDf = in.readVLong(); supersetDf = in.readVLong();
term = in.readLong(); term = in.readLong();
score = in.readDouble(); score = in.readDouble();
aggregations = new InternalAggregations(in); aggregations = InternalAggregations.readFrom(in);
} }
@Override @Override

View file

@ -57,7 +57,7 @@ public class SignificantStringTerms extends InternalMappedSignificantTerms<Signi
subsetDf = in.readVLong(); subsetDf = in.readVLong();
supersetDf = in.readVLong(); supersetDf = in.readVLong();
score = in.readDouble(); score = in.readDouble();
aggregations = new InternalAggregations(in); aggregations = InternalAggregations.readFrom(in);
} }
@Override @Override

View file

@ -89,7 +89,7 @@ public class BucketScriptPipelineAggregator extends PipelineAggregator {
InternalSimpleValue simpleValue = new InternalSimpleValue(name(), returned.doubleValue(), formatter, metadata()); InternalSimpleValue simpleValue = new InternalSimpleValue(name(), returned.doubleValue(), formatter, metadata());
aggs.add(simpleValue); aggs.add(simpleValue);
InternalMultiBucketAggregation.InternalBucket newBucket = originalAgg.createBucket(new InternalAggregations(aggs), InternalMultiBucketAggregation.InternalBucket newBucket = originalAgg.createBucket(InternalAggregations.from(aggs),
bucket); bucket);
newBuckets.add(newBucket); newBuckets.add(newBucket);
} }

View file

@ -66,7 +66,7 @@ public class CumulativeSumPipelineAggregator extends PipelineAggregator {
.map((p) -> (InternalAggregation) p) .map((p) -> (InternalAggregation) p)
.collect(Collectors.toList()); .collect(Collectors.toList());
aggs.add(new InternalSimpleValue(name(), sum, formatter, metadata())); aggs.add(new InternalSimpleValue(name(), sum, formatter, metadata()));
Bucket newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs)); Bucket newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), InternalAggregations.from(aggs));
newBuckets.add(newBucket); newBuckets.add(newBucket);
} }
return factory.createAggregation(newBuckets); return factory.createAggregation(newBuckets);

View file

@ -73,7 +73,7 @@ public class DerivativePipelineAggregator extends PipelineAggregator {
return (InternalAggregation) p; return (InternalAggregation) p;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
aggs.add(new InternalDerivative(name(), gradient, xDiff, formatter, metadata())); aggs.add(new InternalDerivative(name(), gradient, xDiff, formatter, metadata()));
Bucket newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs)); Bucket newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), InternalAggregations.from(aggs));
newBuckets.add(newBucket); newBuckets.add(newBucket);
} else { } else {
newBuckets.add(bucket); newBuckets.add(bucket);

View file

@ -122,7 +122,7 @@ public class MovFnPipelineAggregator extends PipelineAggregator {
.map(InternalAggregation.class::cast) .map(InternalAggregation.class::cast)
.collect(Collectors.toList()); .collect(Collectors.toList());
aggs.add(new InternalSimpleValue(name(), movavg, formatter, metadata())); aggs.add(new InternalSimpleValue(name(), movavg, formatter, metadata()));
newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs)); newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), InternalAggregations.from(aggs));
index++; index++;
} }
newBuckets.add(newBucket); newBuckets.add(newBucket);

View file

@ -89,7 +89,7 @@ public class SerialDiffPipelineAggregator extends PipelineAggregator {
List<InternalAggregation> aggs = StreamSupport.stream(bucket.getAggregations().spliterator(), false).map( List<InternalAggregation> aggs = StreamSupport.stream(bucket.getAggregations().spliterator(), false).map(
(p) -> (InternalAggregation) p).collect(Collectors.toList()); (p) -> (InternalAggregation) p).collect(Collectors.toList());
aggs.add(new InternalSimpleValue(name(), diff, formatter, metadata())); aggs.add(new InternalSimpleValue(name(), diff, formatter, metadata()));
newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs)); newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), InternalAggregations.from(aggs));
} }
newBuckets.add(newBucket); newBuckets.add(newBucket);

View file

@ -37,7 +37,7 @@ public abstract class SiblingPipelineAggregator extends PipelineAggregator {
return aggregation.copyWithRewritenBuckets(aggregations -> { return aggregation.copyWithRewritenBuckets(aggregations -> {
List<InternalAggregation> aggs = aggregations.copyResults(); List<InternalAggregation> aggs = aggregations.copyResults();
aggs.add(doReduce(aggregations, reduceContext)); aggs.add(doReduce(aggregations, reduceContext));
return new InternalAggregations(aggs); return InternalAggregations.from(aggs);
}); });
} }

View file

@ -52,7 +52,7 @@ public class InternalSearchResponse extends SearchResponseSections implements Wr
public InternalSearchResponse(StreamInput in) throws IOException { public InternalSearchResponse(StreamInput in) throws IOException {
super( super(
new SearchHits(in), new SearchHits(in),
in.readBoolean() ? new InternalAggregations(in) : null, in.readBoolean() ? InternalAggregations.readFrom(in) : null,
in.readBoolean() ? new Suggest(in) : null, in.readBoolean() ? new Suggest(in) : null,
in.readBoolean(), in.readBoolean(),
in.readOptionalBoolean(), in.readOptionalBoolean(),

View file

@ -316,7 +316,7 @@ public final class QuerySearchResult extends SearchPhaseResult {
} }
setTopDocs(readTopDocs(in)); setTopDocs(readTopDocs(in));
if (hasAggs = in.readBoolean()) { if (hasAggs = in.readBoolean()) {
aggregations = DelayableWriteable.delayed(InternalAggregations::new, in); aggregations = DelayableWriteable.delayed(InternalAggregations::readFrom, in);
} }
if (in.readBoolean()) { if (in.readBoolean()) {
suggest = new Suggest(in); suggest = new Suggest(in);

View file

@ -396,7 +396,7 @@ public class SearchPhaseControllerTests extends ESTestCase {
new SearchShardTarget("node", new ShardId("a", "b", 0), null, OriginalIndices.NONE)); new SearchShardTarget("node", new ShardId("a", "b", 0), null, OriginalIndices.NONE));
result.topDocs(new TopDocsAndMaxScore(new TopDocs(new TotalHits(0, TotalHits.Relation.EQUAL_TO), new ScoreDoc[0]), Float.NaN), result.topDocs(new TopDocsAndMaxScore(new TopDocs(new TotalHits(0, TotalHits.Relation.EQUAL_TO), new ScoreDoc[0]), Float.NaN),
new DocValueFormat[0]); new DocValueFormat[0]);
InternalAggregations aggs = new InternalAggregations(singletonList(new InternalMax("test", 1.0D, DocValueFormat.RAW, emptyMap()))); InternalAggregations aggs = InternalAggregations.from(singletonList(new InternalMax("test", 1.0D, DocValueFormat.RAW, emptyMap())));
result.aggregations(aggs); result.aggregations(aggs);
result.setShardIndex(0); result.setShardIndex(0);
consumer.consumeResult(result); consumer.consumeResult(result);
@ -405,7 +405,7 @@ public class SearchPhaseControllerTests extends ESTestCase {
new SearchShardTarget("node", new ShardId("a", "b", 0), null, OriginalIndices.NONE)); new SearchShardTarget("node", new ShardId("a", "b", 0), null, OriginalIndices.NONE));
result.topDocs(new TopDocsAndMaxScore(new TopDocs(new TotalHits(0, TotalHits.Relation.EQUAL_TO), new ScoreDoc[0]), Float.NaN), result.topDocs(new TopDocsAndMaxScore(new TopDocs(new TotalHits(0, TotalHits.Relation.EQUAL_TO), new ScoreDoc[0]), Float.NaN),
new DocValueFormat[0]); new DocValueFormat[0]);
aggs = new InternalAggregations(singletonList(new InternalMax("test", 3.0D, DocValueFormat.RAW, emptyMap()))); aggs = InternalAggregations.from(singletonList(new InternalMax("test", 3.0D, DocValueFormat.RAW, emptyMap())));
result.aggregations(aggs); result.aggregations(aggs);
result.setShardIndex(2); result.setShardIndex(2);
consumer.consumeResult(result); consumer.consumeResult(result);
@ -414,7 +414,7 @@ public class SearchPhaseControllerTests extends ESTestCase {
new SearchShardTarget("node", new ShardId("a", "b", 0), null, OriginalIndices.NONE)); new SearchShardTarget("node", new ShardId("a", "b", 0), null, OriginalIndices.NONE));
result.topDocs(new TopDocsAndMaxScore(new TopDocs(new TotalHits(0, TotalHits.Relation.EQUAL_TO), new ScoreDoc[0]), Float.NaN), result.topDocs(new TopDocsAndMaxScore(new TopDocs(new TotalHits(0, TotalHits.Relation.EQUAL_TO), new ScoreDoc[0]), Float.NaN),
new DocValueFormat[0]); new DocValueFormat[0]);
aggs = new InternalAggregations(singletonList(new InternalMax("test", 2.0D, DocValueFormat.RAW, emptyMap()))); aggs = InternalAggregations.from(singletonList(new InternalMax("test", 2.0D, DocValueFormat.RAW, emptyMap())));
result.aggregations(aggs); result.aggregations(aggs);
result.setShardIndex(1); result.setShardIndex(1);
consumer.consumeResult(result); consumer.consumeResult(result);
@ -483,7 +483,7 @@ public class SearchPhaseControllerTests extends ESTestCase {
result.topDocs(new TopDocsAndMaxScore( result.topDocs(new TopDocsAndMaxScore(
new TopDocs(new TotalHits(1, TotalHits.Relation.EQUAL_TO), new ScoreDoc[] {new ScoreDoc(0, number)}), number), new TopDocs(new TotalHits(1, TotalHits.Relation.EQUAL_TO), new ScoreDoc[] {new ScoreDoc(0, number)}), number),
new DocValueFormat[0]); new DocValueFormat[0]);
InternalAggregations aggs = new InternalAggregations(Collections.singletonList(new InternalMax("test", (double) number, InternalAggregations aggs = InternalAggregations.from(Collections.singletonList(new InternalMax("test", (double) number,
DocValueFormat.RAW, Collections.emptyMap()))); DocValueFormat.RAW, Collections.emptyMap())));
result.aggregations(aggs); result.aggregations(aggs);
result.setShardIndex(id); result.setShardIndex(id);
@ -526,7 +526,7 @@ public class SearchPhaseControllerTests extends ESTestCase {
new SearchShardTarget("node", new ShardId("a", "b", i), null, OriginalIndices.NONE)); new SearchShardTarget("node", new ShardId("a", "b", i), null, OriginalIndices.NONE));
result.topDocs(new TopDocsAndMaxScore(new TopDocs(new TotalHits(1, TotalHits.Relation.EQUAL_TO), new ScoreDoc[0]), number), result.topDocs(new TopDocsAndMaxScore(new TopDocs(new TotalHits(1, TotalHits.Relation.EQUAL_TO), new ScoreDoc[0]), number),
new DocValueFormat[0]); new DocValueFormat[0]);
InternalAggregations aggs = new InternalAggregations(Collections.singletonList(new InternalMax("test", (double) number, InternalAggregations aggs = InternalAggregations.from(Collections.singletonList(new InternalMax("test", (double) number,
DocValueFormat.RAW, Collections.emptyMap()))); DocValueFormat.RAW, Collections.emptyMap())));
result.aggregations(aggs); result.aggregations(aggs);
result.setShardIndex(i); result.setShardIndex(i);
@ -878,7 +878,7 @@ public class SearchPhaseControllerTests extends ESTestCase {
result.topDocs(new TopDocsAndMaxScore( result.topDocs(new TopDocsAndMaxScore(
new TopDocs(new TotalHits(1, TotalHits.Relation.EQUAL_TO), new ScoreDoc[]{new ScoreDoc(0, number)}), number), new TopDocs(new TotalHits(1, TotalHits.Relation.EQUAL_TO), new ScoreDoc[]{new ScoreDoc(0, number)}), number),
new DocValueFormat[0]); new DocValueFormat[0]);
InternalAggregations aggs = new InternalAggregations(Collections.singletonList( InternalAggregations aggs = InternalAggregations.from(Collections.singletonList(
new InternalMax("test", (double) number, DocValueFormat.RAW, Collections.emptyMap()))); new InternalMax("test", (double) number, DocValueFormat.RAW, Collections.emptyMap())));
result.aggregations(aggs); result.aggregations(aggs);
result.setShardIndex(id); result.setShardIndex(id);

View file

@ -370,7 +370,7 @@ public class SearchResponseMergerTests extends ESTestCase {
InternalDateRange.Bucket bucket = factory.createBucket("bucket", 0, 10000, count, InternalAggregations.EMPTY, InternalDateRange.Bucket bucket = factory.createBucket("bucket", 0, 10000, count, InternalAggregations.EMPTY,
false, DocValueFormat.RAW); false, DocValueFormat.RAW);
InternalDateRange range = factory.create(rangeAggName, singletonList(bucket), DocValueFormat.RAW, false, emptyMap()); InternalDateRange range = factory.create(rangeAggName, singletonList(bucket), DocValueFormat.RAW, false, emptyMap());
InternalAggregations aggs = new InternalAggregations(Arrays.asList(range, max)); InternalAggregations aggs = InternalAggregations.from(Arrays.asList(range, max));
SearchHits searchHits = new SearchHits(new SearchHit[0], null, Float.NaN); SearchHits searchHits = new SearchHits(new SearchHit[0], null, Float.NaN);
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(searchHits, aggs, null, null, false, null, 1); InternalSearchResponse internalSearchResponse = new InternalSearchResponse(searchHits, aggs, null, null, false, null, 1);
SearchResponse searchResponse = new SearchResponse(internalSearchResponse, null, 1, 1, 0, randomLong(), SearchResponse searchResponse = new SearchResponse(internalSearchResponse, null, 1, 1, 0, randomLong(),

View file

@ -298,6 +298,6 @@ public class AggregationsTests extends ESTestCase {
} }
aggs.add(testCase.createTestInstance()); aggs.add(testCase.createTestInstance());
} }
return new InternalAggregations(aggs); return InternalAggregations.from(aggs);
} }
} }

View file

@ -59,7 +59,7 @@ public class InternalAggregationsTests extends ESTestCase {
public void testNonFinalReduceTopLevelPipelineAggs() { public void testNonFinalReduceTopLevelPipelineAggs() {
InternalAggregation terms = new StringTerms("name", BucketOrder.key(true), InternalAggregation terms = new StringTerms("name", BucketOrder.key(true),
10, 1, Collections.emptyMap(), DocValueFormat.RAW, 25, false, 10, Collections.emptyList(), 0); 10, 1, Collections.emptyMap(), DocValueFormat.RAW, 25, false, 10, Collections.emptyList(), 0);
List<InternalAggregations> aggs = singletonList(new InternalAggregations(Collections.singletonList(terms))); List<InternalAggregations> aggs = singletonList(InternalAggregations.from(Collections.singletonList(terms)));
InternalAggregations reducedAggs = InternalAggregations.topLevelReduce(aggs, maxBucketReduceContext().forPartialReduction()); InternalAggregations reducedAggs = InternalAggregations.topLevelReduce(aggs, maxBucketReduceContext().forPartialReduction());
assertEquals(1, reducedAggs.aggregations.size()); assertEquals(1, reducedAggs.aggregations.size());
} }
@ -68,7 +68,7 @@ public class InternalAggregationsTests extends ESTestCase {
InternalAggregation terms = new StringTerms("name", BucketOrder.key(true), InternalAggregation terms = new StringTerms("name", BucketOrder.key(true),
10, 1, Collections.emptyMap(), DocValueFormat.RAW, 25, false, 10, Collections.emptyList(), 0); 10, 1, Collections.emptyMap(), DocValueFormat.RAW, 25, false, 10, Collections.emptyList(), 0);
InternalAggregations aggs = new InternalAggregations(Collections.singletonList(terms)); InternalAggregations aggs = InternalAggregations.from(Collections.singletonList(terms));
InternalAggregations reducedAggs = InternalAggregations.topLevelReduce(Collections.singletonList(aggs), InternalAggregations reducedAggs = InternalAggregations.topLevelReduce(Collections.singletonList(aggs),
maxBucketReduceContext().forFinalReduction()); maxBucketReduceContext().forFinalReduction());
assertEquals(2, reducedAggs.aggregations.size()); assertEquals(2, reducedAggs.aggregations.size());
@ -98,7 +98,7 @@ public class InternalAggregationsTests extends ESTestCase {
InternalSimpleValueTests simpleValueTests = new InternalSimpleValueTests(); InternalSimpleValueTests simpleValueTests = new InternalSimpleValueTests();
aggsList.add(simpleValueTests.createTestInstance()); aggsList.add(simpleValueTests.createTestInstance());
} }
return new InternalAggregations(aggsList); return InternalAggregations.from(aggsList);
} }
public void testSerialization() throws Exception { public void testSerialization() throws Exception {
@ -113,7 +113,7 @@ public class InternalAggregationsTests extends ESTestCase {
aggregations.writeTo(out); aggregations.writeTo(out);
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(out.bytes().toBytesRef().bytes), registry)) { try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(out.bytes().toBytesRef().bytes), registry)) {
in.setVersion(version); in.setVersion(version);
InternalAggregations deserialized = new InternalAggregations(in); InternalAggregations deserialized = InternalAggregations.readFrom(in);
assertEquals(aggregations.aggregations, deserialized.aggregations); assertEquals(aggregations.aggregations, deserialized.aggregations);
if (iteration < 2) { if (iteration < 2) {
writeToAndReadFrom(deserialized, iteration + 1); writeToAndReadFrom(deserialized, iteration + 1);

View file

@ -42,7 +42,7 @@ public class InternalMultiBucketAggregationTests extends ESTestCase {
AggregationPath path = AggregationPath.parse("the_avg"); AggregationPath path = AggregationPath.parse("the_avg");
List<LongTerms.Bucket> buckets = new ArrayList<>(); List<LongTerms.Bucket> buckets = new ArrayList<>();
InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap()); InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap());
InternalAggregations internalAggregations = new InternalAggregations(Collections.singletonList(agg)); InternalAggregations internalAggregations = InternalAggregations.from(Collections.singletonList(agg));
LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW); LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW);
buckets.add(bucket); buckets.add(bucket);
@ -55,7 +55,7 @@ public class InternalMultiBucketAggregationTests extends ESTestCase {
AggregationPath path = AggregationPath.parse("the_avg.value"); AggregationPath path = AggregationPath.parse("the_avg.value");
List<LongTerms.Bucket> buckets = new ArrayList<>(); List<LongTerms.Bucket> buckets = new ArrayList<>();
InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap()); InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap());
InternalAggregations internalAggregations = new InternalAggregations(Collections.singletonList(agg)); InternalAggregations internalAggregations = InternalAggregations.from(Collections.singletonList(agg));
LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW); LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW);
buckets.add(bucket); buckets.add(bucket);
@ -68,7 +68,7 @@ public class InternalMultiBucketAggregationTests extends ESTestCase {
AggregationPath path = AggregationPath.parse("foo.value"); AggregationPath path = AggregationPath.parse("foo.value");
List<LongTerms.Bucket> buckets = new ArrayList<>(); List<LongTerms.Bucket> buckets = new ArrayList<>();
InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap()); InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap());
InternalAggregations internalAggregations = new InternalAggregations(Collections.singletonList(agg)); InternalAggregations internalAggregations = InternalAggregations.from(Collections.singletonList(agg));
LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW); LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW);
buckets.add(bucket); buckets.add(bucket);
@ -82,7 +82,7 @@ public class InternalMultiBucketAggregationTests extends ESTestCase {
AggregationPath path = AggregationPath.parse("the_avg.unknown"); AggregationPath path = AggregationPath.parse("the_avg.unknown");
List<LongTerms.Bucket> buckets = new ArrayList<>(); List<LongTerms.Bucket> buckets = new ArrayList<>();
InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap()); InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap());
InternalAggregations internalAggregations = new InternalAggregations(Collections.singletonList(agg)); InternalAggregations internalAggregations = InternalAggregations.from(Collections.singletonList(agg));
LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW); LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW);
buckets.add(bucket); buckets.add(bucket);
@ -96,7 +96,7 @@ public class InternalMultiBucketAggregationTests extends ESTestCase {
AggregationPath path = AggregationPath.parse("_bucket_count"); AggregationPath path = AggregationPath.parse("_bucket_count");
List<LongTerms.Bucket> buckets = new ArrayList<>(); List<LongTerms.Bucket> buckets = new ArrayList<>();
InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap()); InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap());
InternalAggregations internalAggregations = new InternalAggregations(Collections.singletonList(agg)); InternalAggregations internalAggregations = InternalAggregations.from(Collections.singletonList(agg));
LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW); LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW);
buckets.add(bucket); buckets.add(bucket);
@ -109,7 +109,7 @@ public class InternalMultiBucketAggregationTests extends ESTestCase {
AggregationPath path = AggregationPath.parse("_count"); AggregationPath path = AggregationPath.parse("_count");
List<LongTerms.Bucket> buckets = new ArrayList<>(); List<LongTerms.Bucket> buckets = new ArrayList<>();
InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap()); InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap());
InternalAggregations internalAggregations = new InternalAggregations(Collections.singletonList(agg)); InternalAggregations internalAggregations = InternalAggregations.from(Collections.singletonList(agg));
LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW); LongTerms.Bucket bucket = new LongTerms.Bucket(1, 1, internalAggregations, false, 0, DocValueFormat.RAW);
buckets.add(bucket); buckets.add(bucket);
@ -122,7 +122,7 @@ public class InternalMultiBucketAggregationTests extends ESTestCase {
AggregationPath path = AggregationPath.parse("_key"); AggregationPath path = AggregationPath.parse("_key");
List<LongTerms.Bucket> buckets = new ArrayList<>(); List<LongTerms.Bucket> buckets = new ArrayList<>();
InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap()); InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap());
InternalAggregations internalAggregations = new InternalAggregations(Collections.singletonList(agg)); InternalAggregations internalAggregations = InternalAggregations.from(Collections.singletonList(agg));
LongTerms.Bucket bucket = new LongTerms.Bucket(19, 1, internalAggregations, false, 0, DocValueFormat.RAW); LongTerms.Bucket bucket = new LongTerms.Bucket(19, 1, internalAggregations, false, 0, DocValueFormat.RAW);
buckets.add(bucket); buckets.add(bucket);
@ -136,14 +136,14 @@ public class InternalMultiBucketAggregationTests extends ESTestCase {
List<LongTerms.Bucket> buckets = new ArrayList<>(); List<LongTerms.Bucket> buckets = new ArrayList<>();
InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap()); InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap());
InternalAggregations internalStringAggs = new InternalAggregations(Collections.singletonList(agg)); InternalAggregations internalStringAggs = InternalAggregations.from(Collections.singletonList(agg));
List<StringTerms.Bucket> stringBuckets = Collections.singletonList(new StringTerms.Bucket( List<StringTerms.Bucket> stringBuckets = Collections.singletonList(new StringTerms.Bucket(
new BytesRef("foo".getBytes(StandardCharsets.UTF_8), 0, "foo".getBytes(StandardCharsets.UTF_8).length), 1, new BytesRef("foo".getBytes(StandardCharsets.UTF_8), 0, "foo".getBytes(StandardCharsets.UTF_8).length), 1,
internalStringAggs, false, 0, DocValueFormat.RAW)); internalStringAggs, false, 0, DocValueFormat.RAW));
InternalTerms termsAgg = new StringTerms("string_terms", BucketOrder.count(false), 1, 0, InternalTerms termsAgg = new StringTerms("string_terms", BucketOrder.count(false), 1, 0,
Collections.emptyMap(), DocValueFormat.RAW, 1, false, 0, stringBuckets, 0); Collections.emptyMap(), DocValueFormat.RAW, 1, false, 0, stringBuckets, 0);
InternalAggregations internalAggregations = new InternalAggregations(Collections.singletonList(termsAgg)); InternalAggregations internalAggregations = InternalAggregations.from(Collections.singletonList(termsAgg));
LongTerms.Bucket bucket = new LongTerms.Bucket(19, 1, internalAggregations, false, 0, DocValueFormat.RAW); LongTerms.Bucket bucket = new LongTerms.Bucket(19, 1, internalAggregations, false, 0, DocValueFormat.RAW);
buckets.add(bucket); buckets.add(bucket);
@ -156,14 +156,14 @@ public class InternalMultiBucketAggregationTests extends ESTestCase {
List<LongTerms.Bucket> buckets = new ArrayList<>(); List<LongTerms.Bucket> buckets = new ArrayList<>();
InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap()); InternalAggregation agg = new InternalAvg("the_avg", 2, 1, DocValueFormat.RAW, Collections.emptyMap());
InternalAggregations internalStringAggs = new InternalAggregations(Collections.singletonList(agg)); InternalAggregations internalStringAggs = InternalAggregations.from(Collections.singletonList(agg));
List<StringTerms.Bucket> stringBuckets = Collections.singletonList(new StringTerms.Bucket( List<StringTerms.Bucket> stringBuckets = Collections.singletonList(new StringTerms.Bucket(
new BytesRef("foo".getBytes(StandardCharsets.UTF_8), 0, "foo".getBytes(StandardCharsets.UTF_8).length), 1, new BytesRef("foo".getBytes(StandardCharsets.UTF_8), 0, "foo".getBytes(StandardCharsets.UTF_8).length), 1,
internalStringAggs, false, 0, DocValueFormat.RAW)); internalStringAggs, false, 0, DocValueFormat.RAW));
InternalTerms termsAgg = new StringTerms("string_terms", BucketOrder.count(false), 1, 0, InternalTerms termsAgg = new StringTerms("string_terms", BucketOrder.count(false), 1, 0,
Collections.emptyMap(), DocValueFormat.RAW, 1, false, 0, stringBuckets, 0); Collections.emptyMap(), DocValueFormat.RAW, 1, false, 0, stringBuckets, 0);
InternalAggregations internalAggregations = new InternalAggregations(Collections.singletonList(termsAgg)); InternalAggregations internalAggregations = InternalAggregations.from(Collections.singletonList(termsAgg));
LongTerms.Bucket bucket = new LongTerms.Bucket(19, 1, internalAggregations, false, 0, DocValueFormat.RAW); LongTerms.Bucket bucket = new LongTerms.Bucket(19, 1, internalAggregations, false, 0, DocValueFormat.RAW);
buckets.add(bucket); buckets.add(bucket);

View file

@ -64,7 +64,7 @@ public class InternalFilterTests extends InternalSingleBucketAggregationTestCase
InternalFilter dummy = createTestInstance(); InternalFilter dummy = createTestInstance();
InternalFilter inner = createTestInstance(); InternalFilter inner = createTestInstance();
InternalAggregations sub = new InternalAggregations(List.of(inner)); InternalAggregations sub = InternalAggregations.from(List.of(inner));
InternalFilter test = createTestInstance("test", randomNonNegativeLong(), sub, emptyMap()); InternalFilter test = createTestInstance("test", randomNonNegativeLong(), sub, emptyMap());
PipelineAggregator mockPipeline = new PipelineAggregator(null, null, null) { PipelineAggregator mockPipeline = new PipelineAggregator(null, null, null) {
@Override @Override

View file

@ -131,7 +131,7 @@ public class InternalFiltersTests extends InternalMultiBucketAggregationTestCase
InternalFilters dummy = createTestInstance(); InternalFilters dummy = createTestInstance();
InternalFilters inner = createTestInstance(); InternalFilters inner = createTestInstance();
InternalAggregations sub = new InternalAggregations(List.of(inner)); InternalAggregations sub = InternalAggregations.from(List.of(inner));
InternalFilters test = createTestInstance("test", emptyMap(), sub); InternalFilters test = createTestInstance("test", emptyMap(), sub);
PipelineAggregator mockPipeline = new PipelineAggregator(null, null, null) { PipelineAggregator mockPipeline = new PipelineAggregator(null, null, null) {
@Override @Override

View file

@ -37,14 +37,12 @@ import java.time.ZoneOffset;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap; import static java.util.Collections.emptyMap;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.empty;
@ -73,8 +71,7 @@ public class InternalAutoDateHistogramTests extends InternalMultiBucketAggregati
long key = startingDate + (intervalMillis * i); long key = startingDate + (intervalMillis * i);
buckets.add(i, new InternalAutoDateHistogram.Bucket(key, randomIntBetween(1, 100), format, aggregations)); buckets.add(i, new InternalAutoDateHistogram.Bucket(key, randomIntBetween(1, 100), format, aggregations));
} }
InternalAggregations subAggregations = new InternalAggregations(Collections.emptyList()); BucketInfo bucketInfo = new BucketInfo(roundingInfos, roundingIndex, InternalAggregations.EMPTY);
BucketInfo bucketInfo = new BucketInfo(roundingInfos, roundingIndex, subAggregations);
return new InternalAutoDateHistogram(name, buckets, targetBuckets, bucketInfo, format, metadata, 1); return new InternalAutoDateHistogram(name, buckets, targetBuckets, bucketInfo, format, metadata, 1);
} }
@ -360,7 +357,7 @@ public class InternalAutoDateHistogramTests extends InternalMultiBucketAggregati
ReduceTestBuilder bucket(String key, long docCount) { ReduceTestBuilder bucket(String key, long docCount) {
buckets.add(new InternalAutoDateHistogram.Bucket( buckets.add(new InternalAutoDateHistogram.Bucket(
utcMillis(key), docCount, FORMAT, new InternalAggregations(emptyList()))); utcMillis(key), docCount, FORMAT, InternalAggregations.EMPTY));
return this; return this;
} }
@ -376,7 +373,7 @@ public class InternalAutoDateHistogramTests extends InternalMultiBucketAggregati
assertThat("rounding [" + whichRounding + "] should be in " + Arrays.toString(roundings), roundingIdx, greaterThan(-1)); assertThat("rounding [" + whichRounding + "] should be in " + Arrays.toString(roundings), roundingIdx, greaterThan(-1));
assertTrue(Arrays.toString(roundings[roundingIdx].innerIntervals) + " must contain " + innerInterval, assertTrue(Arrays.toString(roundings[roundingIdx].innerIntervals) + " must contain " + innerInterval,
Arrays.binarySearch(roundings[roundingIdx].innerIntervals, innerInterval) >= 0); Arrays.binarySearch(roundings[roundingIdx].innerIntervals, innerInterval) >= 0);
BucketInfo bucketInfo = new BucketInfo(roundings, roundingIdx, new InternalAggregations(emptyList())); BucketInfo bucketInfo = new BucketInfo(roundings, roundingIdx, InternalAggregations.EMPTY);
results.add(new InternalAutoDateHistogram("test", new ArrayList<>(buckets), targetBuckets, bucketInfo, results.add(new InternalAutoDateHistogram("test", new ArrayList<>(buckets), targetBuckets, bucketInfo,
FORMAT, emptyMap(), innerInterval)); FORMAT, emptyMap(), innerInterval));
buckets.clear(); buckets.clear();

View file

@ -62,7 +62,7 @@ public abstract class InternalSingleBucketAggregationTestCase<T extends Internal
if (hasInternalMin) { if (hasInternalMin) {
aggs.add(new InternalMin("min", randomDouble(), randomNumericDocValueFormat(), emptyMap())); aggs.add(new InternalMin("min", randomDouble(), randomNumericDocValueFormat(), emptyMap()));
} }
return new InternalAggregations(aggs); return InternalAggregations.from(aggs);
}; };
} }
@ -93,7 +93,7 @@ public abstract class InternalSingleBucketAggregationTestCase<T extends Internal
List<InternalAggregation> aggs = new ArrayList<>(); List<InternalAggregation> aggs = new ArrayList<>();
aggs.add(new InternalMax("new_max", randomDouble(), randomNumericDocValueFormat(), emptyMap())); aggs.add(new InternalMax("new_max", randomDouble(), randomNumericDocValueFormat(), emptyMap()));
aggs.add(new InternalMin("new_min", randomDouble(), randomNumericDocValueFormat(), emptyMap())); aggs.add(new InternalMin("new_min", randomDouble(), randomNumericDocValueFormat(), emptyMap()));
aggregations = new InternalAggregations(aggs); aggregations = InternalAggregations.from(aggs);
break; break;
case 3: case 3:
default: default:

View file

@ -78,7 +78,7 @@ public abstract class InternalMultiBucketAggregationTestCase<T extends InternalA
for (int i = 0; i < numAggregations; i++) { for (int i = 0; i < numAggregations; i++) {
aggs.add(createTestInstance(randomAlphaOfLength(5), emptyMap(), InternalAggregations.EMPTY)); aggs.add(createTestInstance(randomAlphaOfLength(5), emptyMap(), InternalAggregations.EMPTY));
} }
return new InternalAggregations(aggs); return InternalAggregations.from(aggs);
}; };
} }
} }

View file

@ -62,7 +62,7 @@ public class CumulativeCardinalityPipelineAggregator extends PipelineAggregator
.map((p) -> (InternalAggregation) p) .map((p) -> (InternalAggregation) p)
.collect(Collectors.toList()); .collect(Collectors.toList());
aggs.add(new InternalSimpleLongValue(name(), cardinality, formatter, metadata())); aggs.add(new InternalSimpleLongValue(name(), cardinality, formatter, metadata()));
Bucket newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs)); Bucket newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), InternalAggregations.from(aggs));
newBuckets.add(newBucket); newBuckets.add(newBucket);
} }
return factory.createAggregation(newBuckets); return factory.createAggregation(newBuckets);

View file

@ -106,7 +106,7 @@ public class MovingPercentilesPipelineAggregator extends PipelineAggregator {
.map((p) -> (InternalAggregation) p) .map((p) -> (InternalAggregation) p)
.collect(Collectors.toList()); .collect(Collectors.toList());
aggs.add(new InternalTDigestPercentiles(name(), config.keys, state, config.keyed, config.formatter, metadata())); aggs.add(new InternalTDigestPercentiles(name(), config.keys, state, config.keyed, config.formatter, metadata()));
newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs)); newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), InternalAggregations.from(aggs));
} }
newBuckets.add(newBucket); newBuckets.add(newBucket);
index++; index++;
@ -152,7 +152,7 @@ public class MovingPercentilesPipelineAggregator extends PipelineAggregator {
.map((p) -> (InternalAggregation) p) .map((p) -> (InternalAggregation) p)
.collect(Collectors.toList()); .collect(Collectors.toList());
aggs.add(new InternalHDRPercentiles(name(), config.keys, state, config.keyed, config.formatter, metadata())); aggs.add(new InternalHDRPercentiles(name(), config.keys, state, config.keyed, config.formatter, metadata()));
newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), new InternalAggregations(aggs)); newBucket = factory.createBucket(factory.getKey(bucket), bucket.getDocCount(), InternalAggregations.from(aggs));
} }
newBuckets.add(newBucket); newBuckets.add(newBucket);
index++; index++;

View file

@ -67,7 +67,7 @@ public class NormalizePipelineAggregator extends PipelineAggregator {
.map((p) -> (InternalAggregation) p) .map((p) -> (InternalAggregation) p)
.collect(Collectors.toList()); .collect(Collectors.toList());
aggs.add(new InternalSimpleValue(name(), normalizedBucketValue, formatter, metadata())); aggs.add(new InternalSimpleValue(name(), normalizedBucketValue, formatter, metadata()));
InternalMultiBucketAggregation.InternalBucket newBucket = originalAgg.createBucket(new InternalAggregations(aggs), bucket); InternalMultiBucketAggregation.InternalBucket newBucket = originalAgg.createBucket(InternalAggregations.from(aggs), bucket);
newBuckets.add(newBucket); newBuckets.add(newBucket);
} }

View file

@ -5,8 +5,6 @@
*/ */
package org.elasticsearch.xpack.rollup; package org.elasticsearch.xpack.rollup;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.search.MultiSearchResponse; import org.elasticsearch.action.search.MultiSearchResponse;
@ -41,7 +39,6 @@ import org.elasticsearch.xpack.core.rollup.RollupField;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -57,8 +54,6 @@ import java.util.stream.Collectors;
*/ */
public class RollupResponseTranslator { public class RollupResponseTranslator {
private static final Logger logger = LogManager.getLogger(RollupResponseTranslator.class);
/** /**
* Verifies a live-only search response. Essentially just checks for failure then returns * Verifies a live-only search response. Essentially just checks for failure then returns
* the response since we have no work to do * the response since we have no work to do
@ -272,7 +267,7 @@ public class RollupResponseTranslator {
// The combination process returns a tree that is identical to the non-rolled // The combination process returns a tree that is identical to the non-rolled
// which means we can use aggregation's reduce method to combine, just as if // which means we can use aggregation's reduce method to combine, just as if
// it was a result from another shard // it was a result from another shard
InternalAggregations currentTree = new InternalAggregations(Collections.emptyList()); InternalAggregations currentTree = InternalAggregations.EMPTY;
InternalAggregation.ReduceContext finalReduceContext = InternalAggregation.ReduceContext.forFinalReduction( InternalAggregation.ReduceContext finalReduceContext = InternalAggregation.ReduceContext.forFinalReduction(
reduceContext.bigArrays(), reduceContext.scriptService(), b -> {}, PipelineTree.EMPTY); reduceContext.bigArrays(), reduceContext.scriptService(), b -> {}, PipelineTree.EMPTY);
for (SearchResponse rolledResponse : rolledResponses) { for (SearchResponse rolledResponse : rolledResponses) {
@ -291,7 +286,7 @@ public class RollupResponseTranslator {
// Iteratively merge in each new set of unrolled aggs, so that we can identify/fix overlapping doc_counts // Iteratively merge in each new set of unrolled aggs, so that we can identify/fix overlapping doc_counts
// in the next round of unrolling // in the next round of unrolling
InternalAggregations finalUnrolledAggs = new InternalAggregations(unrolledAggs); InternalAggregations finalUnrolledAggs = InternalAggregations.from(unrolledAggs);
currentTree = InternalAggregations.reduce(Arrays.asList(currentTree, finalUnrolledAggs), finalReduceContext); currentTree = InternalAggregations.reduce(Arrays.asList(currentTree, finalUnrolledAggs), finalReduceContext);
} }
@ -505,7 +500,7 @@ public class RollupResponseTranslator {
*/ */
private static InternalAggregations unrollSubAggsFromMulti(InternalBucket bucket, InternalBucket original, InternalBucket currentTree) { private static InternalAggregations unrollSubAggsFromMulti(InternalBucket bucket, InternalBucket original, InternalBucket currentTree) {
// Iterate over the subAggs in each bucket // Iterate over the subAggs in each bucket
return new InternalAggregations(bucket.getAggregations() return InternalAggregations.from(bucket.getAggregations()
.asList().stream() .asList().stream()
// Avoid any rollup count metrics, as that's not a true "sub-agg" but rather agg // Avoid any rollup count metrics, as that's not a true "sub-agg" but rather agg
// added by the rollup for accounting purposes (e.g. doc_count) // added by the rollup for accounting purposes (e.g. doc_count)

View file

@ -162,11 +162,11 @@ public class RollupResponseTranslationTests extends AggregatorTestCase {
when(count.getType()).thenReturn(SumAggregationBuilder.NAME); when(count.getType()).thenReturn(SumAggregationBuilder.NAME);
subaggs.add(count); subaggs.add(count);
when(filter.getAggregations()).thenReturn(new InternalAggregations(subaggs)); when(filter.getAggregations()).thenReturn(InternalAggregations.from(subaggs));
when(filter.getName()).thenReturn("filter_foo"); when(filter.getName()).thenReturn("filter_foo");
aggTree.add(filter); aggTree.add(filter);
Aggregations mockAggsWithout = new InternalAggregations(aggTree); Aggregations mockAggsWithout = InternalAggregations.from(aggTree);
when(responseWithout.getAggregations()).thenReturn(mockAggsWithout); when(responseWithout.getAggregations()).thenReturn(mockAggsWithout);
MultiSearchResponse.Item[] msearch = new MultiSearchResponse.Item[]{ MultiSearchResponse.Item[] msearch = new MultiSearchResponse.Item[]{
@ -186,8 +186,7 @@ public class RollupResponseTranslationTests extends AggregatorTestCase {
SearchResponse responseWithout = mock(SearchResponse.class); SearchResponse responseWithout = mock(SearchResponse.class);
when(responseWithout.getTook()).thenReturn(new TimeValue(100)); when(responseWithout.getTook()).thenReturn(new TimeValue(100));
Aggregations mockAggsWithout = new InternalAggregations(Collections.emptyList()); when(responseWithout.getAggregations()).thenReturn(InternalAggregations.EMPTY);
when(responseWithout.getAggregations()).thenReturn(mockAggsWithout);
MultiSearchResponse.Item[] msearch = new MultiSearchResponse.Item[]{ MultiSearchResponse.Item[] msearch = new MultiSearchResponse.Item[]{
new MultiSearchResponse.Item(responseWithout, null)}; new MultiSearchResponse.Item(responseWithout, null)};
@ -258,11 +257,11 @@ public class RollupResponseTranslationTests extends AggregatorTestCase {
when(count.getType()).thenReturn(SumAggregationBuilder.NAME); when(count.getType()).thenReturn(SumAggregationBuilder.NAME);
subaggs.add(count); subaggs.add(count);
when(filter.getAggregations()).thenReturn(new InternalAggregations(subaggs)); when(filter.getAggregations()).thenReturn(InternalAggregations.from(subaggs));
when(filter.getName()).thenReturn("filter_foo"); when(filter.getName()).thenReturn("filter_foo");
aggTree.add(filter); aggTree.add(filter);
Aggregations mockAggs = new InternalAggregations(aggTree); Aggregations mockAggs = InternalAggregations.from(aggTree);
when(response.getAggregations()).thenReturn(mockAggs); when(response.getAggregations()).thenReturn(mockAggs);
MultiSearchResponse.Item item = new MultiSearchResponse.Item(response, null); MultiSearchResponse.Item item = new MultiSearchResponse.Item(response, null);
@ -298,7 +297,7 @@ public class RollupResponseTranslationTests extends AggregatorTestCase {
InternalMax protoMax = mock(InternalMax.class); InternalMax protoMax = mock(InternalMax.class);
when(protoMax.getName()).thenReturn("foo"); when(protoMax.getName()).thenReturn("foo");
protoAggTree.add(protoMax); protoAggTree.add(protoMax);
Aggregations protoMockAggs = new InternalAggregations(protoAggTree); Aggregations protoMockAggs = InternalAggregations.from(protoAggTree);
when(protoResponse.getAggregations()).thenReturn(protoMockAggs); when(protoResponse.getAggregations()).thenReturn(protoMockAggs);
MultiSearchResponse.Item unrolledResponse = new MultiSearchResponse.Item(protoResponse, null); MultiSearchResponse.Item unrolledResponse = new MultiSearchResponse.Item(protoResponse, null);
@ -307,7 +306,7 @@ public class RollupResponseTranslationTests extends AggregatorTestCase {
InternalMax max = mock(InternalMax.class); InternalMax max = mock(InternalMax.class);
when(max.getName()).thenReturn("bizzbuzz"); when(max.getName()).thenReturn("bizzbuzz");
aggTreeWithoutFilter.add(max); aggTreeWithoutFilter.add(max);
Aggregations mockAggsWithout = new InternalAggregations(aggTreeWithoutFilter); Aggregations mockAggsWithout = InternalAggregations.from(aggTreeWithoutFilter);
when(responseWithout.getAggregations()).thenReturn(mockAggsWithout); when(responseWithout.getAggregations()).thenReturn(mockAggsWithout);
MultiSearchResponse.Item rolledResponse = new MultiSearchResponse.Item(responseWithout, null); MultiSearchResponse.Item rolledResponse = new MultiSearchResponse.Item(responseWithout, null);
@ -328,7 +327,7 @@ public class RollupResponseTranslationTests extends AggregatorTestCase {
InternalMax protoMax = mock(InternalMax.class); InternalMax protoMax = mock(InternalMax.class);
when(protoMax.getName()).thenReturn("foo"); when(protoMax.getName()).thenReturn("foo");
protoAggTree.add(protoMax); protoAggTree.add(protoMax);
Aggregations protoMockAggs = new InternalAggregations(protoAggTree); Aggregations protoMockAggs = InternalAggregations.from(protoAggTree);
when(protoResponse.getAggregations()).thenReturn(protoMockAggs); when(protoResponse.getAggregations()).thenReturn(protoMockAggs);
MultiSearchResponse.Item unrolledResponse = new MultiSearchResponse.Item(protoResponse, null); MultiSearchResponse.Item unrolledResponse = new MultiSearchResponse.Item(protoResponse, null);
@ -336,7 +335,7 @@ public class RollupResponseTranslationTests extends AggregatorTestCase {
List<InternalAggregation> aggTreeWithoutFilter = new ArrayList<>(1); List<InternalAggregation> aggTreeWithoutFilter = new ArrayList<>(1);
InternalMax max = new InternalMax("filter_foo", 0, DocValueFormat.RAW, null); InternalMax max = new InternalMax("filter_foo", 0, DocValueFormat.RAW, null);
aggTreeWithoutFilter.add(max); aggTreeWithoutFilter.add(max);
Aggregations mockAggsWithout = new InternalAggregations(aggTreeWithoutFilter); Aggregations mockAggsWithout = InternalAggregations.from(aggTreeWithoutFilter);
when(responseWithout.getAggregations()).thenReturn(mockAggsWithout); when(responseWithout.getAggregations()).thenReturn(mockAggsWithout);
MultiSearchResponse.Item rolledResponse = new MultiSearchResponse.Item(responseWithout, null); MultiSearchResponse.Item rolledResponse = new MultiSearchResponse.Item(responseWithout, null);
@ -358,7 +357,7 @@ public class RollupResponseTranslationTests extends AggregatorTestCase {
List<InternalAggregation> protoAggTree = new ArrayList<>(1); List<InternalAggregation> protoAggTree = new ArrayList<>(1);
InternalAvg internalAvg = new InternalAvg("foo", 10, 2, DocValueFormat.RAW, null); InternalAvg internalAvg = new InternalAvg("foo", 10, 2, DocValueFormat.RAW, null);
protoAggTree.add(internalAvg); protoAggTree.add(internalAvg);
Aggregations protoMockAggs = new InternalAggregations(protoAggTree); Aggregations protoMockAggs = InternalAggregations.from(protoAggTree);
when(protoResponse.getAggregations()).thenReturn(protoMockAggs); when(protoResponse.getAggregations()).thenReturn(protoMockAggs);
MultiSearchResponse.Item unrolledResponse = new MultiSearchResponse.Item(protoResponse, null); MultiSearchResponse.Item unrolledResponse = new MultiSearchResponse.Item(protoResponse, null);
@ -386,11 +385,11 @@ public class RollupResponseTranslationTests extends AggregatorTestCase {
when(count.getType()).thenReturn(SumAggregationBuilder.NAME); when(count.getType()).thenReturn(SumAggregationBuilder.NAME);
subaggs.add(count); subaggs.add(count);
when(filter.getAggregations()).thenReturn(new InternalAggregations(subaggs)); when(filter.getAggregations()).thenReturn(InternalAggregations.from(subaggs));
when(filter.getName()).thenReturn("filter_foo"); when(filter.getName()).thenReturn("filter_foo");
aggTree.add(filter); aggTree.add(filter);
Aggregations mockAggsWithout = new InternalAggregations(aggTree); Aggregations mockAggsWithout = InternalAggregations.from(aggTree);
when(responseWithout.getAggregations()).thenReturn(mockAggsWithout); when(responseWithout.getAggregations()).thenReturn(mockAggsWithout);
MultiSearchResponse.Item rolledResponse = new MultiSearchResponse.Item(responseWithout, null); MultiSearchResponse.Item rolledResponse = new MultiSearchResponse.Item(responseWithout, null);
@ -495,11 +494,11 @@ public class RollupResponseTranslationTests extends AggregatorTestCase {
// TODO SearchResponse.Clusters is not public, using null for now. Should fix upstream. // TODO SearchResponse.Clusters is not public, using null for now. Should fix upstream.
MultiSearchResponse.Item unrolledItem = new MultiSearchResponse.Item(new SearchResponse( MultiSearchResponse.Item unrolledItem = new MultiSearchResponse.Item(new SearchResponse(
new InternalSearchResponse(null, new InternalSearchResponse(null,
new InternalAggregations(Collections.singletonList(responses.get(0))), null, null, false, false, 1), InternalAggregations.from(Collections.singletonList(responses.get(0))), null, null, false, false, 1),
null, 1, 1, 0, 10, null, null), null); null, 1, 1, 0, 10, null, null), null);
MultiSearchResponse.Item rolledItem = new MultiSearchResponse.Item(new SearchResponse( MultiSearchResponse.Item rolledItem = new MultiSearchResponse.Item(new SearchResponse(
new InternalSearchResponse(null, new InternalSearchResponse(null,
new InternalAggregations(Collections.singletonList(responses.get(1))), null, null, false, false, 1), InternalAggregations.from(Collections.singletonList(responses.get(1))), null, null, false, false, 1),
null, 1, 1, 0, 10, null, null), null); null, 1, 1, 0, 10, null, null), null);
MultiSearchResponse.Item[] msearch = new MultiSearchResponse.Item[]{unrolledItem, rolledItem}; MultiSearchResponse.Item[] msearch = new MultiSearchResponse.Item[]{unrolledItem, rolledItem};

View file

@ -652,11 +652,11 @@ public class SearchActionTests extends ESTestCase {
when(count.getType()).thenReturn(SumAggregationBuilder.NAME); when(count.getType()).thenReturn(SumAggregationBuilder.NAME);
subaggs.add(count); subaggs.add(count);
when(filter.getAggregations()).thenReturn(new InternalAggregations(subaggs)); when(filter.getAggregations()).thenReturn(InternalAggregations.from(subaggs));
when(filter.getName()).thenReturn("filter_foo"); when(filter.getName()).thenReturn("filter_foo");
aggTree.add(filter); aggTree.add(filter);
Aggregations mockAggs = new InternalAggregations(aggTree); Aggregations mockAggs = InternalAggregations.from(aggTree);
when(response.getAggregations()).thenReturn(mockAggs); when(response.getAggregations()).thenReturn(mockAggs);
MultiSearchResponse.Item item = new MultiSearchResponse.Item(response, null); MultiSearchResponse.Item item = new MultiSearchResponse.Item(response, null);
MultiSearchResponse msearchResponse = new MultiSearchResponse(new MultiSearchResponse.Item[]{item}, 1); MultiSearchResponse msearchResponse = new MultiSearchResponse(new MultiSearchResponse.Item[]{item}, 1);
@ -736,7 +736,7 @@ public class SearchActionTests extends ESTestCase {
List<InternalAggregation> protoAggTree = new ArrayList<>(1); List<InternalAggregation> protoAggTree = new ArrayList<>(1);
InternalAvg internalAvg = new InternalAvg("foo", 10, 2, DocValueFormat.RAW, null); InternalAvg internalAvg = new InternalAvg("foo", 10, 2, DocValueFormat.RAW, null);
protoAggTree.add(internalAvg); protoAggTree.add(internalAvg);
Aggregations protoMockAggs = new InternalAggregations(protoAggTree); Aggregations protoMockAggs = InternalAggregations.from(protoAggTree);
when(protoResponse.getAggregations()).thenReturn(protoMockAggs); when(protoResponse.getAggregations()).thenReturn(protoMockAggs);
MultiSearchResponse.Item unrolledResponse = new MultiSearchResponse.Item(protoResponse, null); MultiSearchResponse.Item unrolledResponse = new MultiSearchResponse.Item(protoResponse, null);
@ -764,11 +764,11 @@ public class SearchActionTests extends ESTestCase {
when(count.getType()).thenReturn(SumAggregationBuilder.NAME); when(count.getType()).thenReturn(SumAggregationBuilder.NAME);
subaggs.add(count); subaggs.add(count);
when(filter.getAggregations()).thenReturn(new InternalAggregations(subaggs)); when(filter.getAggregations()).thenReturn(InternalAggregations.from(subaggs));
when(filter.getName()).thenReturn("filter_foo"); when(filter.getName()).thenReturn("filter_foo");
aggTree.add(filter); aggTree.add(filter);
Aggregations mockAggsWithout = new InternalAggregations(aggTree); Aggregations mockAggsWithout = InternalAggregations.from(aggTree);
when(responseWithout.getAggregations()).thenReturn(mockAggsWithout); when(responseWithout.getAggregations()).thenReturn(mockAggsWithout);
MultiSearchResponse.Item rolledResponse = new MultiSearchResponse.Item(responseWithout, null); MultiSearchResponse.Item rolledResponse = new MultiSearchResponse.Item(responseWithout, null);

View file

@ -622,7 +622,7 @@ public class RollupIndexerStateTests extends ESTestCase {
@Override @Override
public Aggregations getAggregations() { public Aggregations getAggregations() {
return new InternalAggregations(Collections.emptyList()); return InternalAggregations.EMPTY;
} }
@Override @Override
@ -735,7 +735,7 @@ public class RollupIndexerStateTests extends ESTestCase {
@Override @Override
public Aggregations getAggregations() { public Aggregations getAggregations() {
return new InternalAggregations(Collections.emptyList()); return InternalAggregations.EMPTY;
} }
@Override @Override
@ -892,7 +892,7 @@ public class RollupIndexerStateTests extends ESTestCase {
@Override @Override
public Aggregations getAggregations() { public Aggregations getAggregations() {
return new InternalAggregations(Collections.emptyList()); return InternalAggregations.EMPTY;
} }
@Override @Override