expression

package
v0.15.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValueTypeStrings = map[ValueType]string{
	ValueTypeUnspecified:   "<<invalid>>",
	ValueTypeString:        "string",
	ValueTypeSignedInt8:    "int8",
	ValueTypeSignedInt16:   "int16",
	ValueTypeSignedInt32:   "int32",
	ValueTypeSignedInt64:   "int64",
	ValueTypeUnsignedInt8:  "uint8",
	ValueTypeUnsignedInt16: "uint16",
	ValueTypeUnsignedInt32: "uint32",
	ValueTypeUnsignedInt64: "uint64",
	ValueTypeBool:          "bool",
	ValueTypeDouble:        "float64",
	ValueTypeTimestamp:     "uint64",
}

ValueTypeStrings is a mapping of value type constants to human-readble string representations

Functions

func BitwiseAnd

func BitwiseAnd(lhs, rhs *api.Expression) *api.Expression

BitwiseAnd creates a new BINARY_AND binary Expression node.

func Equal

func Equal(lhs, rhs *api.Expression) *api.Expression

Equal creates a new EQ binary Expression node.

func GreaterThan

func GreaterThan(lhs, rhs *api.Expression) *api.Expression

GreaterThan creates a new GT binary expression node.

func GreaterThanEqualTo

func GreaterThanEqualTo(lhs, rhs *api.Expression) *api.Expression

GreaterThanEqualTo creates a new GE binary expression node.

func Identifier

func Identifier(name string) *api.Expression

Identifier creates a new IDENTIFIER Expression node.

func IsNotNull

func IsNotNull(operand *api.Expression) *api.Expression

IsNotNull creates a new IS_NOT_NULL unary Expression node

func IsNull

func IsNull(operand *api.Expression) *api.Expression

IsNull creates a new IS_NULL unary Expression node

func IsValueTrue

func IsValueTrue(i interface{}) bool

IsValueTrue determines whether a value's truth value is true or false. Strings are true if they contain one or more characters. Any numeric type is true if it is non-zero.

func LessThan

func LessThan(lhs, rhs *api.Expression) *api.Expression

LessThan creates a new LT binary Expression node.

func LessThanEqualTo

func LessThanEqualTo(lhs, rhs *api.Expression) *api.Expression

LessThanEqualTo creates a new LE binary Expression node.

func Like

func Like(lhs, rhs *api.Expression) *api.Expression

Like creates a new LIKE binary Expression node.

func LogicalAnd

func LogicalAnd(lhs, rhs *api.Expression) *api.Expression

LogicalAnd creates a new LOGICAL_AND binary Expression node. If either lhs or rhs is nil, the other will be returned

func LogicalOr

func LogicalOr(lhs, rhs *api.Expression) *api.Expression

LogicalOr creates a new LOGICAL_OR binary Expression node. If either lhs or rhs is nil, the other will be returned

func NewValue

func NewValue(i interface{}) *api.Value

NewValue creates a new Value instance from a native Go type. If a Go type is used that does not have a Value equivalent, the return will be nil.

func NotEqual

func NotEqual(lhs, rhs *api.Expression) *api.Expression

NotEqual creates a new NE binary Expression node.

func Value

func Value(i interface{}) *api.Expression

Value creates a new VALUE Expression node.

Types

type Expression

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

Expression is a wrapper around expressions around the API. It may contain internal information that is used to better support the raw representation.

func NewExpression

func NewExpression(tree *api.Expression) (*Expression, error)

NewExpression instantiates a new Expression instance. The expression tree that is passed is validated to ensure that it is well-formed.

func (*Expression) Evaluate

func (expr *Expression) Evaluate(types FieldTypeMap, values FieldValueMap) (interface{}, error)

Evaluate evaluates an expression using the specified type and value information, and returns the result of that evaluation or an error. Any identifier not present in the types map is considered to be an undefined field and any reference to it is an error. Any identifier present in the types map, but not present in the values map is considered to be NULL; all comparisons against NULL will always evaluate FALSE.

func (*Expression) KernelFilterString

func (expr *Expression) KernelFilterString() string

KernelFilterString returns a string representation of an expression that is suitable for setting a kernel perf_event filter. This is mostly the same as a normal string representation of the expression; however, a few adjustments are needed for the kernel.

func (*Expression) String

func (expr *Expression) String() string

Return the string representation of an expression.

func (*Expression) Validate

func (expr *Expression) Validate(types FieldTypeMap) error

Validate ensures that an expression is properly constructed with the specified type information. Any identifier not present in the types map is considered to be an undefined field and any reference to it is an error.

func (*Expression) ValidateKernelFilter

func (expr *Expression) ValidateKernelFilter() error

ValidateKernelFilter determins whether an expression can be represented as a kernel filter string. If the result is nil, the kernel will most likely accept the expression as a filter. No check is done on the number of predicates in the expression, and some kernel versions do not support bitwise-and; however, this validator will accept bitwise-and because most do. Kernel limits on the number of predicates can vary, so it's not checked. If an expression passes this validation, it is not guaranteed that a given running kernel will absolutely accept it.

type FieldTypeMap

type FieldTypeMap map[string]ValueType

FieldTypeMap is a mapping of types for field names/identifiers

type FieldValueMap

type FieldValueMap map[string]interface{}

FieldValueMap is a mapping of values for field names/identifiers.

type ValueType

type ValueType int

ValueType represents the type of a value in an expression

const (
	// ValueTypeUnspecified is an unspecified type
	ValueTypeUnspecified ValueType = iota

	// ValueTypeString is a string
	ValueTypeString

	// ValueTypeSignedInt8 is a signed 8-bit integer
	ValueTypeSignedInt8
	// ValueTypeSignedInt16 is a signed 16-bit integer
	ValueTypeSignedInt16
	// ValueTypeSignedInt32 is a signed 32-bit integer
	ValueTypeSignedInt32
	// ValueTypeSignedInt64 is a signed 64-bit integer
	ValueTypeSignedInt64
	// ValueTypeUnsignedInt8 is an unisnged 8-bit integer
	ValueTypeUnsignedInt8
	// ValueTypeUnsignedInt16 is an unsigned 16-bit integer
	ValueTypeUnsignedInt16
	// ValueTypeUnsignedInt32 is an unsigned 32-bit integer
	ValueTypeUnsignedInt32
	// ValueTypeUnsignedInt64 is an unsigned 64-bit integer
	ValueTypeUnsignedInt64

	// ValueTypeBool is a bool
	ValueTypeBool
	// ValueTypeDouble is a 64-bit floating point
	ValueTypeDouble
	// ValueTypeTimestamp is a timestamp with nanosecond granularity
	ValueTypeTimestamp
)

func ValueTypeOf

func ValueTypeOf(i interface{}) ValueType

ValueTypeOf returns the value type of a value

func (ValueType) IsInteger

func (t ValueType) IsInteger() bool

IsInteger returns true if the specified ValueType represents an integer type.

func (ValueType) IsNumeric

func (t ValueType) IsNumeric() bool

IsNumeric returns true if the specified ValueType represents a numeric type type (integer or double)

func (ValueType) IsString

func (t ValueType) IsString() bool

IsString returns true if the specified ValueType represents a string type.

Jump to

Keyboard shortcuts

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