expreval

package
v0.40.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package expreval provides go-mysql-server expression evaluation logic that works directly on noms types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LiteralToNomsValue

func LiteralToNomsValue(kind types.NomsKind, literal *expression.Literal) (types.Value, error)

LiteralToNomsValue converts a go-mysql-servel Literal into a noms value.

Types

type CompareOp

type CompareOp interface {
	// CompareLiterals compares two go-mysql-server literals
	CompareLiterals(l1, l2 *expression.Literal) (bool, error)
	// CompareNomsValues compares two noms values
	CompareNomsValues(v1, v2 types.Value) (bool, error)
	// CompareToNil compares a noms value to nil using sql logic rules
	CompareToNil(v2 types.Value) (bool, error)
}

CompareOp is an interface for comparing values

type ComparisonType

type ComparisonType int
const (
	InvalidCompare ComparisonType = iota
	VariableConstCompare
	VariableVariableCompare
	VariableInLiteralList
	ConstConstCompare
)

func GetComparisonType

GetComparisonType looks at a go-mysql-server BinaryExpression classifies the left and right arguments as variables or constants.

type EqualsOp

type EqualsOp struct{}

EqualsOp implements the CompareOp interface implementing equality logic

func (EqualsOp) CompareLiterals

func (op EqualsOp) CompareLiterals(l1, l2 *expression.Literal) (bool, error)

CompareLiterals compares two go-mysql-server literals for equality

func (EqualsOp) CompareNomsValues

func (op EqualsOp) CompareNomsValues(v1, v2 types.Value) (bool, error)

CompareNomsValues compares two noms values for equality

func (EqualsOp) CompareToNil

func (op EqualsOp) CompareToNil(types.Value) (bool, error)

CompareToNil always returns false as values are neither greater than, less than, or equal to nil

type ExpressionFunc

type ExpressionFunc func(ctx context.Context, vals map[uint64]types.Value) (bool, error)

ExpressionFunc is a function that takes a map of tag to value and returns whether some set of criteria are true for the set of values

func ExpressionFuncFromSQLExpressions

func ExpressionFuncFromSQLExpressions(nbf *types.NomsBinFormat, sch schema.Schema, expressions []sql.Expression) (ExpressionFunc, error)

ExpressionFuncFromSQLExpressions returns an ExpressionFunc which represents the slice of sql.Expressions passed in

type GreaterEqualOp

type GreaterEqualOp struct {
	NBF *types.NomsBinFormat
}

GreaterEqualOp implements the CompareOp interface implementing greater than or equal to logic

func (GreaterEqualOp) CompareLiterals

func (op GreaterEqualOp) CompareLiterals(l1, l2 *expression.Literal) (bool, error)

CompareLiterals compares two go-mysql-server literals returning true if the value of the first is greater than or equal to the second.

func (GreaterEqualOp) CompareNomsValues

func (op GreaterEqualOp) CompareNomsValues(v1, v2 types.Value) (bool, error)

CompareNomsValues compares two noms values returning true if the of the first is greater or equal to than the second.

func (GreaterEqualOp) CompareToNil

func (op GreaterEqualOp) CompareToNil(types.Value) (bool, error)

CompareToNil always returns false as values are neither greater than, less than, or equal to nil

type GreaterOp

type GreaterOp struct {
	NBF *types.NomsBinFormat
}

GreaterOp implements the CompareOp interface implementing greater than logic

func (GreaterOp) CompareLiterals

func (op GreaterOp) CompareLiterals(l1, l2 *expression.Literal) (bool, error)

CompareLiterals compares two go-mysql-server literals returning true if the value of the first is greater than the second.

func (GreaterOp) CompareNomsValues

func (op GreaterOp) CompareNomsValues(v1, v2 types.Value) (bool, error)

CompareNomsValues compares two noms values returning true if the of the first is greater than the second.

func (GreaterOp) CompareToNil

func (op GreaterOp) CompareToNil(types.Value) (bool, error)

CompareToNil always returns false as values are neither greater than, less than, or equal to nil

type LessEqualOp

type LessEqualOp struct {
	NBF *types.NomsBinFormat
}

LessEqualOp implements the CompareOp interface implementing less than or equal to logic

func (LessEqualOp) CompareLiterals

func (op LessEqualOp) CompareLiterals(l1, l2 *expression.Literal) (bool, error)

CompareLiterals compares two go-mysql-server literals returning true if the value of the first is less than or equal to the second.

func (LessEqualOp) CompareNomsValues

func (op LessEqualOp) CompareNomsValues(v1, v2 types.Value) (bool, error)

CompareNomsValues compares two noms values returning true if the of the first is less than or equal to the second.

func (LessEqualOp) CompareToNil

func (op LessEqualOp) CompareToNil(types.Value) (bool, error)

CompareToNil always returns false as values are neither greater than, less than, or equal to nil

type LessOp

type LessOp struct {
	NBF *types.NomsBinFormat
}

LessOp implements the CompareOp interface implementing less than logic

func (LessOp) CompareLiterals

func (op LessOp) CompareLiterals(l1, l2 *expression.Literal) (bool, error)

CompareLiterals compares two go-mysql-server literals returning true if the value of the first is less than the second.

func (LessOp) CompareNomsValues

func (op LessOp) CompareNomsValues(v1, v2 types.Value) (bool, error)

CompareNomsValues compares two noms values returning true if the of the first is less than the second.

func (LessOp) CompareToNil

func (op LessOp) CompareToNil(types.Value) (bool, error)

CompareToNil always returns false as values are neither greater than, less than, or equal to nil

Jump to

Keyboard shortcuts

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