diff options
author | Nik Everett <nik9000@gmail.com> | 2016-07-19 14:50:49 -0400 |
---|---|---|
committer | Nik Everett <nik9000@gmail.com> | 2016-07-20 09:46:04 -0400 |
commit | fc4b4396353fffc3b78b1e582d7aeef8ff98d95d (patch) | |
tree | 5e4a411d2ac115928551c043c662dfd9164da4df /core/src/main/java/org/elasticsearch/search/aggregations/pipeline | |
parent | a4f09d2b814595d7cca111cbc59d72fcf2dfb57d (diff) |
Remove AggregationStreams and friends
* Remove outdated aggregation registration method
* Remove AggregationStreams
* Adds StreamInput#readNamedWriteableList and
StreamOutput#writeNamedWriteableList convenience methods. We strive to
make the reading and writing from the streams terse so they are easier
to scan visually.
* Remove PipelineAggregatorStreams
* Remove stream info from InternalAggreation.Type
* Remove InternalAggregation#type
* Remove Streamable from PipelineAggregator
* Remove Streamable from MultiBucketsAggregation.Bucket
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/aggregations/pipeline')
3 files changed, 3 insertions, 113 deletions
diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregator.java index 446b56d07e..f49ca1dd39 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregator.java @@ -24,19 +24,15 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.NamedWriteable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.index.query.QueryParseContext; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregation.ReduceContext; -import org.elasticsearch.search.aggregations.InternalAggregation.Type; import org.elasticsearch.search.aggregations.PipelineAggregationBuilder; import java.io.IOException; import java.util.Map; -public abstract class PipelineAggregator implements Streamable, NamedWriteable { - // NORELEASE remove Streamable - +public abstract class PipelineAggregator implements NamedWriteable { /** * Parse the {@link PipelineAggregationBuilder} from a {@link QueryParseContext}. */ @@ -66,9 +62,6 @@ public abstract class PipelineAggregator implements Streamable, NamedWriteable { private String[] bucketsPaths; private Map<String, Object> metaData; - protected PipelineAggregator() { // for Serialisation - } - protected PipelineAggregator(String name, String[] bucketsPaths, Map<String, Object> metaData) { this.name = name; this.bucketsPaths = bucketsPaths; @@ -85,26 +78,8 @@ public abstract class PipelineAggregator implements Streamable, NamedWriteable { } @Override - public final void readFrom(StreamInput in) throws IOException { - try { - getWriteableName(); // Throws UnsupportedOperationException if this aggregation should be read using old style Streams - assert false : "Used reading constructor instead"; - } catch (UnsupportedOperationException e) { - // OK - } - name = in.readString(); - bucketsPaths = in.readStringArray(); - metaData = in.readMap(); - doReadFrom(in); - } - - protected void doReadFrom(StreamInput in) throws IOException { - throw new UnsupportedOperationException("Use reading constructor instead"); // NORELEASE remove when we remove Streamable - } - - @Override public final void writeTo(StreamOutput out) throws IOException { - out.writeString(name); // NORELEASE remote writing the name - it is automatically handled with writeNamedWriteable + out.writeString(name); out.writeStringArray(bucketsPaths); out.writeMap(metaData); doWriteTo(out); @@ -112,12 +87,6 @@ public abstract class PipelineAggregator implements Streamable, NamedWriteable { protected abstract void doWriteTo(StreamOutput out) throws IOException; - @Override - public String getWriteableName() { - // NORELEASE remove me when all InternalAggregations override it - throw new UnsupportedOperationException("Override on every class"); - } - public String name() { return name; } @@ -130,10 +99,5 @@ public abstract class PipelineAggregator implements Streamable, NamedWriteable { return metaData; } - public Type type() { - // NORELEASE remove this method - throw new UnsupportedOperationException(getClass().getName() + " used type but should Use getWriteableName instead"); - } - public abstract InternalAggregation reduce(InternalAggregation aggregation, ReduceContext reduceContext); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorStreams.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorStreams.java deleted file mode 100644 index ad1dc73f6e..0000000000 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorStreams.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.search.aggregations.pipeline; - -import org.elasticsearch.common.bytes.BytesReference; -import org.elasticsearch.common.io.stream.StreamInput; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Collections.emptyMap; -import static java.util.Collections.unmodifiableMap; - -/** - * A registry for all the dedicated streams in the aggregation module. This is to support dynamic addAggregation that - * know how to stream themselves. - */ -public class PipelineAggregatorStreams { - private static Map<BytesReference, Stream> streams = emptyMap(); - - /** - * A stream that knows how to read an aggregation from the input. - */ - public interface Stream { - PipelineAggregator readResult(StreamInput in) throws IOException; - } - - /** - * Registers the given stream and associate it with the given types. - * - * @param stream The streams to register - * @param types The types associated with the streams - */ - public static synchronized void registerStream(Stream stream, BytesReference... types) { - Map<BytesReference, Stream> newStreams = new HashMap<>(streams); - for (BytesReference type : types) { - newStreams.put(type, stream); - } - streams = unmodifiableMap(newStreams); - } - - /** - * Returns the stream that is registered for the given type - * - * @param type The given type - * @return The associated stream - */ - public static Stream stream(BytesReference type) { - return streams.get(type); - } - -} diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/SiblingPipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/SiblingPipelineAggregator.java index 79ec761b0e..b78691455d 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/SiblingPipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/SiblingPipelineAggregator.java @@ -36,11 +36,6 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; public abstract class SiblingPipelineAggregator extends PipelineAggregator { - - protected SiblingPipelineAggregator() { // NOCOMMIT remove me - super(); - } - protected SiblingPipelineAggregator(String name, String[] bucketsPaths, Map<String, Object> metaData) { super(name, bucketsPaths, metaData); } @@ -83,7 +78,7 @@ public abstract class SiblingPipelineAggregator extends PipelineAggregator { return singleBucketAgg.create(new InternalAggregations(aggs)); } else { throw new IllegalStateException("Aggregation [" + aggregation.getName() + "] must be a bucket aggregation [" - + aggregation.type().name() + "]"); + + aggregation.getWriteableName() + "]"); } } |