Skip to content

Commit

Permalink
Closes #92 Fixed code and test to do consistent serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
tdunning committed Aug 6, 2017
1 parent 943d8a4 commit d05568e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/tdunning/math/stats/AVLTreeDigest.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public double compression() {
*/
@Override
public int byteSize() {
return 4 + 8 * 2 + 4 + 4 + summary.size() * 12;
return 4 + 8 * 2 + 8 + 4 + summary.size() * 12;
}

/**
Expand All @@ -341,7 +341,7 @@ public void asBytes(ByteBuffer buf) {
buf.putInt(VERBOSE_ENCODING);
buf.putDouble(min);
buf.putDouble(max);
buf.putFloat((float) compression());
buf.putDouble((float) compression());
buf.putInt(summary.size());
for (Centroid centroid : summary) {
buf.putDouble(centroid.mean());
Expand Down
5 changes: 0 additions & 5 deletions src/test/java/com/tdunning/math/stats/TDigestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,6 @@ public void testSerialization() {
dist.asBytes(buf);
assertTrue(buf.position() < 11000);
assertEquals(dist.byteSize(), buf.position());
buf.clear();

dist.asSmallBytes(buf);
assertTrue(buf.position() < 6000);
assertEquals(buf.position(), dist.smallByteSize());

System.out.printf("# big %d bytes\n", buf.position());

Expand Down

0 comments on commit d05568e

Please sign in to comment.