don't assume bytebuffer limit is set

This commit is contained in:
Xavier Léauté 2014-03-27 15:58:34 -07:00
parent 21e54d8060
commit 03c51518bc
1 changed files with 3 additions and 1 deletions

View File

@ -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);