Fix GeoCenteriod Aggregation serialization

This commit is contained in:
Simon Willnauer 2015-10-15 09:57:47 +02:00
parent 68561ce55c
commit 5b1ee8bd74
1 changed files with 7 additions and 1 deletions

View File

@ -63,6 +63,7 @@ public class InternalGeoCentroid extends InternalMetricsAggregation implements G
pipelineAggregators, Map<String, Object> metaData) { pipelineAggregators, Map<String, Object> metaData) {
super(name, pipelineAggregators, metaData); super(name, pipelineAggregators, metaData);
this.centroid = centroid; this.centroid = centroid;
assert count >= 0;
this.count = count; this.count = count;
} }
@ -127,8 +128,10 @@ public class InternalGeoCentroid extends InternalMetricsAggregation implements G
@Override @Override
protected void doReadFrom(StreamInput in) throws IOException { protected void doReadFrom(StreamInput in) throws IOException {
count = in.readVLong(); count = in.readVLong();
if (count > 0) { if (in.readBoolean()) {
centroid = GeoPoint.fromIndexLong(in.readLong()); centroid = GeoPoint.fromIndexLong(in.readLong());
} else {
centroid = null;
} }
} }
@ -136,7 +139,10 @@ public class InternalGeoCentroid extends InternalMetricsAggregation implements G
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeVLong(count); out.writeVLong(count);
if (centroid != null) { if (centroid != null) {
out.writeBoolean(true);
out.writeLong(XGeoUtils.mortonHash(centroid.lon(), centroid.lat())); out.writeLong(XGeoUtils.mortonHash(centroid.lon(), centroid.lat()));
} else {
out.writeBoolean(false);
} }
} }