public class SparseHyperLogLogEncoder extends Object implements HyperLogLogEncoder, Versioned
The implementation is using a fixed p' = 25 which according to [1] provides very high accuracy for the range of cardinalities where the sparse representation is used.
Constructor and Description |
---|
SparseHyperLogLogEncoder() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(long hash)
Aggregates the hash value in the HyperLogLog registers, and returns a hint if the
operation might have affected the cardinality, it is just a hint, and it relies to
the respective implementation.
|
long |
estimate()
Computes a new estimate for the current status of the registers.
|
com.hazelcast.cardinality.impl.hyperloglog.impl.HyperLogLogEncoding |
getEncodingType()
Returns the encoding type of this instance; see:
HyperLogLogEncoding |
int |
getFactoryId()
Returns DataSerializableFactory factory ID for this class.
|
int |
getId()
Returns type identifier for this class.
|
int |
getMemoryFootprint()
Returns the size in memory occupied (in bytes) for this implementation of HyperLogLog.
|
void |
init(int p,
com.hazelcast.cardinality.impl.hyperloglog.impl.SparseHyperLogLogEncoder.VariableLengthDiffArray register) |
HyperLogLogEncoder |
merge(HyperLogLogEncoder encoder)
Merge the two HyperLogLog structures in one.
|
void |
readData(ObjectDataInput in)
Reads fields from the input stream
|
void |
writeData(ObjectDataOutput out)
Writes object fields to output stream
|
public void init(int p, com.hazelcast.cardinality.impl.hyperloglog.impl.SparseHyperLogLogEncoder.VariableLengthDiffArray register)
public boolean add(long hash)
HyperLogLogEncoder
add
in interface HyperLogLogEncoder
hash
- the value to aggregatepublic long estimate()
HyperLogLogEncoder
estimate
in interface HyperLogLogEncoder
public HyperLogLogEncoder merge(HyperLogLogEncoder encoder)
HyperLogLogEncoder
merge
in interface HyperLogLogEncoder
encoder
- The second HLL to be merged into this oneHyperLogLogEncoder
the unionpublic int getFactoryId()
IdentifiedDataSerializable
getFactoryId
in interface IdentifiedDataSerializable
public int getId()
IdentifiedDataSerializable
getId
in interface IdentifiedDataSerializable
public void writeData(ObjectDataOutput out) throws IOException
DataSerializable
writeData
in interface DataSerializable
out
- outputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.public void readData(ObjectDataInput in) throws IOException
DataSerializable
readData
in interface DataSerializable
in
- inputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
input stream has been closed.public com.hazelcast.cardinality.impl.hyperloglog.impl.HyperLogLogEncoding getEncodingType()
HyperLogLogEncoder
HyperLogLogEncoding
getEncodingType
in interface HyperLogLogEncoder
HyperLogLogEncoding
public int getMemoryFootprint()
HyperLogLogEncoder
getMemoryFootprint
in interface HyperLogLogEncoder
Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.