Skip to content

Commit

Permalink
Serialize bucket keys as strings as opposed to optional strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtibshirani committed May 27, 2018
1 parent b5af95b commit 7b58a8a
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.elasticsearch.search.aggregations.bucket.range;

import org.elasticsearch.Version;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.XContentBuilder;
Expand Down Expand Up @@ -168,7 +169,11 @@ private static String generateKey(double from, double to, DocValueFormat format)

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(key);
if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) {
out.writeString(key);
} else {
out.writeOptionalString(key);
}
out.writeDouble(from);
out.writeDouble(to);
out.writeVLong(docCount);
Expand Down Expand Up @@ -254,7 +259,9 @@ public InternalRange(StreamInput in) throws IOException {
int size = in.readVInt();
List<B> ranges = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
String key = in.readOptionalString();
String key = in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)
? in.readString()
: in.readOptionalString();
ranges.add(getFactory().createBucket(key, in.readDouble(), in.readDouble(), in.readVLong(),
InternalAggregations.readAggregations(in), keyed, format));
}
Expand Down

0 comments on commit 7b58a8a

Please sign in to comment.