Documentation
¶
Overview ¶
Expression structures, ie the `a = b` type expression syntax including parser, node types, boolean logic check, functions.
Package expr is a generated protocol buffer package. It is generated from these files: node.proto It has these top-level messages: NodePb BinaryNodePb UnaryNodePb FuncNodePb TriNodePb ArrayNodePb StringNodePb IdentityNodePb NumberNodePb ValueNodePb
Index ¶
- Variables
- func AggFuncAdd(name string, fn interface{})
- func FindAllIdentityField(node Node) []string
- func FindIdentityField(node Node) string
- func FindIdentityName(depth int, node Node, prefix string) string
- func FuncAdd(name string, fn interface{})
- func FuncsGet() map[string]Func
- func HasDateMath(node Node) bool
- func IdentityMaybeEscapeBuf(buf *bytes.Buffer, quote byte, ident string)
- func IdentityMaybeQuote(quote byte, ident string) string
- func IdentityMaybeQuoteStrict(quote byte, ident string) string
- func IdentityMaybeQuoteStrictBuf(buf *bytes.Buffer, quote byte, ident string)
- func IdentityTrim(ident string) string
- func IsAgg(name string) bool
- func LeftRight(val string) (string, string, bool)
- func LiteralQuoteEscape(quote rune, literal string) string
- func LiteralQuoteEscapeBuf(buf *bytes.Buffer, quote rune, literal string)
- func NodesEqual(n1, n2 Node) bool
- func StringEscape(quote rune, literal string) string
- func ValueArray(pg TokenPager) (value.Value, error)
- func ValueTypeFromNode(n Node) value.ValueType
- type ArrayNode
- func (m *ArrayNode) Append(n Node)
- func (m *ArrayNode) Check() error
- func (m *ArrayNode) Equal(n Node) bool
- func (m *ArrayNode) FromPB(n *NodePb) Node
- func (m *ArrayNode) String() string
- func (m *ArrayNode) ToPB() *NodePb
- func (m *ArrayNode) Type() reflect.Value
- func (m *ArrayNode) WriteDialect(w DialectWriter)
- type ArrayNodePb
- func (m *ArrayNodePb) Marshal() (data []byte, err error)
- func (m *ArrayNodePb) MarshalTo(data []byte) (int, error)
- func (*ArrayNodePb) ProtoMessage()
- func (m *ArrayNodePb) Reset()
- func (m *ArrayNodePb) Size() (n int)
- func (m *ArrayNodePb) String() string
- func (m *ArrayNodePb) Unmarshal(data []byte) error
- type BinaryNode
- func (m *BinaryNode) Check() error
- func (m *BinaryNode) Equal(n Node) bool
- func (m *BinaryNode) FromPB(n *NodePb) Node
- func (m *BinaryNode) String() string
- func (m *BinaryNode) StringNegate() string
- func (m *BinaryNode) ToPB() *NodePb
- func (m *BinaryNode) Type() reflect.Value
- func (m *BinaryNode) WriteDialect(w DialectWriter)
- func (m *BinaryNode) WriteNegate(w DialectWriter)
- type BinaryNodePb
- func (m *BinaryNodePb) Marshal() (data []byte, err error)
- func (m *BinaryNodePb) MarshalTo(data []byte) (int, error)
- func (*BinaryNodePb) ProtoMessage()
- func (m *BinaryNodePb) Reset()
- func (m *BinaryNodePb) Size() (n int)
- func (m *BinaryNodePb) String() string
- func (m *BinaryNodePb) Unmarshal(data []byte) error
- type ContextReadWriter
- type ContextReader
- type ContextWriter
- type DialectWriter
- type EvalContext
- type Func
- type FuncNode
- type FuncNodePb
- type FuncRegistry
- type FuncResolver
- type IdentityNode
- func (m *IdentityNode) Bool() bool
- func (m *IdentityNode) Check() error
- func (m *IdentityNode) Equal(n Node) bool
- func (m *IdentityNode) FromPB(n *NodePb) Node
- func (m *IdentityNode) HasLeftRight() bool
- func (m *IdentityNode) IsBooleanIdentity() bool
- func (m *IdentityNode) LeftRight() (string, string, bool)
- func (m *IdentityNode) OriginalText() string
- func (m *IdentityNode) String() string
- func (m *IdentityNode) ToPB() *NodePb
- func (m *IdentityNode) Type() reflect.Value
- func (m *IdentityNode) WriteDialect(w DialectWriter)
- type IdentityNodePb
- func (m *IdentityNodePb) Marshal() (data []byte, err error)
- func (m *IdentityNodePb) MarshalTo(data []byte) (int, error)
- func (*IdentityNodePb) ProtoMessage()
- func (m *IdentityNodePb) Reset()
- func (m *IdentityNodePb) Size() (n int)
- func (m *IdentityNodePb) String() string
- func (m *IdentityNodePb) Unmarshal(data []byte) error
- type LexTokenPager
- type NegateableNode
- type Node
- type NodePb
- type NodeValueType
- type NullNode
- type NumberNode
- type NumberNodePb
- func (m *NumberNodePb) Marshal() (data []byte, err error)
- func (m *NumberNodePb) MarshalTo(data []byte) (int, error)
- func (*NumberNodePb) ProtoMessage()
- func (m *NumberNodePb) Reset()
- func (m *NumberNodePb) Size() (n int)
- func (m *NumberNodePb) String() string
- func (m *NumberNodePb) Unmarshal(data []byte) error
- type RowWriter
- type SchemaInfo
- type SchemaInfoString
- type StringNode
- type StringNodePb
- func (m *StringNodePb) Marshal() (data []byte, err error)
- func (m *StringNodePb) MarshalTo(data []byte) (int, error)
- func (*StringNodePb) ProtoMessage()
- func (m *StringNodePb) Reset()
- func (m *StringNodePb) Size() (n int)
- func (m *StringNodePb) String() string
- func (m *StringNodePb) Unmarshal(data []byte) error
- type TokenPager
- type Tree
- func (t *Tree) A(depth int) Node
- func (t *Tree) ArrayNode(depth int) Node
- func (t *Tree) BuildTree(runCheck bool) (err error)
- func (t *Tree) C(depth int) Node
- func (t *Tree) F(depth int) Node
- func (t *Tree) Func(depth int, funcTok lex.Token) (fn *FuncNode)
- func (t *Tree) M(depth int) Node
- func (t *Tree) O(depth int) Node
- func (t *Tree) P(depth int) Node
- func (t *Tree) String() string
- type TriNode
- func (m *TriNode) Check() error
- func (m *TriNode) Equal(n Node) bool
- func (m *TriNode) FromPB(n *NodePb) Node
- func (m *TriNode) String() string
- func (m *TriNode) StringNegate() string
- func (m *TriNode) ToPB() *NodePb
- func (m *TriNode) Type() reflect.Value
- func (m *TriNode) WriteDialect(w DialectWriter)
- func (m *TriNode) WriteNegate(w DialectWriter)
- type TriNodePb
- type UnaryNode
- type UnaryNodePb
- func (m *UnaryNodePb) Marshal() (data []byte, err error)
- func (m *UnaryNodePb) MarshalTo(data []byte) (int, error)
- func (*UnaryNodePb) ProtoMessage()
- func (m *UnaryNodePb) Reset()
- func (m *UnaryNodePb) Size() (n int)
- func (m *UnaryNodePb) String() string
- func (m *UnaryNodePb) Unmarshal(data []byte) error
- type ValueNode
- type ValueNodePb
- func (m *ValueNodePb) Marshal() (data []byte, err error)
- func (m *ValueNodePb) MarshalTo(data []byte) (int, error)
- func (*ValueNodePb) ProtoMessage()
- func (m *ValueNodePb) Reset()
- func (m *ValueNodePb) Size() (n int)
- func (m *ValueNodePb) String() string
- func (m *ValueNodePb) Unmarshal(data []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( // Standard errors ErrNotSupported = fmt.Errorf("qlbridge Not supported") ErrNotImplemented = fmt.Errorf("qlbridge Not implemented") ErrUnknownCommand = fmt.Errorf("qlbridge Unknown Command") ErrInternalError = fmt.Errorf("qlbridge Internal Error") )
var ( ErrInvalidLengthNode = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowNode = fmt.Errorf("proto: integer overflow") )
var DefaultDialect *lex.Dialect = lex.LogicalExpressionDialect
We have a default Dialect, which is the "Language" or rule-set of ql
Functions ¶
func AggFuncAdd ¶
func AggFuncAdd(name string, fn interface{})
AggFuncAdd Adding Aggregate functions which are special functions
that perform aggregation operations
func FindAllIdentityField ¶
Recursively descend down a node looking for all Identity Fields
min(year) == {year} eq(min(item), max(month)) == {item, month}
func FindIdentityField ¶
Recursively descend down a node looking for first Identity Field
min(year) == year eq(min(item), max(month)) == item
func FindIdentityName ¶
Recursively descend down a node looking for first Identity Field
and combine with outermost expression to create an alias min(year) == min_year eq(min(year), max(month)) == eq_year
func FuncAdd ¶
func FuncAdd(name string, fn interface{})
FuncAdd Global add Functions to the VM func registry occurs here.
Functions have the following pseudo interface. 1. They must have expr.ContextReader as first argument 2. They must accept 1 OR variadic number of value.Value arguments 3. Return must be a value.Value, or anything that implements value Interface and bool func(ctx expr.ContextReader, value.Value...) (value.Value, bool) { // function } func(ctx expr.ContextReader, value.Value...) (value.StringValue, bool) { // function } func(ctx expr.ContextReader, value.Value, value.Value) (value.NumberValue, bool) { // function }
func HasDateMath ¶
Determine if this expression node uses datemath (ie, "now-4h") - only works on right-hand of equation - doesn't work on args of a function
func IdentityMaybeEscapeBuf ¶
IdentityMaybeEscape Quote an identity/literal if need be (has illegal characters or spaces)
func IdentityMaybeQuote ¶
IdentityMaybeQuote
func IdentityMaybeQuoteStrict ¶
IdentityMaybeQuoteStrict Quote an identity if need be (has illegal characters or spaces)
First character MUST be alpha (not numeric or any other character)
func IdentityMaybeQuoteStrictBuf ¶
IdentityMaybeQuoteStrict Quote an identity if need be (has illegal characters or spaces)
First character MUST be alpha (not numeric or any other character)
func IdentityTrim ¶
IdentityTrim trims the leading/trailing identity quote marks ` or []
func LeftRight ¶
LeftRight Return left, right values if is of form `table.column` or `schema`.`table` also return true/false for if it even has left/right
func LiteralQuoteEscape ¶
LiteralQuoteEscape escape string that may need characters escaped
LiteralQuoteEscape("'","item's") => 'item''s' LiteralQuoteEscape(`"`,"item's") => "item's" LiteralQuoteEscape(`"`,`item"s`) => "item""s"
func LiteralQuoteEscapeBuf ¶
LiteralQuoteEscapeBuf escape string that may need characters escaped
LiteralQuoteEscapeBuf("'","item's") => 'item''s' LiteralQuoteEscapeBuf(`"`,"item's") => "item's" LiteralQuoteEscapeBuf(`"`,`item"s`) => "item""s"
func NodesEqual ¶
func StringEscape ¶
StringEscape escape string that may need characters escaped
StringEscape("'","item's") => "item''s"
func ValueArray ¶
func ValueArray(pg TokenPager) (value.Value, error)
ValueArray
IN ("a","b","c") ["a","b","c"]
Types ¶
type ArrayNode ¶
type ArrayNode struct { Args []Node // contains filtered or unexported fields }
Array Node for holding multiple similar elements
arg0 IN (arg1,arg2.....) 5 in (1,2,3,4)
func NewArrayNode ¶
func NewArrayNode() *ArrayNode
Create an array of Nodes which is a valid node type for boolean IN operator
func NewArrayNodeArgs ¶
func (*ArrayNode) WriteDialect ¶
func (m *ArrayNode) WriteDialect(w DialectWriter)
type ArrayNodePb ¶
type ArrayNodePb struct { Wrap *int32 `protobuf:"varint,1,req,name=wrap" json:"wrap,omitempty"` Args []NodePb `protobuf:"bytes,3,rep,name=args" json:"args"` XXX_unrecognized []byte `json:"-"` }
Array Node
func (*ArrayNodePb) Marshal ¶
func (m *ArrayNodePb) Marshal() (data []byte, err error)
func (*ArrayNodePb) ProtoMessage ¶
func (*ArrayNodePb) ProtoMessage()
func (*ArrayNodePb) Reset ¶
func (m *ArrayNodePb) Reset()
func (*ArrayNodePb) Size ¶
func (m *ArrayNodePb) Size() (n int)
func (*ArrayNodePb) String ¶
func (m *ArrayNodePb) String() string
func (*ArrayNodePb) Unmarshal ¶
func (m *ArrayNodePb) Unmarshal(data []byte) error
type BinaryNode ¶
Binary node is x op y, two nodes (left, right) and an operator operators can be a variety of:
+, -, *, %, /, LIKE, CONTAINS, INTERSECTS
Also, parenthesis may wrap these
func NewBinaryNode ¶
func NewBinaryNode(operator lex.Token, lhArg, rhArg Node) *BinaryNode
Create a Binary node
@operator = * + - %/ / && || = == @operator = and, or, "is not" @lhArg, rhArg the left, right side of binary
func (*BinaryNode) Check ¶
func (m *BinaryNode) Check() error
func (*BinaryNode) Equal ¶
func (m *BinaryNode) Equal(n Node) bool
func (*BinaryNode) FromPB ¶
func (m *BinaryNode) FromPB(n *NodePb) Node
func (*BinaryNode) String ¶
func (m *BinaryNode) String() string
func (*BinaryNode) StringNegate ¶
func (m *BinaryNode) StringNegate() string
func (*BinaryNode) ToPB ¶
func (m *BinaryNode) ToPB() *NodePb
func (*BinaryNode) Type ¶
func (m *BinaryNode) Type() reflect.Value
func (*BinaryNode) WriteDialect ¶
func (m *BinaryNode) WriteDialect(w DialectWriter)
func (*BinaryNode) WriteNegate ¶
func (m *BinaryNode) WriteNegate(w DialectWriter)
type BinaryNodePb ¶
type BinaryNodePb struct { Op int32 `protobuf:"varint,1,req,name=op" json:"op"` Paren bool `protobuf:"varint,2,opt,name=paren" json:"paren"` Args []NodePb `protobuf:"bytes,3,rep,name=args" json:"args"` XXX_unrecognized []byte `json:"-"` }
Binary Node, two child args
func (*BinaryNodePb) Marshal ¶
func (m *BinaryNodePb) Marshal() (data []byte, err error)
func (*BinaryNodePb) ProtoMessage ¶
func (*BinaryNodePb) ProtoMessage()
func (*BinaryNodePb) Reset ¶
func (m *BinaryNodePb) Reset()
func (*BinaryNodePb) Size ¶
func (m *BinaryNodePb) Size() (n int)
func (*BinaryNodePb) String ¶
func (m *BinaryNodePb) String() string
func (*BinaryNodePb) Unmarshal ¶
func (m *BinaryNodePb) Unmarshal(data []byte) error
type ContextReadWriter ¶
type ContextReadWriter interface { ContextReader ContextWriter }
type ContextReader ¶
type ContextReader interface { Get(key string) (value.Value, bool) Row() map[string]value.Value Ts() time.Time }
Context Reader is a key-value interface to read the context of message/row
using a Get("key") interface. Used by vm to evaluate messages
type ContextWriter ¶
type ContextWriter interface { Put(col SchemaInfo, readCtx ContextReader, v value.Value) error Delete(row map[string]value.Value) error }
For evaluation storage
vm writes results to this after evaluation
type DialectWriter ¶
type DialectWriter interface { io.Writer Len() int WriteLiteral(string) WriteIdentity(string) WriteNumber(string) WriteNull() WriteValue(v value.Value) String() string }
DialectWriters allow different dialects to have different escape characters - postgres: literal-escape = ', identity = " - mysql: literal-escape = ", identity = ` - cql: literal-escape - ', identity = `
func NewDefaultWriter ¶
func NewDefaultWriter() DialectWriter
func NewDialectWriter ¶
func NewDialectWriter(l, i byte) DialectWriter
func NewFingerPrintWriter ¶
func NewFingerPrintWriter(replace string, w DialectWriter) DialectWriter
func NewFingerPrinter ¶
func NewFingerPrinter() DialectWriter
func NewKeywordDialect ¶
func NewKeywordDialect(kw []string) DialectWriter
type EvalContext ¶
type EvalContext interface { ContextReader }
Eval context, used to contain info for usage/lookup at runtime evaluation
type Func ¶
type Func struct { Name string Aggregate bool // is this aggregate func? // The arguments we expect Args []reflect.Value VariadicArgs bool Return reflect.Value ReturnValueType value.ValueType // The actual Go Function F reflect.Value }
Describes a function which wraps and allows native go functions
to be called (via reflection) via scripting
type FuncNode ¶
type FuncNode struct { Name string // Name of func F Func // The actual function that this AST maps to Missing bool Args []Node // Arguments are them-selves nodes }
FuncNode holds a Func, which desribes a go Function as well as fulfilling the Pos, String() etc for a Node
interfaces: Node
func NewFuncNode ¶
func (*FuncNode) WriteDialect ¶
func (m *FuncNode) WriteDialect(w DialectWriter)
type FuncNodePb ¶
type FuncNodePb struct { Name string `protobuf:"bytes,1,req,name=name" json:"name"` Args []NodePb `protobuf:"bytes,2,rep,name=args" json:"args"` XXX_unrecognized []byte `json:"-"` }
Func Node, args are children
func (*FuncNodePb) Marshal ¶
func (m *FuncNodePb) Marshal() (data []byte, err error)
func (*FuncNodePb) ProtoMessage ¶
func (*FuncNodePb) ProtoMessage()
func (*FuncNodePb) Reset ¶
func (m *FuncNodePb) Reset()
func (*FuncNodePb) Size ¶
func (m *FuncNodePb) Size() (n int)
func (*FuncNodePb) String ¶
func (m *FuncNodePb) String() string
func (*FuncNodePb) Unmarshal ¶
func (m *FuncNodePb) Unmarshal(data []byte) error
type FuncRegistry ¶
type FuncRegistry struct {
// contains filtered or unexported fields
}
func NewFuncRegistry ¶
func NewFuncRegistry() *FuncRegistry
func (*FuncRegistry) Add ¶
func (m *FuncRegistry) Add(name string, fn interface{})
type FuncResolver ¶
FuncResolver is a function resolution service that allows
local/namespaced function resolution
type IdentityNode ¶
IdentityNode will look up a value out of a env bag
also identities of sql objects (tables, columns, etc) we often need to rewrite these as in sql it is `table.column`
func NewIdentityNode ¶
func NewIdentityNode(tok *lex.Token) *IdentityNode
func NewIdentityNodeVal ¶
func NewIdentityNodeVal(val string) *IdentityNode
func (*IdentityNode) Bool ¶
func (m *IdentityNode) Bool() bool
func (*IdentityNode) Check ¶
func (m *IdentityNode) Check() error
func (*IdentityNode) Equal ¶
func (m *IdentityNode) Equal(n Node) bool
func (*IdentityNode) FromPB ¶
func (m *IdentityNode) FromPB(n *NodePb) Node
func (*IdentityNode) HasLeftRight ¶
func (m *IdentityNode) HasLeftRight() bool
HasLeftRight Return bool if is of form `table.column` or `schema`.`table`
func (*IdentityNode) IsBooleanIdentity ¶
func (m *IdentityNode) IsBooleanIdentity() bool
func (*IdentityNode) LeftRight ¶
func (m *IdentityNode) LeftRight() (string, string, bool)
Return left, right values if is of form `table.column` or `schema`.`table` and also return true/false for if it even has left & right syntax
func (*IdentityNode) OriginalText ¶
func (m *IdentityNode) OriginalText() string
func (*IdentityNode) String ¶
func (m *IdentityNode) String() string
func (*IdentityNode) ToPB ¶
func (m *IdentityNode) ToPB() *NodePb
func (*IdentityNode) Type ¶
func (m *IdentityNode) Type() reflect.Value
func (*IdentityNode) WriteDialect ¶
func (m *IdentityNode) WriteDialect(w DialectWriter)
type IdentityNodePb ¶
type IdentityNodePb struct { Quote *int32 `protobuf:"varint,1,opt,name=quote" json:"quote,omitempty"` Text string `protobuf:"bytes,3,opt,name=text" json:"text"` XXX_unrecognized []byte `json:"-"` }
Identity
func (*IdentityNodePb) Marshal ¶
func (m *IdentityNodePb) Marshal() (data []byte, err error)
func (*IdentityNodePb) ProtoMessage ¶
func (*IdentityNodePb) ProtoMessage()
func (*IdentityNodePb) Reset ¶
func (m *IdentityNodePb) Reset()
func (*IdentityNodePb) Size ¶
func (m *IdentityNodePb) Size() (n int)
func (*IdentityNodePb) String ¶
func (m *IdentityNodePb) String() string
func (*IdentityNodePb) Unmarshal ¶
func (m *IdentityNodePb) Unmarshal(data []byte) error
type LexTokenPager ¶
type LexTokenPager struct {
// contains filtered or unexported fields
}
TokenPager is responsible for determining end of current tree (column, etc)
func NewLexTokenPager ¶
func NewLexTokenPager(lex *lex.Lexer) *LexTokenPager
func (*LexTokenPager) Backup ¶
func (m *LexTokenPager) Backup()
backup backs the input stream up one token.
func (*LexTokenPager) ClauseEnd ¶
func (m *LexTokenPager) ClauseEnd() bool
ClauseEnd are we at end of clause
func (*LexTokenPager) Cur ¶
func (m *LexTokenPager) Cur() lex.Token
Returns the current token, does not advance
func (*LexTokenPager) IsEnd ¶
func (m *LexTokenPager) IsEnd() bool
IsEnd determines if pager is at end of statement
func (*LexTokenPager) Lexer ¶
func (m *LexTokenPager) Lexer() *lex.Lexer
Lexer get the underlying lexer
func (*LexTokenPager) Next ¶
func (m *LexTokenPager) Next() lex.Token
Next returns the current token and advances cursor to next one
func (*LexTokenPager) Peek ¶
func (m *LexTokenPager) Peek() lex.Token
Peek returns but does not consume the next token.
type NegateableNode ¶
type NegateableNode interface { StringNegate() string WriteNegate(w DialectWriter) }
A negateable node requires a special type of String() function due to an enclosing urnary NOT being inserted into middle of string syntax
<expression> [NOT] IN ("a","b") <expression> [NOT] BETWEEN <expression> AND <expression> <expression> [NOT] LIKE <expression> <expression> [NOT] CONTAINS <expression> <expression> [NOT] INTERSECTS ("a", "b")
type Node ¶
type Node interface { // string representation of Node parseable back to itself String() string // Given a dialect writer write to writer WriteDialect(w DialectWriter) // performs type and syntax checking for itself and sub-nodes, evaluates // validity of the expression/node in advance of evaluation Check() error // Protobuf helpers that convert to serializeable format and marshall ToPB() *NodePb FromPB(*NodePb) Node // for testing purposes Equal(Node) bool }
A Node is an element in the expression tree, implemented by different types (binary, urnary, func, identity, etc)
- qlbridge does not currently implement statements (if, for, switch, etc) just expressions, and operators
func NodeFromNodePb ¶
func NodesFromNodesPb ¶
func NodesFromNodesPbPtr ¶
type NodePb ¶
type NodePb struct { Bn *BinaryNodePb `protobuf:"bytes,1,opt,name=bn" json:"bn,omitempty"` Un *UnaryNodePb `protobuf:"bytes,2,opt,name=un" json:"un,omitempty"` Fn *FuncNodePb `protobuf:"bytes,3,opt,name=fn" json:"fn,omitempty"` Tn *TriNodePb `protobuf:"bytes,4,opt,name=tn" json:"tn,omitempty"` An *ArrayNodePb `protobuf:"bytes,5,opt,name=an" json:"an,omitempty"` Nn *NumberNodePb `protobuf:"bytes,10,opt,name=nn" json:"nn,omitempty"` Vn *ValueNodePb `protobuf:"bytes,11,opt,name=vn" json:"vn,omitempty"` In *IdentityNodePb `protobuf:"bytes,12,opt,name=in" json:"in,omitempty"` Sn *StringNodePb `protobuf:"bytes,13,opt,name=sn" json:"sn,omitempty"` XXX_unrecognized []byte `json:"-"` }
The generic Node, must be exactly one of these types
func NodesPbFromNodes ¶
func (*NodePb) ProtoMessage ¶
func (*NodePb) ProtoMessage()
type NodeValueType ¶
Node that has a Type Value, similar to a literal, but can
contain value's such as []string, etc
type NullNode ¶
type NullNode struct{}
func (*NullNode) WriteDialect ¶
func (m *NullNode) WriteDialect(w DialectWriter)
type NumberNode ¶
type NumberNode struct { IsInt bool // Number has an integer value. IsFloat bool // Number has a floating-point value. Int64 int64 // The integer value. Float64 float64 // The floating-point value. Text string // The original textual representation from the input. }
NumberNode holds a number: signed or unsigned integer or float. The value is parsed and stored under all the types that can represent the value. This simulates in a small amount of code the behavior of Go's ideal constants.
func NewNumber ¶
func NewNumber(fv float64) (*NumberNode, error)
func NewNumberStr ¶
func NewNumberStr(text string) (*NumberNode, error)
NewNumberStr is a little weird in that this Node accepts string @text and uses go to parse into Int, AND Float.
func (*NumberNode) Check ¶
func (n *NumberNode) Check() error
func (*NumberNode) Equal ¶
func (m *NumberNode) Equal(n Node) bool
func (*NumberNode) FromPB ¶
func (m *NumberNode) FromPB(n *NodePb) Node
func (*NumberNode) String ¶
func (n *NumberNode) String() string
func (*NumberNode) ToPB ¶
func (m *NumberNode) ToPB() *NodePb
func (*NumberNode) Type ¶
func (n *NumberNode) Type() reflect.Value
func (*NumberNode) WriteDialect ¶
func (m *NumberNode) WriteDialect(w DialectWriter)
type NumberNodePb ¶
type NumberNodePb struct { Isint bool `protobuf:"varint,1,opt,name=isint" json:"isint"` Isfloat bool `protobuf:"varint,2,opt,name=isfloat" json:"isfloat"` Iv int64 `protobuf:"varint,3,req,name=iv" json:"iv"` Fv float64 `protobuf:"fixed64,4,req,name=fv" json:"fv"` Text string `protobuf:"bytes,5,req,name=text" json:"text"` XXX_unrecognized []byte `json:"-"` }
Number Node
func (*NumberNodePb) Marshal ¶
func (m *NumberNodePb) Marshal() (data []byte, err error)
func (*NumberNodePb) ProtoMessage ¶
func (*NumberNodePb) ProtoMessage()
func (*NumberNodePb) Reset ¶
func (m *NumberNodePb) Reset()
func (*NumberNodePb) Size ¶
func (m *NumberNodePb) Size() (n int)
func (*NumberNodePb) String ¶
func (m *NumberNodePb) String() string
func (*NumberNodePb) Unmarshal ¶
func (m *NumberNodePb) Unmarshal(data []byte) error
type RowWriter ¶
type RowWriter interface { Commit(rowInfo []SchemaInfo, row RowWriter) error Put(col SchemaInfo, readCtx ContextReader, v value.Value) error }
for commiting row ops (insert, update)
type SchemaInfo ¶
type SchemaInfo interface {
Key() string
}
SchemaInfo is interface for a Column type
type SchemaInfoString ¶
type SchemaInfoString string
SchemaInfoString implements schemaInfo Key()
func (SchemaInfoString) Key ¶
func (m SchemaInfoString) Key() string
type StringNode ¶
StringNode holds a value literal, quotes not included
func NewStringNoQuoteNode ¶
func NewStringNoQuoteNode(text string) *StringNode
func NewStringNode ¶
func NewStringNode(text string) *StringNode
func NewStringNodeToken ¶
func NewStringNodeToken(t lex.Token) *StringNode
func (*StringNode) Check ¶
func (m *StringNode) Check() error
func (*StringNode) Equal ¶
func (m *StringNode) Equal(n Node) bool
func (*StringNode) FromPB ¶
func (m *StringNode) FromPB(n *NodePb) Node
func (*StringNode) String ¶
func (m *StringNode) String() string
func (*StringNode) ToPB ¶
func (m *StringNode) ToPB() *NodePb
func (*StringNode) WriteDialect ¶
func (m *StringNode) WriteDialect(w DialectWriter)
type StringNodePb ¶
type StringNodePb struct { Noquote *bool `protobuf:"varint,1,opt,name=noquote" json:"noquote,omitempty"` Quote *int32 `protobuf:"varint,2,opt,name=quote" json:"quote,omitempty"` Text string `protobuf:"bytes,3,opt,name=text" json:"text"` XXX_unrecognized []byte `json:"-"` }
String literal, no children
func (*StringNodePb) Marshal ¶
func (m *StringNodePb) Marshal() (data []byte, err error)
func (*StringNodePb) ProtoMessage ¶
func (*StringNodePb) ProtoMessage()
func (*StringNodePb) Reset ¶
func (m *StringNodePb) Reset()
func (*StringNodePb) Size ¶
func (m *StringNodePb) Size() (n int)
func (*StringNodePb) String ¶
func (m *StringNodePb) String() string
func (*StringNodePb) Unmarshal ¶
func (m *StringNodePb) Unmarshal(data []byte) error
type TokenPager ¶
type TokenPager interface { Peek() lex.Token Next() lex.Token Cur() lex.Token Backup() IsEnd() bool ClauseEnd() bool Lexer() *lex.Lexer }
TokenPager wraps a Lexer, and implements the Logic to determine what is the end of this particular clause. Lexer's are stateless, while tokenpager implements state ontop of pager and allows forward/back etc
type Tree ¶
type Tree struct { Root Node // top-level root node of the tree TokenPager // pager for grabbing next tokens, backup(), recognizing end // contains filtered or unexported fields }
Tree is the representation of a single parsed expression
func NewTree ¶
func NewTree(pager TokenPager) *Tree
func NewTreeFuncs ¶
func NewTreeFuncs(pager TokenPager, fr FuncResolver) *Tree
func ParseExpression ¶
Parse a single Expression, returning a Tree
ParseExpression("5 * toint(item_name)")
type TriNode ¶
Tri Node
ARG1 Between ARG2 AND ARG3
func (*TriNode) StringNegate ¶
func (*TriNode) WriteDialect ¶
func (m *TriNode) WriteDialect(w DialectWriter)
func (*TriNode) WriteNegate ¶
func (m *TriNode) WriteNegate(w DialectWriter)
type TriNodePb ¶
type TriNodePb struct { Op int32 `protobuf:"varint,1,req,name=op" json:"op"` Args []NodePb `protobuf:"bytes,2,rep,name=args" json:"args"` XXX_unrecognized []byte `json:"-"` }
Tri Node, may hve children
func (*TriNodePb) ProtoMessage ¶
func (*TriNodePb) ProtoMessage()
type UnaryNode ¶
UnaryNode negates a single node argument
( not <expression> | !<expression> ) !eq(5,6) !true !(true OR false) !toint(now())
func (*UnaryNode) WriteDialect ¶
func (m *UnaryNode) WriteDialect(w DialectWriter)
type UnaryNodePb ¶
type UnaryNodePb struct { Op int32 `protobuf:"varint,1,req,name=op" json:"op"` Paren bool `protobuf:"varint,2,opt,name=paren" json:"paren"` Arg NodePb `protobuf:"bytes,3,req,name=arg" json:"arg"` XXX_unrecognized []byte `json:"-"` }
Unary Node, one child
func (*UnaryNodePb) Marshal ¶
func (m *UnaryNodePb) Marshal() (data []byte, err error)
func (*UnaryNodePb) ProtoMessage ¶
func (*UnaryNodePb) ProtoMessage()
func (*UnaryNodePb) Reset ¶
func (m *UnaryNodePb) Reset()
func (*UnaryNodePb) Size ¶
func (m *UnaryNodePb) Size() (n int)
func (*UnaryNodePb) String ¶
func (m *UnaryNodePb) String() string
func (*UnaryNodePb) Unmarshal ¶
func (m *UnaryNodePb) Unmarshal(data []byte) error
type ValueNode ¶
Value holds a value.Value type
value.Values can be strings, numbers, arrays, objects, etc
func NewValueNode ¶
func (*ValueNode) WriteDialect ¶
func (m *ValueNode) WriteDialect(w DialectWriter)
type ValueNodePb ¶
type ValueNodePb struct { Valuetype int32 `protobuf:"varint,1,req,name=valuetype" json:"valuetype"` Value []byte `protobuf:"bytes,2,req,name=value" json:"value,omitempty"` XXX_unrecognized []byte `json:"-"` }
Value Node
func (*ValueNodePb) Marshal ¶
func (m *ValueNodePb) Marshal() (data []byte, err error)
func (*ValueNodePb) ProtoMessage ¶
func (*ValueNodePb) ProtoMessage()
func (*ValueNodePb) Reset ¶
func (m *ValueNodePb) Reset()
func (*ValueNodePb) Size ¶
func (m *ValueNodePb) Size() (n int)
func (*ValueNodePb) String ¶
func (m *ValueNodePb) String() string
func (*ValueNodePb) Unmarshal ¶
func (m *ValueNodePb) Unmarshal(data []byte) error
Directories
¶
Path | Synopsis |
---|---|
Builtin functions are a library of functions natively available in qlbridge expression evaluation although adding your own is easy.
|
Builtin functions are a library of functions natively available in qlbridge expression evaluation although adding your own is easy. |