SemanticMetricDistribution implements Distribution { @Override public java.nio.ByteBuffer getValueAndFlush() { TDigest curVal; synchronized (this) { curVal = distRef.getAndSet(create()); } ByteBuffer byteBuffer = ByteBuffer.allocate(curVal.smallByteSize()); curVal.asSmallBytes(byteBuffer); return byteBuffer; } SemanticMetricDistribution(); @Override synchronized void record(double val); @Override java.nio.ByteBuffer getValueAndFlush(); @Override long getCount();  }
@Test public void testGetValueAndFlush(){ Arrays.stream(period1Data).forEach(t->distribution.record(t)); TDigest periode1tDigest = distribution.tDigest(); distribution.getValueAndFlush(); Arrays.stream(period1Data).forEach(t->distribution.record(t) ); assertEquals(period1Data.length, distribution.getCount()); TDigest periode2Digest = distribution.tDigest(); assertNotEquals(periode1tDigest,periode2Digest); }