Skip to content

Commit b5af95b

Browse files
committed
Pull the stream serialization logic for buckets into the Bucket class.
1 parent 2fdeb31 commit b5af95b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static class Bucket extends InternalMultiBucketAggregation.InternalBucket
4747
protected final double from;
4848
protected final double to;
4949
private final long docCount;
50-
final InternalAggregations aggregations;
50+
private final InternalAggregations aggregations;
5151
private final String key;
5252

5353
public Bucket(String key, double from, double to, long docCount, InternalAggregations aggregations, boolean keyed,
@@ -168,6 +168,11 @@ private static String generateKey(double from, double to, DocValueFormat format)
168168

169169
@Override
170170
public void writeTo(StreamOutput out) throws IOException {
171+
out.writeOptionalString(key);
172+
out.writeDouble(from);
173+
out.writeDouble(to);
174+
out.writeVLong(docCount);
175+
aggregations.writeTo(out);
171176
}
172177

173178
@Override
@@ -262,11 +267,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
262267
out.writeBoolean(keyed);
263268
out.writeVInt(ranges.size());
264269
for (B bucket : ranges) {
265-
out.writeOptionalString(((Bucket) bucket).key);
266-
out.writeDouble(bucket.from);
267-
out.writeDouble(bucket.to);
268-
out.writeVLong(((Bucket) bucket).docCount);
269-
bucket.aggregations.writeTo(out);
270+
bucket.writeTo(out);
270271
}
271272
}
272273

0 commit comments

Comments
 (0)