Documentation
¶
Overview ¶
Package expr provides utilities for evaluating expressions against a columnar.RecordBatch with a selection vector.
Package expr is EXPERIMENTAL and currently only intended to be used by github.com/grafana/loki/v3/pkg/dataobj.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Evaluate ¶
func Evaluate(alloc *memory.Allocator, expr Expression, batch *columnar.RecordBatch) (columnar.Datum, error)
Evaluate processes expr against the provided batch, producing a datum as a result using alloc.
The return type of Evaluate depends on the expression provided. See the documentation for implementations of Expression for what they produce when evaluated.
Types ¶
type Binary ¶
type Binary struct {
Left Expression
Op BinaryOp
Right Expression
}
Binary is an Expression that performs a binary operation against a left and a right expression.
The result of the expression depends on value of BinaryOp. The documentation of BinaryOp will describe the behavior of the expression.
type BinaryOp ¶
type BinaryOp int
BinaryOp denotes a binary operation to perform against two arguments.
const ( // BinaryOpInvalid indicates an invalid binary operation. Evaluating a // BinaryOpInvalid will result in an error. BinaryOpInvalid BinaryOp = iota // BinaryOpEQ performs an equality (==) check of the left and right // expressions. The expressions must be of the same type. // // The result is a bool datum, which is either a bool scalar if both // arguments are scalars, otherwise the result is a bool array. BinaryOpEQ // BinaryOpNEQ performs an inequality (!=) check of the left and right // expressions. The expressions must be of the same type. // // The result is a bool datum, which is either a bool scalar if both // arguments are scalars, otherwise the result is a bool array. BinaryOpNEQ // BinaryOpGT performs a greater than (>) check of the left and right // expressions. The expressions must be of the same type, and must be // ordered (numeric or UTF8). // // The result is a bool datum, which is either a bool scalar if both // arguments are scalars, otherwise the result is a bool array. BinaryOpGT // BinaryOpGTE performs a greater than or equal (>=) check of the left and // right expressions. The expressions must be of the same type, and must be // ordered (numeric or UTF8). // // The result is a bool datum, which is either a bool scalar if both // arguments are scalars, otherwise the result is a bool array. BinaryOpGTE // BinaryOpLT performs a less than (<) check of the left and right // expressions. The expressions must be of the same type, and must be // ordered (numeric or UTF8). // // The result is a bool datum, which is either a bool scalar if both // arguments are scalars, otherwise the result is a bool array. BinaryOpLT // BinaryOpLTE performs a less than or equal (<=) check of the left and // right expressions. The expressions must be of the same type, and must be // ordered (numeric or UTF8). // // The result is a bool datum, which is either a bool scalar if both // arguments are scalars, otherwise the result is a bool array. BinaryOpLTE // BinaryOpAND performs a logical AND (&&) operation on the left and right // expressions. The expressions must be of bool type. // // The result is a bool datum, which is either a bool scalar if both // arguments are scalars, otherwise the result is a bool array. BinaryOpAND // BinaryOpOR performs a logical OR (||) operation on the left and right // expressions. The expressions must be of bool type. // // The result is a bool datum, which is either a bool scalar if both // arguments are scalars, otherwise the result is a bool array. BinaryOpOR // BinaryOpMatchRegex performs a regex match of the left and right expressions. // // The left expression denotes the datum to search, and must be a UTF8 // scalar or array. The right expression denotes the regular expression to // match with, and must be a [Regexp]. If the expression matches the UTF8 // value, the result is true. // // The result is a bool datum, which is either a bool scalar if both // arguments are scalars, otherwise the result is a bool array. BinaryOpMatchRegex // BinaryOpIn performs a membership check of the left and right expressions. // // The left expression denotes the datum to search. The right // expression denotes the set of values to search for, and must // be a [ValueSet] matching the left datum's type. // // If the value is found in the set, the result is true. // // The result is a bool datum, which is either a bool scalar if the // left datum is a scalar, otherwise the result is a bool array. BinaryOpIn // BinaryOpHasSubstr performs a case-sensitive substring check of the left // and right expressions. // // The left expression denotes the "haystack" to search, and must be a UTF8 // scalar or array. The right expression denotes the "needle" to search // with, and must be a UTF8 scalar. If the needle is found in the haystack, // the result is true. // // The result is a bool datum, which is either a bool scalar if both // arguments are scalars, otherwise the result is a bool array. BinaryOpHasSubstr // BinaryOpHasSubstrIgnoreCase performs a case-insensitive substring check // of the left and right expressions. // // The left expression denotes the "haystack" to search, and must be a UTF8 // scalar or array. The right expression denotes the "needle" to search // with, and must be a UTF8 scalar. If the needle is found in the haystack // (ignoring case), the result is true. // // The result is a bool datum, which is either a bool scalar if both // arguments are scalars, otherwise the result is a bool array. BinaryOpHasSubstrIgnoreCase )
type Column ¶
type Column struct{ Name string }
Column is an Expression that looks up the column by name in the record batch supplied to Evaluate.
If the column doesn't exist, a Null column is produced.
type Constant ¶
Constant is an Expression that produces a single scalar value when evaluated.
type Expression ¶
type Expression interface {
// contains filtered or unexported methods
}
Expression represents an operation that can be evaluated to produce a result.
type Regexp ¶
Regexp is an Expression used as the right-hand side of a BinaryOpMatchRegex.
Regexp cannot be evaluated directly into a datum.
type Unary ¶
type Unary struct {
Op UnaryOp
Value Expression
}
Unary is an Expression that performs a unary operation against a single argument.
The result of the expression depends on value of UnaryOp. The documentation of UnaryOp will describe the behavior of the expression.
type UnaryOp ¶
type UnaryOp int
UnaryOp denotes a unary operation to perform against a single argument.
type ValueSet ¶
ValueSet is an Expression used as the right-hand side of a BinaryOpIn.
ValueSet cannot be evaluated directly into a datum.