Version: v0.0.0-...-24d4c76 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2018 License: BSD-3-Clause Imports: 5 Imported by: 0




View Source
const EPSILON float64 = 0.01

EPSILON is the precision of the rank returned by our quantile queries


This section is empty.


This section is empty.


type Entry

type Entry struct {
	V     float64 `json:"v"`
	G     int     `json:"g"`
	Delta int     `json:"delta"`

Entry is an element of the skiplist, see GK paper for description

type Skiplist

type Skiplist struct {
	// contains filtered or unexported fields

Skiplist is a pseudo-random data structure used to store nodes and find quickly what we want

func NewSkiplist

func NewSkiplist() *Skiplist

NewSkiplist returns a new empty Skiplist

func (*Skiplist) Insert

func (s *Skiplist) Insert(e Entry) *SkiplistNode

Insert adds a new Entry to the Skiplist and yields a pointer to the node where the data was inserted

func (*Skiplist) Remove

func (s *Skiplist) Remove(node *SkiplistNode)

Remove removes a node from the Skiplist

type SkiplistNode

type SkiplistNode struct {
	// contains filtered or unexported fields

SkiplistNode is holding the actual value and pointers to the neighbor nodes

type SliceSummary

type SliceSummary struct {
	Entries []Entry
	N       int

SliceSummary is a GK-summary with a slice backend

func NewSliceSummary

func NewSliceSummary() *SliceSummary

NewSliceSummary allocates a new GK summary backed by a DLL

func WeighSummary

func WeighSummary(s *SliceSummary, weight float64) *SliceSummary

WeighSummary applies a weight factor to a slice summary and return it as a new slice.

func (*SliceSummary) BySlices

func (s *SliceSummary) BySlices() []SummarySlice

BySlices returns a slice of Summary slices that represents weighted ranges of values e.g. [0, 1] : 3

[1, 23] : 12 ...

The number of intervals is related to the precision kept in the internal data structure to ensure epsilon*s.N precision on quantiles, but it's bounded. When the bounds of the interval are equal, the weight is the number of times that exact value was inserted in the summary.

func (*SliceSummary) Copy

func (s *SliceSummary) Copy() *SliceSummary

Copy allocates a new summary with the same data

func (*SliceSummary) Insert

func (s *SliceSummary) Insert(v float64, t uint64)

Insert inserts a new value v in the summary paired with t (the ID of the span it was reported from)

func (*SliceSummary) Merge

func (s *SliceSummary) Merge(s2 *SliceSummary)

Merge two summaries entries together

func (*SliceSummary) Quantile

func (s *SliceSummary) Quantile(q float64) float64

Quantile returns an EPSILON estimate of the element at quantile 'q' (0 <= q <= 1)

func (SliceSummary) String

func (s SliceSummary) String() string

type SummarySlice

type SummarySlice struct {
	Start  float64
	End    float64
	Weight int

SummarySlice reprensents how many values are in a [Start, End] range

func BySlicesWeighted

func BySlicesWeighted(summaries ...WeightedSliceSummary) []SummarySlice

BySlicesWeighted BySlices() is the BySlices version but combines multiple weighted slice summaries before returning the histogram

type WeightedSliceSummary

type WeightedSliceSummary struct {
	Weight float64

WeightedSliceSummary associates a weight to a slice summary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL