redis-hll

A Redis backed HyperLogLog implementation for node.js.

npm install redis-hll
4 downloads in the last week
8 downloads in the last month

redis-hll

A Redis backed HyperLogLog implementation for node.js, basically ported from hyperloglog-redis.

Install

npm install redis-hll

Usage

// dependencies

var redis = require('redis').createClient();
var hll = require('redis-hll')(redis);
var assert = require('assert');

// create a new counter

var counter = hll.counter('beatles');

// add some values

var beatles = ['john', 'paul', 'george', 'ringo', 'john', 'paul'];
var n = beatles.length;

beatles.forEach(function(beatle){
  counter.add(beatle, function(err){
    if (err) return next(err);
    --n || next();
  });
});

// fetch the cardinality of the hll

function next(err){
  if (err) return console.error(err);
  counter.count(function(err, total){
    if (err) return console.error(err);
    assert(4 === total);
  });
}

TODO

  • test tons of values
  • unions
  • intersections
  • refactor

License

MIT

npm loves you