vm

package
v0.0.0-...-fc2d520 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

VM implements the virtual machine runtime evaluator for the SQL, FilterQL, and Expression evalutors.

Index

Constants

This section is empty.

Variables

View Source
var (
	// MaxDepth acts as a guard against potentially recursive queries
	MaxDepth = 10000
	// ErrMaxDepth If we hit max depth on recursion
	ErrMaxDepth = fmt.Errorf("Recursive Evaluation Error")
	// ErrUnknownOp an unrecognized Operator in expression
	ErrUnknownOp = fmt.Errorf("expr: unknown op type")
	// ErrUnknownNodeType Unhandled Node type for expression evaluation
	ErrUnknownNodeType = fmt.Errorf("expr: unknown node type")
	// ErrExecute could not evaluate an expression
	ErrExecute = fmt.Errorf("Could not execute")
)

Functions

func Eval

func Eval(ctx expr.EvalContext, arg expr.Node) (value.Value, bool)

Eval - Evaluate the given expression (arg Node) against the given context. @ctx is the evaluation context ie the variables/values which the expression will be evaluated against. It may be a simple reader of message/data or any object whhich implements EvalContext.

func EvalFilterSelect

func EvalFilterSelect(sel *rel.FilterSelect, writeContext expr.ContextWriter, readContext expr.EvalContext) (bool, bool)

EvalFilerSelect evaluates a FilterSelect statement from read, into write context

@writeContext = Write results of projection @readContext = Message input, ie evaluate for Where/Filter clause

func EvalSql

func EvalSql(sel *rel.SqlSelect, writeContext expr.ContextWriter, readContext expr.EvalContext) (bool, error)

EvalSql Is a partial SQL statement evaluator (that doesn't get it all right). See exec package for full sql evaluator. Can be used to evaluate a read context and write results to write context. This does not project columns prior to running WHERE.

@writeContext = Write out results of projection @readContext = Message to evaluate does it match where clause? if so proceed to projection

func LikeCompare

func LikeCompare(a, b string) (value.BoolValue, bool)

LikeCompare takes two strings and evaluates them for like equality

func Matches

func Matches(cr expr.EvalContext, stmt *rel.FilterStatement) (bool, bool)

Matches executes a FilterQL statement against an evaluation context returning true if the context matches.

func MatchesExpr

func MatchesExpr(cr expr.EvalContext, node expr.Node) (bool, bool)

MatchesExpr executes a expr.Node expression against an evaluation context returning true if the context matches.

func MatchesInc

func MatchesInc(inc expr.Includer, cr expr.EvalContext, stmt *rel.FilterStatement) (bool, bool)

Matches executes a FilterQL statement against an evaluation context returning true if the context matches.

func ResolveIncludes

func ResolveIncludes(ctx expr.Includer, arg expr.Node) error

ResolveIncludes take an expression and resolve any includes so that it does not have to be resolved at runtime. There is also a InlineIncludes alternative in expr pkg which actually re-writes the expression to remove includes and embed the expressions they refer to as part of this expression.

Types

type DateConverter

type DateConverter struct {
	HasDateMath bool      // Does this have date math in it all?
	Node        expr.Node // The expression we are extracting datemath from
	TimeStrings []string  // List of each extracted timestring
	// contains filtered or unexported fields
}

DateConverter can help inspect a boolean expression to determine if there is date-math in it. If there is datemath, can calculate the time boundary where the expression may possibly change from true to false. - Must be boolean expression - Only calculates the first boundary - Only calculates POSSIBLE boundary, given complex logic (ors etc) may NOT change.

func NewDateConverter

func NewDateConverter(ctx expr.EvalIncludeContext, n expr.Node) (*DateConverter, error)

NewDateConverter takes a node expression

func (*DateConverter) Boundary

func (d *DateConverter) Boundary() time.Time

Boundary given all the date-maths in this node find the boundary time where this expression possibly will change boolean value. If no boundaries exist, returns time.Time{} (zero time)

type EvalBaseContext

type EvalBaseContext struct {
	expr.EvalContext
}

EvalBaseContext base context for expression evaluation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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