From 03c51518bc5233ce488eb980df23fbcadcaf4a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Thu, 27 Mar 2014 15:58:34 -0700 Subject: [PATCH] don't assume bytebuffer limit is set --- .../aggregation/hyperloglog/HyperUniquesBufferAggregator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/processing/src/main/java/io/druid/query/aggregation/hyperloglog/HyperUniquesBufferAggregator.java b/processing/src/main/java/io/druid/query/aggregation/hyperloglog/HyperUniquesBufferAggregator.java index 143e68dece2..3229e813d6d 100644 --- a/processing/src/main/java/io/druid/query/aggregation/hyperloglog/HyperUniquesBufferAggregator.java +++ b/processing/src/main/java/io/druid/query/aggregation/hyperloglog/HyperUniquesBufferAggregator.java @@ -66,9 +66,11 @@ public class HyperUniquesBufferAggregator implements BufferAggregator @Override public Object get(ByteBuffer buf, int position) { - ByteBuffer dataCopyBuffer = ByteBuffer.allocateDirect(HyperLogLogCollector.getLatestNumBytesForDenseStorage()); + final int size = HyperLogLogCollector.getLatestNumBytesForDenseStorage(); + ByteBuffer dataCopyBuffer = ByteBuffer.allocateDirect(size); ByteBuffer mutationBuffer = buf.duplicate(); mutationBuffer.position(position); + mutationBuffer.limit(position + size); dataCopyBuffer.put(mutationBuffer); dataCopyBuffer.rewind(); return HyperLogLogCollector.makeCollector(dataCopyBuffer);