functions

package
v0.0.0-...-d8ac9bd Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasFunction

func HasFunction(n string) bool

func InitialFirst

func InitialFirst(v ql.Value) ql.Value

InitialFirst returns the first valid metric in a Value. If the Value has no valid metrics then it returns the original value.

func InitialInvalid

func InitialInvalid(_ ql.Value) ql.Value

InitialInvalid returns an invalid Value. It's used for functions using Calculation's, where we want to start the aggregation without an initial starting value.

func InitialLast

func InitialLast(v ql.Value) ql.Value

InitialLast returns the last valid metric in a Value. If the Value has no valid metrics then it returns the original value.

Types

type Aggregator

type Aggregator func(l int, a ql.Value) ql.Value

func MathAggregator

func MathAggregator(o SingleMathOperation) Aggregator

MathAggregator applies a SingleMathOperation against the result

type Function

type Function struct {
	// Args is the number of arguments a Function requires.
	// This overrides MinArg and MaxArg if MinArg < Args > MaxArg
	Args int

	// MinArg is the minimum number of arguments a Function accepts.
	// Default 0
	MinArg int

	// MaxArg is the maximum number of arguments a Function accepts.
	// Default 0, if this is less than MinArg then the function supports MaxInt arguments
	MaxArg int

	// Initial is a function to be called to get the initial valur for an aggregator.
	// If not set then InitialFirst is used.
	Initial FunctionInitialiser

	// Reducer is a value.Comparator used to determine which value to keep.
	// If comparator(a,b) returns true then a is used, otherwise b.
	Reducer value.Comparator

	// Calculation is a value.Calculation which performs an operation against two Value's
	// returning a new one.
	Calculation value.Calculation // calculation of a and b

	// Aggregator is a function which will convert a Value based on the number of values
	// passed through the aggregator.
	//
	// l=number of entries in set, return Value based on l and result
	Aggregator Aggregator

	// Function is called after any aggregations have been performed.
	Function FunctionHandler // Handler for specific functions

	// AggregateArguments if set will apply the aggregator against the arguments before passing
	// the single result to the Function.
	// This only applies if Function is set.
	AggregateArguments bool
}

Function definition

func GetFunction

func GetFunction(n string) (Function, bool)

func (Function) IsAggregator

func (f Function) IsAggregator() bool

IsAggregator returns true if one of Reducer, Calculation or Aggregator is defined.

func (Function) Run

func (f Function) Run(ex ql.Executor, v ql2.QueryVisitor, fn *ql2.Function) error

type FunctionHandler

type FunctionHandler func(ql.Executor, ql2.QueryVisitor, *ql2.Function, []ql.Value) error

type FunctionInitialiser

type FunctionInitialiser func(ql.Value) ql.Value

type FunctionMap

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

func AddFunction

func AddFunction(n string, ag Function) *FunctionMap

func (*FunctionMap) AddFunction

func (f *FunctionMap) AddFunction(n string, ag Function)

func (*FunctionMap) GetFunction

func (f *FunctionMap) GetFunction(n string) (Function, bool)

func (*FunctionMap) HasFunction

func (f *FunctionMap) HasFunction(n string) bool

type SingleMathOperation

type SingleMathOperation func(float64) float64

Jump to

Keyboard shortcuts

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