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();
public HLLCV0()
protected HLLCV0()
{
super(defaultStorageBuffer);
}
public HLLCV0(ByteBuffer buffer)
protected HLLCV0(ByteBuffer buffer)
{
super(buffer);
}
@ -149,4 +149,4 @@ public class HLLCV0 extends HyperLogLogCollector
{
return buffer.position() + HEADER_NUM_BYTES;
}
}
}

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})
.asReadOnlyBuffer();
public HLLCV1()
protected HLLCV1()
{
super(defaultStorageBuffer);
}
public HLLCV1(ByteBuffer buffer)
protected HLLCV1(ByteBuffer buffer)
{
super(buffer);
}

View File

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