Remove PROTOTYPE from KeyedFilter

Relates to #17085
This commit is contained in:
Nik Everett 2016-04-18 14:00:14 -04:00
parent c8af7edb24
commit d62376ce33
2 changed files with 15 additions and 16 deletions

View File

@ -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<KeyedFilter>, 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);

View File

@ -100,7 +100,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
filters = new ArrayList<>(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++) {