HyperLogLog, a distinct values estimator, in erlang
[HyperLogLog] paper [HyperLogLog]: algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf "HyperLogLog"
./rebar compile
or
make
- Initialize
New = ehyperloglog:new(16).
- 10000 distinct values
HLL = lists:foldl(fun ehyperloglog:update/2, New, lists:seq(1,100000)).
- Should give an estimate close to 100000
ehyperloglog:cardinality(HLL).
A compact erlang bitstring for storing integers exposing 0-based array like interface.
- A length 3 bitmap 4-bits cell width
B = bitmap:new(3, 4).
- Set cell 1 to 7
B1 = bitmap:set(B, 1, 7).
7 = bitmap:get(B1, 1).
- Set cell 1 to 17 (overflow)
B2 = bitmap:set(B1, 1, 17).
1 = bitmap:get(B2, 1). %% truncated to 1
./rebar eunit