hyperloglog-0.2.1: An approximate streaming (constant space) unique object counter

Portabilitynon-portable
Stabilityexperimental
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellNone

Data.HyperLogLog

Contents

Description

Synopsis

HyperLogLog

data HyperLogLog p Source

Initialize a new counter:

>>> mempty :: HyperLogLog $(3)
HyperLogLog {runHyperLogLog = fromList [0,0,0,0,0,0,0,0]}

Please note how you specify a counter size with the $(n) invocation. Sizes of up to 16 are valid, with 7 being a likely good minimum for decent accuracy.

Let's count a list of unique items and get the latest estimate:

>>> size (foldr insert mempty [1..10] :: HyperLogLog $(4))
Approximate {_confidence = 0.9972, _lo = 2, _estimate = 11, _hi = 20}

Note how insert can be used to add new observations to the approximate counter.

class HasHyperLogLog t p | t -> p whereSource

Instances

size :: ReifiesConfig p => HyperLogLog p -> Approximate Int64Source

Approximate size of our set

Config

data Config Source

Constants required for a bucketing factor b

hll :: Int -> ConfigSource

Precalculate constants for a given bucketing factor b

ReifiesConfig

reifyConfig :: Int -> (forall o. ReifiesConfig o => Proxy o -> r) -> rSource