data-sketches-core-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

DataSketches.Quantiles.RelativeErrorQuantile.Internal

Synopsis

Documentation

data ReqSketch s Source #

This Relative Error Quantiles Sketch is the Haskell implementation based on the paper "Relative Error Streaming Quantiles", https://arxiv.org/abs/2004.01668, and loosely derived from a Python prototype written by Pavel Vesely, ported from the Java equivalent.

This implementation differs from the algorithm described in the paper in the following:

The algorithm requires no upper bound on the stream length. Instead, each relative-compactor counts the number of compaction operations performed so far (via variable state). Initially, the relative-compactor starts with INIT_NUMBER_OF_SECTIONS. Each time the number of compactions (variable state) exceeds 2^{numSections - 1}, we double numSections. Note that after merging the sketch with another one variable state may not correspond to the number of compactions performed at a particular level, however, since the state variable never exceeds the number of compactions, the guarantees of the sketch remain valid.

The size of each section (variable k and sectionSize in the code and parameter k in the paper) is initialized with a value set by the user via variable k. When the number of sections doubles, we decrease sectionSize by a factor of sqrt(2). This is applied at each level separately. Thus, when we double the number of sections, the nominal compactor size increases by a factor of approx. sqrt(2) (+/- rounding).

The merge operation here does not perform "special compactions", which are used in the paper to allow for a tight mathematical analysis of the sketch.

This implementation provides a number of capabilities not discussed in the paper or provided in the Python prototype.

The Python prototype only implemented high accuracy for low ranks. This implementation provides the user with the ability to choose either high rank accuracy or low rank accuracy at the time of sketch construction.

  • The Python prototype only implemented a comparison criterion of "<". This implementation allows the user to switch back and forth between the "<=" criterion and the "<=" criterion.

Instances

Instances details
TakeSnapshot ReqSketch Source # 
Instance details

Defined in DataSketches.Quantiles.RelativeErrorQuantile.Internal

Associated Types

type Snapshot ReqSketch Source #

Generic (ReqSketch s) Source # 
Instance details

Defined in DataSketches.Quantiles.RelativeErrorQuantile.Internal

Associated Types

type Rep (ReqSketch s) :: Type -> Type #

Methods

from :: ReqSketch s -> Rep (ReqSketch s) x #

to :: Rep (ReqSketch s) x -> ReqSketch s #

NFData (ReqSketch s) Source # 
Instance details

Defined in DataSketches.Quantiles.RelativeErrorQuantile.Internal

Methods

rnf :: ReqSketch s -> () #

type Snapshot ReqSketch Source # 
Instance details

Defined in DataSketches.Quantiles.RelativeErrorQuantile.Internal

type Rep (ReqSketch s) Source # 
Instance details

Defined in DataSketches.Quantiles.RelativeErrorQuantile.Internal

type Rep (ReqSketch s) = D1 ('MetaData "ReqSketch" "DataSketches.Quantiles.RelativeErrorQuantile.Internal" "data-sketches-core-0.1.0.0-K1LiaULOxj5Koi8kxDJo0H" 'False) (C1 ('MetaCons "ReqSketch" 'PrefixI 'True) (((S1 ('MetaSel ('Just "k") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: (S1 ('MetaSel ('Just "rankAccuracySetting") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RankAccuracy) :*: S1 ('MetaSel ('Just "criterion") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Criterion))) :*: (S1 ('MetaSel ('Just "sketchRng") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (Gen s)) :*: (S1 ('MetaSel ('Just "totalN") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (URef s Word64)) :*: S1 ('MetaSel ('Just "minValue") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (URef s Double))))) :*: ((S1 ('MetaSel ('Just "maxValue") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (URef s Double)) :*: (S1 ('MetaSel ('Just "sumValue") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (URef s Double)) :*: S1 ('MetaSel ('Just "retainedItems") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (URef s Int)))) :*: (S1 ('MetaSel ('Just "maxNominalCapacitiesSize") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (URef s Int)) :*: (S1 ('MetaSel ('Just "aux") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (MutVar s (Maybe ReqAuxiliary))) :*: S1 ('MetaSel ('Just "compactors") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (MutVar s (Vector (ReqCompactor s)))))))))

count :: PrimMonad m => ReqSketch (PrimState m) -> m Word64 Source #

Get the total number of items inserted into the sketch