aggregate

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result added in v3.1.1

type Result struct {
	Total float64
	Min   float64
	Max   float64
	Avg   float64
	Count uint64
	Last  float64
}

func NewResult added in v3.1.1

func NewResult() *Result

func (*Result) Get added in v3.1.1

func (r *Result) Get() *Result

func (*Result) Merge added in v3.1.1

func (r *Result) Merge(o *Result)

func (*Result) Update added in v3.1.1

func (r *Result) Update(v float64)

type TimeWindowAggregator added in v3.1.1

type TimeWindowAggregator struct {
	// contains filtered or unexported fields
}

TimeWindowAggregator wrappers sliding window to aggregate data.

It is concurrent-safe. It uses custom struct aggregator to aggregate data. The window is divided into several panes, and each pane's value is an aggregator instance.

func NewTimeWindowAggregator added in v3.1.1

func NewTimeWindowAggregator(paneCount int, timeWindowSeconds int64) *TimeWindowAggregator

func (*TimeWindowAggregator) Add added in v3.1.1

func (t *TimeWindowAggregator) Add(v float64)

Add adds a value to the sliding window's current pane.

func (*TimeWindowAggregator) Result added in v3.1.1

func (t *TimeWindowAggregator) Result() *Result

Result returns the aggregate result of the sliding window by aggregating all panes.

type TimeWindowCounter added in v3.1.1

type TimeWindowCounter struct {
	// contains filtered or unexported fields
}

TimeWindowCounter wrappers sliding window around a counter.

It is concurrent-safe. When it works for calculating QPS, the counter's value means the number of requests in a pane.

func NewTimeWindowCounter added in v3.1.1

func NewTimeWindowCounter(paneCount int, timeWindowSeconds int64) *TimeWindowCounter

func (*TimeWindowCounter) Add added in v3.1.1

func (t *TimeWindowCounter) Add(step float64)

Add adds a step to the counter.

func (*TimeWindowCounter) Count added in v3.1.1

func (t *TimeWindowCounter) Count() float64

Count returns the sum of all panes' value.

func (*TimeWindowCounter) Inc added in v3.1.1

func (t *TimeWindowCounter) Inc()

Inc increments the counter by 1.

func (*TimeWindowCounter) LivedSeconds added in v3.1.1

func (t *TimeWindowCounter) LivedSeconds() int64

LivedSeconds returns the lived seconds of the sliding window.

type TimeWindowQuantile

type TimeWindowQuantile struct {
	// contains filtered or unexported fields
}

TimeWindowQuantile wrappers sliding window around T-Digest.

It is concurrent safe. It uses T-Digest algorithm to calculate quantile. The window is divided into several panes, and each pane's value is a TDigest instance.

func NewTimeWindowQuantile

func NewTimeWindowQuantile(compression float64, paneCount int, timeWindowSeconds int64) *TimeWindowQuantile

func (*TimeWindowQuantile) Add

func (t *TimeWindowQuantile) Add(value float64)

Add adds a value to the sliding window's current pane.

func (*TimeWindowQuantile) Quantile

func (t *TimeWindowQuantile) Quantile(q float64) float64

Quantile returns a quantile of the sliding window by merging all panes.

func (*TimeWindowQuantile) Quantiles

func (t *TimeWindowQuantile) Quantiles(qs []float64) []float64

Quantiles returns quantiles of the sliding window by merging all panes.

Jump to

Keyboard shortcuts

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