public abstract class HyperLogLogCollector extends Object implements Comparable<HyperLogLogCollector>
for (int i = 1; i < 20; ++i) {
System.out.printf("i[%,d], val[%,d] => error[%f%%]%n", i, 2 << i, 104 / Math.sqrt(2 << i));
}
This class is *not* multi-threaded. It can be passed among threads, but it is written with the assumption that
only one thread is ever calling methods on it.
If you have multiple threads calling methods on this concurrently, I hope you manage to get correct behavior.
Note that despite the non-thread-safety of this class, it is actually currently used by multiple threads during
realtime indexing. HyperUniquesAggregator's "aggregate" and "get" methods can be called simultaneously by
OnheapIncrementalIndex, since its "doAggregate" and "getMetricObjectValue" methods are not synchronized. So, watch
out for that.Modifier and Type | Field and Description |
---|---|
static int |
BITS_FOR_BUCKETS |
static double |
CORRECTION_PARAMETER |
static int |
DENSE_THRESHOLD |
static double |
HIGH_CORRECTION_THRESHOLD |
static double |
LOW_CORRECTION_THRESHOLD |
static int |
NUM_BUCKETS |
static int |
NUM_BYTES_FOR_BUCKETS |
Constructor and Description |
---|
HyperLogLogCollector(ByteBuffer byteBuffer) |
Modifier and Type | Method and Description |
---|---|
void |
add(byte[] hashedValue) |
void |
add(short bucket,
byte positionOf1) |
static double |
applyCorrection(double e,
int zeroCount) |
int |
compareTo(HyperLogLogCollector other) |
boolean |
equals(Object o) |
static double |
estimateByteBuffer(ByteBuffer buf) |
double |
estimateCardinality() |
HyperLogLogCollector |
fold(ByteBuffer buffer) |
HyperLogLogCollector |
fold(HyperLogLogCollector other) |
protected int |
getInitPosition() |
static int |
getLatestNumBytesForDenseStorage() |
abstract short |
getMaxOverflowRegister() |
abstract byte |
getMaxOverflowValue() |
abstract int |
getNumBytesForDenseStorage() |
abstract int |
getNumHeaderBytes() |
abstract short |
getNumNonZeroRegisters() |
abstract int |
getPayloadBytePosition() |
abstract int |
getPayloadBytePosition(ByteBuffer buffer) |
abstract byte |
getRegisterOffset() |
protected ByteBuffer |
getStorageBuffer() |
abstract byte |
getVersion() |
int |
hashCode() |
static HyperLogLogCollector |
makeCollector(ByteBuffer buffer)
Create a wrapper object around an HLL sketch contained within a buffer.
|
static HyperLogLogCollector |
makeCollectorSharingStorage(HyperLogLogCollector otherCollector)
Creates new collector which shares others collector buffer (by using
ByteBuffer.duplicate() ) |
static byte[] |
makeEmptyVersionedByteArray() |
static HyperLogLogCollector |
makeLatestCollector() |
abstract void |
setMaxOverflowRegister(ByteBuffer buffer,
short register) |
abstract void |
setMaxOverflowRegister(short register) |
abstract void |
setMaxOverflowValue(byte value) |
abstract void |
setMaxOverflowValue(ByteBuffer buffer,
byte value) |
abstract void |
setNumNonZeroRegisters(ByteBuffer buffer,
short numNonZeroRegisters) |
abstract void |
setNumNonZeroRegisters(short numNonZeroRegisters) |
abstract void |
setRegisterOffset(byte registerOffset) |
abstract void |
setRegisterOffset(ByteBuffer buffer,
byte registerOffset) |
abstract void |
setVersion(ByteBuffer buffer) |
byte[] |
toByteArray() |
ByteBuffer |
toByteBuffer() |
String |
toString() |
public static final int DENSE_THRESHOLD
public static final int BITS_FOR_BUCKETS
public static final int NUM_BUCKETS
public static final int NUM_BYTES_FOR_BUCKETS
public static final double LOW_CORRECTION_THRESHOLD
public static final double HIGH_CORRECTION_THRESHOLD
public static final double CORRECTION_PARAMETER
public HyperLogLogCollector(ByteBuffer byteBuffer)
public static HyperLogLogCollector makeLatestCollector()
public static HyperLogLogCollector makeCollector(ByteBuffer buffer)
buffer
- buffer containing an HLL sketch starting at its position and ending at its limitpublic static HyperLogLogCollector makeCollectorSharingStorage(HyperLogLogCollector otherCollector)
ByteBuffer.duplicate()
)otherCollector
- collector which buffer will be sharedpublic static int getLatestNumBytesForDenseStorage()
public static byte[] makeEmptyVersionedByteArray()
public static double applyCorrection(double e, int zeroCount)
public static double estimateByteBuffer(ByteBuffer buf)
public abstract byte getVersion()
public abstract void setVersion(ByteBuffer buffer)
public abstract byte getRegisterOffset()
public abstract void setRegisterOffset(byte registerOffset)
public abstract void setRegisterOffset(ByteBuffer buffer, byte registerOffset)
public abstract short getNumNonZeroRegisters()
public abstract void setNumNonZeroRegisters(short numNonZeroRegisters)
public abstract void setNumNonZeroRegisters(ByteBuffer buffer, short numNonZeroRegisters)
public abstract byte getMaxOverflowValue()
public abstract void setMaxOverflowValue(byte value)
public abstract void setMaxOverflowValue(ByteBuffer buffer, byte value)
public abstract short getMaxOverflowRegister()
public abstract void setMaxOverflowRegister(short register)
public abstract void setMaxOverflowRegister(ByteBuffer buffer, short register)
public abstract int getNumHeaderBytes()
public abstract int getNumBytesForDenseStorage()
public abstract int getPayloadBytePosition()
public abstract int getPayloadBytePosition(ByteBuffer buffer)
protected int getInitPosition()
protected ByteBuffer getStorageBuffer()
public void add(byte[] hashedValue)
public void add(short bucket, byte positionOf1)
public HyperLogLogCollector fold(HyperLogLogCollector other)
public HyperLogLogCollector fold(ByteBuffer buffer)
public ByteBuffer toByteBuffer()
public byte[] toByteArray()
public double estimateCardinality()
public int compareTo(HyperLogLogCollector other)
compareTo
in interface Comparable<HyperLogLogCollector>
Copyright © 2011–2017. All rights reserved.