Serialize doc counts in Matrix-Stats module

This fixes a bug in the RunningStats class for the matrix stats aggregation module. doc counts were not being searlized which means they were only computed the first time the aggregation was computed. This was causing incorrect results when the aggregation was pulled from cache.
This commit is contained in:
Nicholas Knize 2016-08-01 13:56:12 -05:00
parent a7e68e36cf
commit 63f33e0f1e
1 changed files with 4 additions and 0 deletions

View File

@ -78,6 +78,8 @@ public class RunningStats implements Writeable, Cloneable {
@SuppressWarnings("unchecked")
public RunningStats(StreamInput in) throws IOException {
this();
// read doc count
docCount = (Long)in.readGenericValue();
// read fieldSum
fieldSum = (HashMap<String, Double>)in.readGenericValue();
// counts
@ -96,6 +98,8 @@ public class RunningStats implements Writeable, Cloneable {
@Override
public void writeTo(StreamOutput out) throws IOException {
// marshall doc count
out.writeGenericValue(docCount);
// marshall fieldSum
out.writeGenericValue(fieldSum);
// counts