vm

package
v0.0.0-...-8371fe2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2016 License: MIT Imports: 16 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 (

	// ErrNoIncluder is message saying a FilterQL included reference
	// to an include when no Includer was available to resolve
	ErrNoIncluder = fmt.Errorf("No Includer is available")

	// MaxDepth acts as a guard against potentially recursive queries
	MaxDepth = 10000
)
View Source
var (
	ErrUnknownOp       = fmt.Errorf("expr: unknown op type")
	ErrUnknownNodeType = fmt.Errorf("expr: unknown node type")
	ErrExecute         = fmt.Errorf("Could not execute")

	SchemaInfoEmpty = &NoSchema{}
)

Functions

func Eval

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

func EvalFilterSelect

func EvalFilterSelect(sel *rel.FilterSelect, inc Includer, writeContext expr.ContextWriter, readContext expr.ContextReader) (bool, error)

EvalFilerSelect applies a FilterSelect statement to the specified contexts

@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.ContextReader) (bool, error)

Eval applies a sql statement to the specified context

@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)

func NewFilterVm

func NewFilterVm(i Includer) *filterql

Types

type EvalBaseContext

type EvalBaseContext struct {
	expr.ContextReader
}

type EvaluatorFunc

type EvaluatorFunc func(ctx expr.EvalContext) (value.Value, bool)

func Evaluator

func Evaluator(arg expr.Node) EvaluatorFunc

type ExprVm

type ExprVm interface {
	Execute(writeContext expr.ContextWriter, readContext expr.ContextReader) error
}

type Includer

type Includer interface {
	Include(name string) (*rel.FilterStatement, error)
}

Includer defines an interface used for resolving INCLUDE clauses into a *FilterStatement. Implementations should return an error if the name cannot be resolved.

type NoSchema

type NoSchema struct {
}

func (*NoSchema) Key

func (m *NoSchema) Key() string

type State

type State struct {
	ExprVm // reference to the VM operating on this state

	expr.ContextReader
	Writer expr.ContextWriter
	// contains filtered or unexported fields
}

func NewState

func NewState(vm ExprVm, read expr.ContextReader, write expr.ContextWriter) *State

func (*State) Walk

func (e *State) Walk(arg expr.Node) (value.Value, bool)

type Vm

type Vm struct {
	*expr.Tree
}

A node vm is a vm for parsing, evaluating a single tree-node

func NewVm

func NewVm(exprText string) (*Vm, error)

func (*Vm) Execute

func (m *Vm) Execute(writeContext expr.ContextWriter, readContext expr.ContextReader) (err error)

Execute applies a parse expression to the specified context's

func (*Vm) MarshalJSON

func (m *Vm) MarshalJSON() ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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