aggregate

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 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

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

func NewResult

func NewResult() *Result

func (*Result) Get

func (r *Result) Get() *Result

func (*Result) Merge

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

func (*Result) Update

func (r *Result) Update(v float64)

type TimeWindowAggregator

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

func NewTimeWindowAggregator(paneCount int, timeWindowSeconds int64) *TimeWindowAggregator

func (*TimeWindowAggregator) Add

func (t *TimeWindowAggregator) Add(v float64)

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

func (*TimeWindowAggregator) Result

func (t *TimeWindowAggregator) Result() *Result

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

type TimeWindowCounter

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

func NewTimeWindowCounter(paneCount int, timeWindowSeconds int64) *TimeWindowCounter

func (*TimeWindowCounter) Add

func (t *TimeWindowCounter) Add(step float64)

Add adds a step to the counter.

func (*TimeWindowCounter) Count

func (t *TimeWindowCounter) Count() float64

Count returns the sum of all panes' value.

func (*TimeWindowCounter) Inc

func (t *TimeWindowCounter) Inc()

Inc increments the counter by 1.

func (*TimeWindowCounter) LivedSeconds

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