Giter Site home page Giter Site logo

hyperll's Introduction

Hyperll Build Status Coverage Status

HyperLogLog implementation for Ruby. Originally written in pure Ruby, many pieces were rewritten in C for increased performance.

Usage

HyperLogLog stores an estimation of the cardinality of a set. It can be merged with other HyperLogLog instances.

hll = Hyperll::HyperLogLog.new(10)
hll.offer(1)
hll.offer(2)
hll.offer(3)
hll.cardinality # => 3

hll2 = Hyperll::HyperLogLog.new(10)
hll2.offer(3)
hll2.offer(4)
hll2.offer(5)
hll.cardinality # => 3

merged = Hyperll::HyperLogLog.new(10)
merged.merge(hll, hll2)
merged.cardinality # => 5

Serialization

HyperLogLog can be serialized to a binary string. It is compatible with the binary format from the Java stream-lib library.

hll = Hyperll::HyperLogLog.new(4)
hll.offer(1)
hll.offer(2)
hll.offer(3)
hll.serialize # => "\x00\x00\x00\x04\x00\x00\x00\f\x02\x00\x00\x00\x00\x00\x88\x00\x00\x00\x00\x00"

hll2 = Hyperll::HyperLogLog.unserialize("\x00\x00\x00\x04\x00\x00\x00\f\x02\x00\x00\x00\x00\x00\x88\x00\x00\x00\x00\x00")
hll2.cardinality # => 3

hyperll's People

Contributors

alindeman avatar plprofetes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.