From d62376ce33deb7c5cd9764199b6ef34a7c7cab51 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 18 Apr 2016 14:00:14 -0400 Subject: [PATCH] Remove PROTOTYPE from KeyedFilter Relates to #17085 --- .../bucket/filters/FiltersAggregator.java | 29 +++++++++---------- .../filters/FiltersAggregatorBuilder.java | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java index be31d9f6108..b91bb65c84c 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java @@ -58,8 +58,6 @@ public class FiltersAggregator extends BucketsAggregator { public static final ParseField OTHER_BUCKET_KEY_FIELD = new ParseField("other_bucket_key"); public static class KeyedFilter implements Writeable, ToXContent { - - static final KeyedFilter PROTOTYPE = new KeyedFilter("", new MatchAllQueryBuilder()); private final String key; private final QueryBuilder filter; @@ -78,6 +76,20 @@ public class FiltersAggregator extends BucketsAggregator { } } + /** + * Read from a stream. + */ + public KeyedFilter(StreamInput in) throws IOException { + key = in.readString(); + filter = in.readQuery(); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + out.writeString(key); + out.writeQuery(filter); + } + public String key() { return key; } @@ -92,19 +104,6 @@ public class FiltersAggregator extends BucketsAggregator { return builder; } - @Override - public KeyedFilter readFrom(StreamInput in) throws IOException { - String key = in.readString(); - QueryBuilder filter = in.readQuery(); - return new KeyedFilter(key, filter); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - out.writeString(key); - out.writeQuery(filter); - } - @Override public int hashCode() { return Objects.hash(key, filter); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregatorBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregatorBuilder.java index 6712063c6b8..457fd3a64f1 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregatorBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregatorBuilder.java @@ -100,7 +100,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder(filtersSize); if (keyed) { for (int i = 0; i < filtersSize; i++) { - filters.add(KeyedFilter.PROTOTYPE.readFrom(in)); + filters.add(new KeyedFilter(in)); } } else { for (int i = 0; i < filtersSize; i++) {