binary

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PlusType adds datapoints in both series
	PlusType = "+"

	// MinusType subtracts rhs from lhs
	MinusType = "-"

	// MultiplyType multiplies datapoints by series
	MultiplyType = "*"

	// DivType divides datapoints by series
	// Special cases are:
	// 	 X / 0 = +Inf
	// 	-X / 0 = -Inf
	// 	 0 / 0 =  NaN
	DivType = "/"

	// ExpType raises lhs to the power of rhs
	// NB: to keep consistency with prometheus (and go)
	//  0 ^ 0 = 1
	//  NaN ^ 0 = 1
	ExpType = "^"

	// ModType takes the modulo of lhs by rhs
	// Special cases are:
	// 	 X % 0 = NaN
	// 	 NaN % X = NaN
	// 	 X % NaN = NaN
	ModType = "%"
)
View Source
const (
	// EqType checks that lhs is equal to rhs
	EqType = "=="

	// NotEqType checks that lhs is equal to rhs
	NotEqType = "!="

	// GreaterType checks that lhs is equal to rhs
	GreaterType = ">"

	// LesserType checks that lhs is equal to rhs
	LesserType = "<"

	// GreaterEqType checks that lhs is equal to rhs
	GreaterEqType = ">="

	// LesserEqType checks that lhs is equal to rhs
	LesserEqType = "<="
)
View Source
const AndType = "and"

AndType uses values from left hand side for which there is a value in right hand side with exactly matching label sets. Other elements are replaced by NaNs. The metric name and values are carried over from the left-hand side.

View Source
const OrType = "or"

OrType uses all values from left hand side, and appends values from the right hand side which do not have corresponding tags on the right

View Source
const UnlessType = "unless"

UnlessType uses all values from lhs which do not exist in rhs

Variables

This section is empty.

Functions

func HashFunc added in v0.4.2

func HashFunc(on bool, names ...[]byte) func(models.Tags) uint64

HashFunc returns a function that calculates the signature for a metric ignoring the provided labels. If on, then the given labels are only used instead.

func NewOp added in v0.4.2

func NewOp(
	opType string,
	params NodeParams,
) (parser.Params, error)

NewOp creates a new binary operation

Types

type Function added in v0.4.6

type Function func(x, y float64) float64

Function is a function that applies on two floats

func ArithmeticFunction added in v0.4.6

func ArithmeticFunction(opType string, returnBool bool) (Function, error)

ArithmeticFunction returns the arithmetic function for this operation type.

type NodeParams

type NodeParams struct {
	LNode, RNode         parser.NodeID
	LIsScalar, RIsScalar bool
	ReturnBool           bool
	VectorMatching       *VectorMatching
}

NodeParams describes the types of nodes used for binary operations

type VectorMatchCardinality added in v0.4.2

type VectorMatchCardinality int

VectorMatchCardinality describes the cardinality relationship of two Vectors in a binary operation.

const (
	// CardOneToOne is used for one-one relationship
	CardOneToOne VectorMatchCardinality = iota
	// CardManyToOne is used for many-one relationship
	CardManyToOne
	// CardOneToMany is used for one-many relationship
	CardOneToMany
	// CardManyToMany is used for many-many relationship
	CardManyToMany
)

type VectorMatching added in v0.4.2

type VectorMatching struct {
	// The cardinality of the two Vectors.
	Card VectorMatchCardinality
	// MatchingLabels contains the labels which define equality of a pair of
	// elements from the Vectors.
	MatchingLabels [][]byte
	// On includes the given label names from matching,
	// rather than excluding them.
	On bool
	// Include contains additional labels that should be included in
	// the result from the side with the lower cardinality.
	Include []string
}

VectorMatching describes how elements from two Vectors in a binary operation are supposed to be matched.

Jump to

Keyboard shortcuts

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