Algorithm::HyperLogLog3pm
Implementation of the hyperloglog cardinality estimation algorithm
Usage
use Algorithm::HyperLogLog;my $hll = Algorithm::HyperLogLog->new(14);while(<>){$hll->add($_);}my $cardinality = $hll->estimate(); # Estimate cardinality$hll->dump_to_file('hll_register.dump');# Dumps internal data
Construct object from dumped file.
use Algorithm::HyperLogLog;# Restore internal statemy $hll = Algorithm::HyperLogLog->new_from_file('hll_register.dump');
Overview
This module is implementation of the HyperLogLog algorithm.
HyperLogLog is an algorithm for estimating the cardinality of a set.
Methods
new($b)
Constructor.
`$b` is the parameter for determining register size. (The register size is 2^$b.)
`$b` must be a integer between 4 and 16.
new_from_file($filename)
This method constructs object and restore the internal data of object from dumped file(dumped by dump_to_file() method).
dump_to_file($filename)
This method dumps the internal data of an object to a file.
add($data)
Adds element to the cardinality estimator.
estimate()
Returns estimated cardinality value in floating point number.
merge($other)
Merges the estimate from 'other' into this object, returning the estimate of their union.
register_size()
Return number of register.(In the XS implementation, this equals size in bytes)
XS()
If using XS backend, this method return true value.
Thanks to
MurmurHash3(<https://github.com/PeterScott/murmur3>)
- Austin Appleby
- Peter Scott
Releases
2 releases since Debian 12 (Bookworm); the text changed 1 time.