Skip to content

Commit f461f90

Browse files
Remove redundant marker interfaces that extend Bucket (#127038)
No need to have these marker interfaces around when weäre not using them anywhere, all they do is hide a lot of code duplication actually. Removing them sets up the possible removal of hundreds of lines of downstream code it seems
1 parent b46bee4 commit f461f90

File tree

71 files changed

+258
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+258
-437
lines changed

modules/aggregations/src/internalClusterTest/java/org/elasticsearch/aggregations/bucket/TimeSeriesAggregationsIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.elasticsearch.search.aggregations.InternalAggregations;
2828
import org.elasticsearch.search.aggregations.PipelineAggregatorBuilders;
2929
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
30-
import org.elasticsearch.search.aggregations.bucket.global.Global;
30+
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
3131
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
3232
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
3333
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
@@ -327,7 +327,7 @@ public void testStandAloneTimeSeriesAggWithGlobalAggregation() {
327327
SimpleValue obj = aggregations.get("total_filter_sum");
328328
assertThat(obj.value(), closeTo(sumByMetric(filteredData, "metric_" + metric), obj.value() * 0.0001));
329329

330-
Global global = aggregations.get("everything");
330+
SingleBucketAggregation global = aggregations.get("everything");
331331
Sum allSum = global.getAggregations().get("all_sum");
332332
assertThat(allSum.value(), closeTo(sumByMetric(data, "metric_" + metric), allSum.value() * 0.0001));
333333
}

modules/parent-join/src/internalClusterTest/java/org/elasticsearch/join/aggregations/ChildrenIT.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.search.SearchHit;
1616
import org.elasticsearch.search.aggregations.AggregationBuilders;
1717
import org.elasticsearch.search.aggregations.InternalAggregation;
18+
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
1819
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
1920
import org.elasticsearch.search.aggregations.metrics.Sum;
2021
import org.elasticsearch.search.aggregations.metrics.TopHits;
@@ -47,7 +48,7 @@ public void testSimpleChildrenAgg() {
4748
assertNoFailuresAndResponse(
4849
prepareSearch("test").setQuery(matchQuery("randomized", true)).addAggregation(children("to_comment", "comment")),
4950
response -> {
50-
Children childrenAgg = response.getAggregations().get("to_comment");
51+
SingleBucketAggregation childrenAgg = response.getAggregations().get("to_comment");
5152
assertThat("Response: " + response + "\n", childrenAgg.getDocCount(), equalTo(count));
5253
}
5354
);
@@ -73,7 +74,7 @@ public void testChildrenAggs() {
7374
assertThat(categoryBucket.getKeyAsString(), equalTo(entry1.getKey()));
7475
assertThat(categoryBucket.getDocCount(), equalTo((long) entry1.getValue().articleIds.size()));
7576

76-
Children childrenBucket = categoryBucket.getAggregations().get("to_comment");
77+
SingleBucketAggregation childrenBucket = categoryBucket.getAggregations().get("to_comment");
7778
assertThat(childrenBucket.getName(), equalTo("to_comment"));
7879
assertThat(childrenBucket.getDocCount(), equalTo((long) entry1.getValue().commentIds.size()));
7980
assertThat(
@@ -113,7 +114,7 @@ public void testParentWithMultipleBuckets() {
113114

114115
for (Terms.Bucket bucket : categoryTerms.getBuckets()) {
115116
logger.info("bucket={}", bucket.getKey());
116-
Children childrenBucket = bucket.getAggregations().get("to_comment");
117+
SingleBucketAggregation childrenBucket = bucket.getAggregations().get("to_comment");
117118
TopHits topHits = childrenBucket.getAggregations().get("top_comments");
118119
logger.info("total_hits={}", topHits.getHits().getTotalHits().value());
119120
for (SearchHit searchHit : topHits.getHits()) {
@@ -125,7 +126,7 @@ public void testParentWithMultipleBuckets() {
125126
assertThat(categoryBucket.getKeyAsString(), equalTo("a"));
126127
assertThat(categoryBucket.getDocCount(), equalTo(3L));
127128

128-
Children childrenBucket = categoryBucket.getAggregations().get("to_comment");
129+
SingleBucketAggregation childrenBucket = categoryBucket.getAggregations().get("to_comment");
129130
assertThat(childrenBucket.getName(), equalTo("to_comment"));
130131
assertThat(childrenBucket.getDocCount(), equalTo(2L));
131132
TopHits topHits = childrenBucket.getAggregations().get("top_comments");
@@ -178,7 +179,7 @@ public void testWithDeletes() throws Exception {
178179
assertNoFailuresAndResponse(
179180
prepareSearch(indexName).addAggregation(children("children", "child").subAggregation(sum("counts").field("count"))),
180181
response -> {
181-
Children children = response.getAggregations().get("children");
182+
SingleBucketAggregation children = response.getAggregations().get("children");
182183
assertThat(children.getDocCount(), equalTo(4L));
183184

184185
Sum count = children.getAggregations().get("counts");
@@ -205,7 +206,7 @@ public void testWithDeletes() throws Exception {
205206

206207
public void testNonExistingChildType() throws Exception {
207208
assertNoFailuresAndResponse(prepareSearch("test").addAggregation(children("non-existing", "xyz")), response -> {
208-
Children children = response.getAggregations().get("non-existing");
209+
SingleBucketAggregation children = response.getAggregations().get("non-existing");
209210
assertThat(children.getName(), equalTo("non-existing"));
210211
assertThat(children.getDocCount(), equalTo(0L));
211212
});
@@ -264,7 +265,7 @@ public void testPostCollection() throws Exception {
264265
response -> {
265266
assertHitCount(response, 1L);
266267

267-
Children childrenAgg = response.getAggregations().get("my-refinements");
268+
SingleBucketAggregation childrenAgg = response.getAggregations().get("my-refinements");
268269
assertThat(childrenAgg.getDocCount(), equalTo(7L));
269270

270271
Terms termsAgg = childrenAgg.getAggregations().get("my-colors");
@@ -316,7 +317,7 @@ public void testHierarchicalChildrenAggs() {
316317
response -> {
317318
assertHitCount(response, 1L);
318319

319-
Children children = response.getAggregations().get(parentType);
320+
SingleBucketAggregation children = response.getAggregations().get(parentType);
320321
assertThat(children.getName(), equalTo(parentType));
321322
assertThat(children.getDocCount(), equalTo(1L));
322323
children = children.getAggregations().get(childType);
@@ -379,7 +380,7 @@ public void testPostCollectAllLeafReaders() throws Exception {
379380
assertThat(parents.getBuckets().size(), equalTo(2));
380381
assertThat(parents.getBuckets().get(0).getKeyAsString(), equalTo("Alice"));
381382
assertThat(parents.getBuckets().get(0).getDocCount(), equalTo(1L));
382-
Children children = parents.getBuckets().get(0).getAggregations().get("child_docs");
383+
SingleBucketAggregation children = parents.getBuckets().get(0).getAggregations().get("child_docs");
383384
assertThat(children.getDocCount(), equalTo(1L));
384385

385386
assertThat(parents.getBuckets().get(1).getKeyAsString(), equalTo("Bill"));

modules/parent-join/src/internalClusterTest/java/org/elasticsearch/join/aggregations/ParentIT.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.elasticsearch.search.aggregations.Aggregation;
1313
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
14+
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
1415
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
1516

1617
import java.util.HashMap;
@@ -39,7 +40,7 @@ public void testSimpleParentAgg() {
3940
assertNoFailuresAndResponse(
4041
prepareSearch("test").setSize(0).setQuery(matchQuery("randomized", true)).addAggregation(parent("to_article", "comment")),
4142
response -> {
42-
Parent parentAgg = response.getAggregations().get("to_article");
43+
SingleBucketAggregation parentAgg = response.getAggregations().get("to_article");
4344
assertThat("\nResponse: " + response + "\n", parentAgg.getDocCount(), equalTo(articlesWithComment));
4445
}
4546
);
@@ -56,7 +57,7 @@ public void testSimpleParentAggWithSubAgg() {
5657
.setQuery(matchQuery("randomized", true))
5758
.addAggregation(parent("to_article", "comment").subAggregation(terms("category").field("category").size(10000))),
5859
response -> {
59-
Parent parentAgg = response.getAggregations().get("to_article");
60+
SingleBucketAggregation parentAgg = response.getAggregations().get("to_article");
6061
assertThat("Response: " + response + "\n", parentAgg.getDocCount(), equalTo(articlesWithComment));
6162
Terms categoryTerms = parentAgg.getAggregations().get("category");
6263
assertThat(
@@ -123,7 +124,7 @@ public void testParentAggs() throws Exception {
123124
equalTo((long) comments.size())
124125
);
125126

126-
Parent articleAgg = commenterBucket.getAggregations().get("to_article");
127+
SingleBucketAggregation articleAgg = commenterBucket.getAggregations().get("to_article");
127128
assertThat(articleAgg.getName(), equalTo("to_article"));
128129
// find all articles for the comments for the current commenter
129130
Set<String> articles = articleToControl.values()
@@ -159,7 +160,7 @@ public void testParentAggs() throws Exception {
159160
assertThat(categoryBucket.getKeyAsString(), equalTo(commenter));
160161
assertThat(categoryBucket.getDocCount(), equalTo((long) commenterToComments.get(commenter).size()));
161162

162-
Parent childrenBucket = categoryBucket.getAggregations().get("to_article");
163+
SingleBucketAggregation childrenBucket = categoryBucket.getAggregations().get("to_article");
163164
assertThat(childrenBucket.getName(), equalTo("to_article"));
164165
}
165166
}
@@ -186,7 +187,7 @@ private Map<String, Set<String>> getCommenterToComments() {
186187

187188
public void testNonExistingParentType() throws Exception {
188189
assertNoFailuresAndResponse(prepareSearch("test").addAggregation(parent("non-existing", "xyz")), response -> {
189-
Parent parent = response.getAggregations().get("non-existing");
190+
SingleBucketAggregation parent = response.getAggregations().get("non-existing");
190191
assertThat(parent.getName(), equalTo("non-existing"));
191192
assertThat(parent.getDocCount(), equalTo(0L));
192193
});
@@ -216,7 +217,7 @@ public void testTermsParentAggTerms() throws Exception {
216217
equalTo((long) comments.size())
217218
);
218219

219-
Parent articleAgg = commenterBucket.getAggregations().get("to_article");
220+
SingleBucketAggregation articleAgg = commenterBucket.getAggregations().get("to_article");
220221
assertThat(articleAgg.getName(), equalTo("to_article"));
221222
// find all articles for the comments for the current commenter
222223
Set<String> articles = articleToControl.values()

modules/parent-join/src/internalClusterTest/java/org/elasticsearch/join/query/ChildQuerySearchIT.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
import org.elasticsearch.rest.RestStatus;
3232
import org.elasticsearch.search.SearchHit;
3333
import org.elasticsearch.search.aggregations.AggregationBuilders;
34-
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
35-
import org.elasticsearch.search.aggregations.bucket.global.Global;
34+
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
3635
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
3736
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
3837
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder.Field;
@@ -433,8 +432,8 @@ public void testScopedFacet() throws Exception {
433432
assertThat(response.getHits().getAt(0).getId(), anyOf(equalTo("p2"), equalTo("p1")));
434433
assertThat(response.getHits().getAt(1).getId(), anyOf(equalTo("p2"), equalTo("p1")));
435434

436-
Global global = response.getAggregations().get("global");
437-
Filter filter = global.getAggregations().get("filter");
435+
SingleBucketAggregation global = response.getAggregations().get("global");
436+
SingleBucketAggregation filter = global.getAggregations().get("filter");
438437
Terms termsFacet = filter.getAggregations().get("facet1");
439438
assertThat(termsFacet.getBuckets().size(), equalTo(2));
440439
assertThat(termsFacet.getBuckets().get(0).getKeyAsString(), equalTo("red"));

modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/Children.java

-17
This file was deleted.

modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/InternalChildren.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* Results of the {@link ParentToChildrenAggregator}.
2121
*/
22-
public class InternalChildren extends InternalSingleBucketAggregation implements Children {
22+
public class InternalChildren extends InternalSingleBucketAggregation {
2323
public InternalChildren(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
2424
super(name, docCount, aggregations, metadata);
2525
}

modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/InternalParent.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* Results of the {@link ChildrenToParentAggregator}.
2121
*/
22-
public class InternalParent extends InternalSingleBucketAggregation implements Parent {
22+
public class InternalParent extends InternalSingleBucketAggregation {
2323
public InternalParent(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) {
2424
super(name, docCount, aggregations, metadata);
2525
}

modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/JoinAggregationBuilders.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99

1010
package org.elasticsearch.join.aggregations;
1111

12+
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
13+
1214
public abstract class JoinAggregationBuilders {
1315
/**
14-
* Create a new {@link Children} aggregation with the given name.
16+
* Create a new {@link SingleBucketAggregation} aggregation with the given name.
1517
*/
1618
public static ChildrenAggregationBuilder children(String name, String childType) {
1719
return new ChildrenAggregationBuilder(name, childType);
1820
}
1921

2022
/**
21-
* Create a new {@link Parent} aggregation with the given name.
23+
* Create a new {@link SingleBucketAggregation} aggregation with the given name.
2224
*/
2325
public static ParentAggregationBuilder parent(String name, String childType) {
2426
return new ParentAggregationBuilder(name, childType);

modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/Parent.java

-17
This file was deleted.

server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.elasticsearch.search.SearchHit;
3535
import org.elasticsearch.search.SearchHits;
3636
import org.elasticsearch.search.aggregations.AggregationBuilders;
37-
import org.elasticsearch.search.aggregations.bucket.global.Global;
37+
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
3838
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
3939
import org.elasticsearch.search.sort.SortOrder;
4040
import org.elasticsearch.test.ESIntegTestCase;
@@ -306,7 +306,7 @@ public void testSearchingFilteringAliasesSingleIndex() throws Exception {
306306
prepareSearch("tests").setQuery(QueryBuilders.matchQuery("name", "bar"))
307307
.addAggregation(AggregationBuilders.global("global").subAggregation(AggregationBuilders.terms("test").field("name"))),
308308
searchResponse -> {
309-
Global global = searchResponse.getAggregations().get("global");
309+
SingleBucketAggregation global = searchResponse.getAggregations().get("global");
310310
Terms terms = global.getAggregations().get("test");
311311
assertThat(terms.getBuckets().size(), equalTo(4));
312312
}
@@ -318,7 +318,7 @@ public void testSearchingFilteringAliasesSingleIndex() throws Exception {
318318
.addAggregation(AggregationBuilders.global("global").subAggregation(AggregationBuilders.terms("test").field("name")))
319319
.addSort("_index", SortOrder.ASC),
320320
searchResponse -> {
321-
Global global = searchResponse.getAggregations().get("global");
321+
SingleBucketAggregation global = searchResponse.getAggregations().get("global");
322322
Terms terms = global.getAggregations().get("test");
323323
assertThat(terms.getBuckets().size(), equalTo(4));
324324
}

server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/CombiIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
import org.elasticsearch.action.index.IndexRequestBuilder;
1313
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
14+
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
1415
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
15-
import org.elasticsearch.search.aggregations.bucket.missing.Missing;
1616
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
1717
import org.elasticsearch.test.ESIntegTestCase;
1818
import org.hamcrest.Matchers;
@@ -69,7 +69,7 @@ public void testMultipleAggsOnSameField_WithDifferentRequiredValueSourceType() t
6969
response -> {
7070
InternalAggregations aggs = response.getAggregations();
7171

72-
Missing missing = aggs.get("missing_values");
72+
SingleBucketAggregation missing = aggs.get("missing_values");
7373
assertNotNull(missing);
7474
assertThat(missing.getDocCount(), equalTo(finalMissingValues));
7575

server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/EquivalenceIT.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.elasticsearch.script.Script;
2222
import org.elasticsearch.script.ScriptType;
2323
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
24-
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
24+
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation;
2525
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
2626
import org.elasticsearch.search.aggregations.bucket.range.Range;
2727
import org.elasticsearch.search.aggregations.bucket.range.Range.Bucket;
@@ -191,7 +191,7 @@ public void testRandomRanges() throws Exception {
191191
assertEquals(bucket.getKeyAsString(), Integer.toString(i), bucket.getKeyAsString());
192192
assertEquals(bucket.getKeyAsString(), count, bucket.getDocCount());
193193

194-
final Filter filter = response.getAggregations().get("filter" + i);
194+
final SingleBucketAggregation filter = response.getAggregations().get("filter" + i);
195195
assertThat(filter.getDocCount(), equalTo(count));
196196
}
197197
});
@@ -430,7 +430,7 @@ public void testReduce() throws Exception {
430430
)
431431
),
432432
response -> {
433-
Filter filter = response.getAggregations().get("filter");
433+
SingleBucketAggregation filter = response.getAggregations().get("filter");
434434
assertNotNull(filter);
435435
assertEquals(1, filter.getDocCount());
436436

0 commit comments

Comments
 (0)