remove HLL version specific code outside of HyperLogLogCollector

This commit is contained in:
Xavier Léauté 2014-03-25 11:04:24 -07:00
parent cd340aa314
commit 7dc0e9f1a9
3 changed files with 6 additions and 8 deletions

View File

@ -37,12 +37,12 @@ public class HLLCV0 extends HyperLogLogCollector
private static final ByteBuffer defaultStorageBuffer = ByteBuffer.wrap(new byte[]{0, 0, 0}).asReadOnlyBuffer(); private static final ByteBuffer defaultStorageBuffer = ByteBuffer.wrap(new byte[]{0, 0, 0}).asReadOnlyBuffer();
public HLLCV0() protected HLLCV0()
{ {
super(defaultStorageBuffer); super(defaultStorageBuffer);
} }
public HLLCV0(ByteBuffer buffer) protected HLLCV0(ByteBuffer buffer)
{ {
super(buffer); super(buffer);
} }

View File

@ -44,12 +44,12 @@ public class HLLCV1 extends HyperLogLogCollector
private static final ByteBuffer defaultStorageBuffer = ByteBuffer.wrap(new byte[]{VERSION, 0, 0, 0, 0, 0, 0}) private static final ByteBuffer defaultStorageBuffer = ByteBuffer.wrap(new byte[]{VERSION, 0, 0, 0, 0, 0, 0})
.asReadOnlyBuffer(); .asReadOnlyBuffer();
public HLLCV1() protected HLLCV1()
{ {
super(defaultStorageBuffer); super(defaultStorageBuffer);
} }
public HLLCV1(ByteBuffer buffer) protected HLLCV1(ByteBuffer buffer)
{ {
super(buffer); super(buffer);
} }

View File

@ -121,9 +121,7 @@ public class HyperUniquesSerde extends ComplexMetricSerde
public HyperLogLogCollector fromByteBuffer(ByteBuffer buffer, int numBytes) public HyperLogLogCollector fromByteBuffer(ByteBuffer buffer, int numBytes)
{ {
buffer.limit(buffer.position() + numBytes); buffer.limit(buffer.position() + numBytes);
return HyperLogLogCollector.makeCollector(buffer);
int remaining = buffer.remaining();
return (remaining % 3 == 0 || remaining == 1027) ? new HLLCV0(buffer) : new HLLCV1(buffer);
} }
@Override @Override