From c92fd6f45d05237ef383abbc07a1918c44be9dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Wed, 26 Mar 2014 17:13:41 -0700 Subject: [PATCH] folding into direct buffers is faster --- .../hyperloglog/HyperUniquesBufferAggregator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 290fe35a370..143e68dece2 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,10 +66,11 @@ public class HyperUniquesBufferAggregator implements BufferAggregator @Override public Object get(ByteBuffer buf, int position) { - ByteBuffer dataCopyBuffer = ByteBuffer.allocate(HyperLogLogCollector.getLatestNumBytesForDenseStorage()); + ByteBuffer dataCopyBuffer = ByteBuffer.allocateDirect(HyperLogLogCollector.getLatestNumBytesForDenseStorage()); ByteBuffer mutationBuffer = buf.duplicate(); mutationBuffer.position(position); - mutationBuffer.get(dataCopyBuffer.array()); + dataCopyBuffer.put(mutationBuffer); + dataCopyBuffer.rewind(); return HyperLogLogCollector.makeCollector(dataCopyBuffer); }