@Override public int maxLength() { return current().maxLength(); }
@Test public void testBasic() { PercentileSerializer serializer = new PercentileSerializer(DataType.getType("percentile(100)")); PercentileCounter counter = new PercentileCounter(100, 0.5); Random random = new Random(); for (int i = 0; i < 1000; i++) { counter.add(random.nextDouble()); } double markResult = counter.getResultEstimate(); ByteBuffer buffer = ByteBuffer.allocateDirect(serializer.getStorageBytesEstimate()); serializer.serialize(counter, buffer); buffer.flip(); counter = serializer.deserialize(buffer); PercentileCounter counter1 = new PercentileCounter(100, 0.5); counter1.merge(counter); assertEquals(markResult, counter1.getResultEstimate(), 0.01); }
@Override protected double getStorageBytesEstimate(double count) { return current().getBytesEstimate(count); }
@Override public int peekLength(ByteBuffer in) { return current().peekLength(in); }
@Override public int getStorageBytesEstimate() { return current().getBytesEstimate(); }
@Override public int peekLength(ByteBuffer in) { return current().peekLength(in); }
@Override protected double getStorageBytesEstimate(double count) { return current().getBytesEstimate(count); }
@Override public int maxLength() { return current().maxLength(); }
@Override public int getStorageBytesEstimate() { return current().getBytesEstimate(); }