Skip to content

Repository files navigation

Native HyperLogLog for node.js

See http://en.wikipedia.org/wiki/HyperLogLog.

Based on https://github.com/avz/hll.

Example

varHLL=require('hll-native').HLL;vartries=5;for(varn=0;n<tries;n++){varstart=Date.now();varo={};varobj=newHLL(20);for(vari=0;i<10000000;i++){obj.add('hello_'+i);}console.log('['+(n+1)+' / '+tries+']','Approximated set size:',obj.count()+'.','Elapsed time:',Date.now()-start,'ms');}
[1 / 5] Approximated set size: 10000341. Elapsed time: 2142 ms
[2 / 5] Approximated set size: 10000341. Elapsed time: 2133 ms
[3 / 5] Approximated set size: 10000341. Elapsed time: 2142 ms
[4 / 5] Approximated set size: 10000341. Elapsed time: 2121 ms
[5 / 5] Approximated set size: 10000341. Elapsed time: 2118 ms

Memory usage and error values

bitssize (bytes)standard error
41626.00%
53218.38%
66413.00%
71289.19%
82566.50%
95124.60%
1010243.25%
1120482.30%
1240961.62%
1381921.15%
14163840.81%
15327680.57%
16655360.41%
171310720.29%
182621440.20%
195242880.14%
2010485760.10%

Prototype

/** * Create new HyperLogLog storage with specified size and standard error. * * Memory usage for storage calculated as (1 << bits) bytes. * Standard error described in table above * * @param {number} bits */varHLL=function(bits){};/** * Add key to storage * @param {string} key */HLL.prototype.add=function(key){};/** * Get approximated set size with selected standard error * @returns {number} */HLL.prototype.count=function(){};

About

Native (plain C and C++) HLL implementation for node.js

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages