From df3fb07e51308d8a05b2860c6515e9ccab012e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Thu, 22 May 2014 17:48:19 -0700 Subject: [PATCH] test for correct bytebuffer folding --- .../hyperloglog/HyperLogLogCollectorTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/processing/src/test/java/io/druid/query/aggregation/hyperloglog/HyperLogLogCollectorTest.java b/processing/src/test/java/io/druid/query/aggregation/hyperloglog/HyperLogLogCollectorTest.java index 8b6839fa26..acf775d1cd 100644 --- a/processing/src/test/java/io/druid/query/aggregation/hyperloglog/HyperLogLogCollectorTest.java +++ b/processing/src/test/java/io/druid/query/aggregation/hyperloglog/HyperLogLogCollectorTest.java @@ -298,6 +298,24 @@ public class HyperLogLogCollectorTest } } + @Test + public void testBufferSwap() throws Exception + { + ByteBuffer biggerOffset = makeCollectorBuffer(1, (byte) 0x00, 0x11); + ByteBuffer smallerOffset = makeCollectorBuffer(0, (byte) 0x20, 0x00); + + ByteBuffer buffer = ByteBuffer.allocate(HyperLogLogCollector.getLatestNumBytesForDenseStorage()); + HyperLogLogCollector collector = HyperLogLogCollector.makeCollector(buffer); + + // make sure the original buffer gets modified + collector.fold(biggerOffset); + Assert.assertEquals(collector, HyperLogLogCollector.makeCollector(buffer)); + + // make sure the original buffer gets modified + collector.fold(smallerOffset); + Assert.assertEquals(collector, HyperLogLogCollector.makeCollector(buffer)); + } + @Test public void testFoldWithArbitraryInitialPositions() throws Exception { -- GitLab