noc.core.quantile.base

Module Contents

noc.core.quantile.base.Sample
noc.core.quantile.base.MAX_FLOAT
class noc.core.quantile.base.Stream(buff_size)

Bases: object

Base class for approximate quantiles compulation

Parameters:n
f(self, r, n)

Error function invariant :param r: Current rank :param n: Total amount of records :return: Error function

_delta(self, r, n)
insert(self, v)

Submit value to stream :param v: :return:

_maybe_sort(self)

Order samples when necessary :return:

flush(self)

Flush unmerged samples into merged stream :return:

_merge(self)

Merge unmerged and merged samples, maintaining merged samples in sorted order :return:

query(self, q)

Query returns computed q-th percentile value. :param q: :return:

reset(self)

Reset all data :return:

class noc.core.quantile.base.BiasedStream(n, epsilon)

Bases: noc.core.quantile.base.Stream

Base class for High- and Low-biased quantiles where needed quantiles are not known a priori, but error guarantees can still be given

Parameters:
  • n
  • epsilon
class noc.core.quantile.base.LowBiasedStream

Bases: noc.core.quantile.base.BiasedStream

Low-biased quantiles (e.g. 0.01, 0.1, 0.5) where the needed quantiles are not knows a priori, but error guarantees can still be given even for lower ranks of data distribution.

The provided epsilon is a relative error, i.e. the true quantile of a value returned by a query is guaranteed to be within (1±Epsilon)*Quantile

f(self, r, n)
class noc.core.quantile.base.HighBiasedStream

Bases: noc.core.quantile.base.BiasedStream

High-biased quantiles (e.g. 0.01, 0.1, 0.5) where the needed quantiles are not knows a priori, but error guarantees can still be given even for higher ranks of data distribution.

The provided epsilon is a relative error, i.e. the true quantile of a value returned by a query is guaranteed to be within 1-(1±Epsilon)*(1-Quantile)

f(self, r, n)
class noc.core.quantile.base.TargetedStream(n, targets)

Bases: noc.core.quantile.base.Stream

NewTargeted returns an initialized Stream concerned with a particular set of quantile values that are supplied a priori. Knowing these a priori reduces space and computation time. The targets map maps the desired quantiles to their absolute errors, i.e. the true quantile of a value returned by a query is guaranteed to be within (Quantile±Epsilon).

Parameters:
  • n
  • targets – List of (quantile, epsilon)
f(self, r, n)
class noc.core.quantile.base.Summary(ttl, n, kls, *args)

Bases: object

Group of time-expiring quantiles. Collects up to n time slots. Summary collects quantiles for ttl, 2 * ttl, .. , n * ttl intervals. i.e. given ttl == 60 and n == 5 Summary will collects quantiles for 1, 2, 3, 4 and 5 minutes intervals.

Parameters:
  • ttl – Slot time-to live in seconds
  • n – Amount of slots to collect
  • klsStream subclass
  • *args

    Stream constructor parameters

register(self, value)

Register measured value to all slots :param value: Floating point collecting values :return:

query(self, q, *args)

Query quantile for given slots :param q: Quantile value :param args: List of slot numbers :return:

_maybe_rotate(self)

Rotate and flush slots when necessary :return: