A Redis backed HyperLogLog implementation for node.js
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
Makefile
README.md
index.js
package.json 0.0.2 May 3, 2013

README.md

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