helper

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: BSD-2-Clause Imports: 14 Imported by: 83

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Backref = regexp.MustCompile(`\\(\d+)`)

Backref is a pre-compiled expression for backref

View Source
var ErrUnknownFunction = parser.ParseError("unknown function")

Functions

func AggKey added in v0.3.0

func AggKey(series *types.MetricData, fields []int) (string, error)

func AggregateSeries

func AggregateSeries(name string, args []*types.MetricData, absent_if_first_series_absent bool, absent_if_any_absent bool, function AggregateFunc) ([]*types.MetricData, error)

AggregateSeries aggregates series

func AlignStartToInterval

func AlignStartToInterval(start, stop, bucketSize int32) int32

AlignStartToInterval aligns start of serie to interval

func AlignToBucketSize

func AlignToBucketSize(start, stop, bucketSize int32) (int32, int32)

AlignToBucketSize aligns start and stop of serie to specified bucket (step) size

func AvgValue

func AvgValue(f64s []float64, absent []bool) float64

AvgValue returns average of list of values

func CombineSeries added in v0.2.0

func CombineSeries(originalA, originalB *types.MetricData, name string, operator Operator) *types.MetricData

CombineSeries applied operator() on two series. If they do not have the same length, series are consolidated with a Lower Common Multiple step.

func Contains

func Contains(a []int, i int) bool

Contains check if slice 'a' contains value 'i'

func CurrentValue

func CurrentValue(f64s []float64, absent []bool) float64

CurrentValue returns last non-absent value (if any), otherwise returns NaN

func ExtractMetric

func ExtractMetric(s string) string

ExtractMetric extracts metric out of function list

func ForEachSeriesDo

func ForEachSeriesDo(ctx context.Context, e parser.Expr, from, until int32, values map[parser.MetricRequest][]*types.MetricData, function seriesFunc, getTargetData interfaces.GetTargetData) ([]*types.MetricData, error)

ForEachSeriesDo do action for each serie in list.

func GCD added in v0.2.0

func GCD(a, b int32) int32

GCD computes the Greatest Common Divisor of two numbers

func GetBuckets

func GetBuckets(start, stop, bucketSize int32) int32

GetBuckets returns amount buckets for timeSeries (defined with startTime, stopTime and step (bucket) size.

func GetSeriesArg

func GetSeriesArg(ctx context.Context, arg parser.Expr, from, until int32, values map[parser.MetricRequest][]*types.MetricData, getTargetData interfaces.GetTargetData) ([]*types.MetricData, error)

GetSeriesArg returns argument from series.

func GetSeriesArgs

func GetSeriesArgs(ctx context.Context, e []parser.Expr, from, until int32, values map[parser.MetricRequest][]*types.MetricData, getTargetData interfaces.GetTargetData) ([]*types.MetricData, error)

GetSeriesArgs returns arguments of series

func GetSeriesArgsAndRemoveNonExisting

func GetSeriesArgsAndRemoveNonExisting(ctx context.Context, e parser.Expr, from, until int32, values map[parser.MetricRequest][]*types.MetricData, getTargetData interfaces.GetTargetData) ([]*types.MetricData, error)

GetSeriesArgsAndRemoveNonExisting will fetch all required arguments, but will also filter out non existing Series This is needed to be graphite-web compatible in cases when you pass non-existing Series to, for example, sumSeries

func GroupByNodes added in v0.3.0

func GroupByNodes(nodes []int, seriesList []*types.MetricData) (map[string][]*types.MetricData, map[string]bool, error)

func LCM added in v0.2.0

func LCM(a, b int32) int32

LCM computes the Least Commong Multiple of two numbers

func MaxValue

func MaxValue(f64s []float64, absent []bool) float64

MaxValue returns maximum from the list

func MinValue

func MinValue(f64s []float64, absent []bool) float64

MinValue returns minimal from the list

func Normalize added in v0.2.0

func Normalize(args []*types.MetricData) ([]*types.MetricData, int32, int32, int32, error)

func Percentile

func Percentile(data []float64, percent float64, interpolate bool) (float64, bool)

Percentile returns percent-th percentile. Can interpolate if needed

func Poly

func Poly(x float64, coeffs ...float64) float64

Poly computes polynom with specified coefficients

func RemoveEmptySeriesFromName

func RemoveEmptySeriesFromName(args []*types.MetricData) string

RemoveEmptySeriesFromName removes empty series from list of names.

func SetEvaluator

func SetEvaluator(e interfaces.Evaluator)

SetEvaluator sets evaluator for all helper functions

func SummarizeValues

func SummarizeValues(f string, values []float64) (float64, bool, error)

SummarizeValues summarizes values

func Vandermonde

func Vandermonde(absent []bool, deg int) *mat.Dense

Vandermonde creates a Vandermonde matrix

func VarianceValue

func VarianceValue(f64s []float64, absent []bool) float64

VarianceValue gets variances of list of values

Types

type AggregateFunc

type AggregateFunc func([]float64) (float64, bool)

AggregateFunc type that defined aggregate function

type ByName

type ByName []*types.MetricData

ByName sorts metrics by name

func (ByName) Len

func (s ByName) Len() int

Len returns length, required to be sortable

func (ByName) Less

func (s ByName) Less(i, j int) bool

Less compares two elements with specified IDs, required to be sortable

func (ByName) Swap

func (s ByName) Swap(i, j int)

Swap swaps to elements by IDs, required to be sortable

type ByNameNatural

type ByNameNatural []*types.MetricData

ByNameNatural sorts metric naturally by name

func (ByNameNatural) Len

func (s ByNameNatural) Len() int

Len returns length, required to be sortable

func (ByNameNatural) Less

func (s ByNameNatural) Less(i, j int) bool

Less compares two elements with specified IDs, required to be sortable

func (ByNameNatural) Swap

func (s ByNameNatural) Swap(i, j int)

Swap swaps to elements by IDs, required to be sortable

type ByVals

type ByVals struct {
	Vals   []float64
	Series []*types.MetricData
}

ByVals sorts by values Total (sortByTotal), max (sortByMaxima), min (sortByMinima) sorting For 'min', we actually store 1/v so the sorting logic is the same

func (ByVals) Len

func (s ByVals) Len() int

Len returns length, required to be sortable

func (ByVals) Less

func (s ByVals) Less(i, j int) bool

Less compares two elements with specified IDs, required to be sortable

func (ByVals) Swap

func (s ByVals) Swap(i, j int)

Swap swaps to elements by IDs, required to be sortable

type Operator added in v0.2.0

type Operator func(l, r float64) (float64, bool)

Jump to

Keyboard shortcuts

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