Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | Edward Kmett <[email protected]> |
Safe Haskell | None |
Data.HyperLogLog
Contents
Description
See the original paper for details: http://algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf
- data HyperLogLog p
- class HasHyperLogLog t p | t -> p where
- hyperLogLog :: Lens' t (HyperLogLog p)
- size :: ReifiesConfig p => HyperLogLog p -> Approximate Int64
- intersectionSize :: ReifiesConfig p => [HyperLogLog p] -> Approximate Int64
- cast :: forall p q. (ReifiesConfig p, ReifiesConfig q) => HyperLogLog p -> Maybe (HyperLogLog q)
- data Config
- hll :: Int -> Config
- class ReifiesConfig o
- reifyConfig :: Int -> (forall o. ReifiesConfig o => Proxy o -> r) -> r
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.
Instances
HasHyperLogLog k (HyperLogLog k p0) p0 | |
Eq (HyperLogLog k p) | |
Show (HyperLogLog k p) | |
Generic (HyperLogLog k p) | |
ReifiesConfig k p => Monoid (HyperLogLog k p) | |
Serialize (HyperLogLog k p) | |
Semigroup (HyperLogLog k p) | |
ReifiesConfig k p => HasConfig (HyperLogLog k p) |
class HasHyperLogLog t p | t -> p whereSource
Methods
hyperLogLog :: Lens' t (HyperLogLog p)Source
Instances
HasHyperLogLog k (HyperLogLog k p0) p0 |
size :: ReifiesConfig p => HyperLogLog p -> Approximate Int64Source
Approximate size of our set
intersectionSize :: ReifiesConfig p => [HyperLogLog p] -> Approximate Int64Source
cast :: forall p q. (ReifiesConfig p, ReifiesConfig q) => HyperLogLog p -> Maybe (HyperLogLog q)Source
Config
Constants required for a bucketing factor b
ReifiesConfig
class ReifiesConfig o Source
Instances
SingRep Nat n Integer => ReifiesConfig Nat n | |
Reifies * n Int => ReifiesConfig * (D n) | |
Reifies * n Int => ReifiesConfig * (SD n) |
reifyConfig :: Int -> (forall o. ReifiesConfig o => Proxy o -> r) -> rSource