binary

package
v0.0.0-...-9649366 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 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 ArithmeticFunction

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

ArithmeticFunction returns the arithmetic function for this operation type.

func NewOp

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

NewOp creates a new binary operation.

Types

type NodeParams

type NodeParams struct {
	LNode, RNode         parser.NodeID
	ReturnBool           bool
	VectorMatcherBuilder VectorMatcherBuilder
}

NodeParams describes the types of nodes used for binary operations.

type VectorMatchCardinality

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 VectorMatcherBuilder

type VectorMatcherBuilder func(lhs, rhs block.Block) VectorMatching

VectorMatcherBuilder creates a vector matcher based on incoming block types.

type VectorMatching

type VectorMatching struct {
	// Set determines if this has been set or is using default values.
	Set bool
	// Card is 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