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: ExprPb NodePb BinaryNodePb BooleanNodePb IncludeNodePb UnaryNodePb FuncNodePb TriNodePb ArrayNodePb StringNodePb IdentityNodePb NumberNodePb ValueNodePb NullNodePb
Index ¶
- Variables
- func EmptyEvalFunc(ctx EvalContext, args []value.Value) (value.Value, bool)
- func FilterSpecialIdentities(l []string) []string
- func FindAllIdentityField(node Node) []string
- func FindAllLeftIdentityFields(node Node) []string
- func FindFirstIdentity(node Node) string
- func FindIdentityName(depth int, node Node, prefix string) string
- func FindIncludes(node Node) []string
- func FuncAdd(name string, fn CustomFunc)
- 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 IsValidIdentity(identity 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 StringUnEscape(quote rune, val string) (string, bool)
- func ValueArray(depth int, pg TokenPager) (value.Value, error)
- func ValueTypeFromNode(n Node) value.ValueType
- type AggFunc
- type ArrayNode
- func (m *ArrayNode) Append(n Node)
- func (m *ArrayNode) ChildrenArgs() []Node
- func (m *ArrayNode) Equal(n Node) bool
- func (m *ArrayNode) Expr() *Expr
- func (m *ArrayNode) FromExpr(e *Expr) error
- func (m *ArrayNode) FromPB(n *NodePb) Node
- func (m *ArrayNode) NodePb() *NodePb
- func (m *ArrayNode) NodeType() string
- func (m *ArrayNode) String() string
- func (m *ArrayNode) Validate() error
- func (m *ArrayNode) WriteDialect(w DialectWriter)
- type ArrayNodePb
- func (*ArrayNodePb) Descriptor() ([]byte, []int)
- 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) ChildrenArgs() []Node
- func (m *BinaryNode) Equal(n Node) bool
- func (m *BinaryNode) Expr() *Expr
- func (m *BinaryNode) FromExpr(e *Expr) error
- func (m *BinaryNode) FromPB(n *NodePb) Node
- func (m *BinaryNode) NodePb() *NodePb
- func (m *BinaryNode) NodeType() string
- func (m *BinaryNode) String() string
- func (m *BinaryNode) Validate() error
- func (m *BinaryNode) WriteDialect(w DialectWriter)
- type BinaryNodePb
- func (*BinaryNodePb) Descriptor() ([]byte, []int)
- 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 BooleanNode
- func (m *BooleanNode) ChildrenArgs() []Node
- func (m *BooleanNode) Collapse() Node
- func (m *BooleanNode) Equal(n Node) bool
- func (m *BooleanNode) Expr() *Expr
- func (m *BooleanNode) FromExpr(e *Expr) error
- func (m *BooleanNode) FromPB(n *NodePb) Node
- func (m *BooleanNode) Negated() bool
- func (m *BooleanNode) NodePb() *NodePb
- func (m *BooleanNode) NodeType() string
- func (m *BooleanNode) ReverseNegation() bool
- func (m *BooleanNode) String() string
- func (m *BooleanNode) StringNegate() string
- func (m *BooleanNode) Validate() error
- func (m *BooleanNode) WriteDialect(w DialectWriter)
- func (m *BooleanNode) WriteNegate(w DialectWriter)
- type BooleanNodePb
- func (*BooleanNodePb) Descriptor() ([]byte, []int)
- func (m *BooleanNodePb) Marshal() (data []byte, err error)
- func (m *BooleanNodePb) MarshalTo(data []byte) (int, error)
- func (*BooleanNodePb) ProtoMessage()
- func (m *BooleanNodePb) Reset()
- func (m *BooleanNodePb) Size() (n int)
- func (m *BooleanNodePb) String() string
- func (m *BooleanNodePb) Unmarshal(data []byte) error
- type ContextReadWriter
- type ContextReader
- type ContextWriter
- type CustomFunc
- type DialectWriter
- type EvalContext
- type EvalIncludeContext
- type EvaluatorFunc
- type Expr
- type ExprPb
- func (*ExprPb) Descriptor() ([]byte, []int)
- func (m *ExprPb) Marshal() (data []byte, err error)
- func (m *ExprPb) MarshalTo(data []byte) (int, error)
- func (*ExprPb) ProtoMessage()
- func (m *ExprPb) Reset()
- func (m *ExprPb) Size() (n int)
- func (m *ExprPb) String() string
- func (m *ExprPb) Unmarshal(data []byte) error
- type Func
- type FuncNode
- func (m *FuncNode) ChildrenArgs() []Node
- func (m *FuncNode) Equal(n Node) bool
- func (m *FuncNode) Expr() *Expr
- func (m *FuncNode) FromExpr(e *Expr) error
- func (m *FuncNode) FromPB(n *NodePb) Node
- func (m *FuncNode) NodePb() *NodePb
- func (m *FuncNode) NodeType() string
- func (m *FuncNode) String() string
- func (m *FuncNode) Validate() error
- func (m *FuncNode) WriteDialect(w DialectWriter)
- type FuncNodePb
- func (*FuncNodePb) Descriptor() ([]byte, []int)
- func (m *FuncNodePb) Marshal() (data []byte, err error)
- func (m *FuncNodePb) MarshalTo(data []byte) (int, error)
- func (*FuncNodePb) ProtoMessage()
- func (m *FuncNodePb) Reset()
- func (m *FuncNodePb) Size() (n int)
- func (m *FuncNodePb) String() string
- func (m *FuncNodePb) Unmarshal(data []byte) error
- type FuncRegistry
- type FuncResolver
- type IdentityNode
- func (m *IdentityNode) Bool() bool
- func (m *IdentityNode) Equal(n Node) bool
- func (m *IdentityNode) Expr() *Expr
- func (m *IdentityNode) FromExpr(e *Expr) error
- func (m *IdentityNode) FromPB(n *NodePb) Node
- func (m *IdentityNode) HasLeftRight() bool
- func (m *IdentityNode) IdentityPb() *IdentityNodePb
- func (m *IdentityNode) IsBooleanIdentity() bool
- func (m *IdentityNode) LeftRight() (string, string, bool)
- func (m *IdentityNode) NodePb() *NodePb
- func (m *IdentityNode) NodeType() string
- func (m *IdentityNode) OriginalText() string
- func (m *IdentityNode) String() string
- func (m *IdentityNode) Validate() error
- func (m *IdentityNode) WriteDialect(w DialectWriter)
- type IdentityNodePb
- func (*IdentityNodePb) Descriptor() ([]byte, []int)
- 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 IdentityNodes
- type IncludeContext
- type IncludeNode
- func (m *IncludeNode) Collapse() Node
- func (m *IncludeNode) Equal(n Node) bool
- func (m *IncludeNode) Expr() *Expr
- func (m *IncludeNode) FromExpr(e *Expr) error
- func (m *IncludeNode) FromPB(n *NodePb) Node
- func (m *IncludeNode) Negated() bool
- func (m *IncludeNode) NodePb() *NodePb
- func (m *IncludeNode) NodeType() string
- func (m *IncludeNode) ReverseNegation() bool
- func (m *IncludeNode) String() string
- func (m *IncludeNode) StringNegate() string
- func (m *IncludeNode) Validate() error
- func (m *IncludeNode) WriteDialect(w DialectWriter)
- func (m *IncludeNode) WriteNegate(w DialectWriter)
- type IncludeNodePb
- func (*IncludeNodePb) Descriptor() ([]byte, []int)
- func (m *IncludeNodePb) Marshal() (data []byte, err error)
- func (m *IncludeNodePb) MarshalTo(data []byte) (int, error)
- func (*IncludeNodePb) ProtoMessage()
- func (m *IncludeNodePb) Reset()
- func (m *IncludeNodePb) Size() (n int)
- func (m *IncludeNodePb) String() string
- func (m *IncludeNodePb) Unmarshal(data []byte) error
- type Includer
- type LexTokenPager
- func (m *LexTokenPager) Backup()
- func (m *LexTokenPager) ClauseEnd() bool
- func (m *LexTokenPager) Cur() lex.Token
- func (m *LexTokenPager) ErrMsg(msg string) error
- func (m *LexTokenPager) IsEnd() bool
- func (m *LexTokenPager) Lexer() *lex.Lexer
- func (m *LexTokenPager) Next() lex.Token
- func (m *LexTokenPager) Peek() lex.Token
- type NegateableNode
- type Node
- func InlineIncludes(ctx Includer, n Node) (Node, error)
- func MustParse(expressionText string) Node
- func NewUnary(operator lex.Token, arg Node) Node
- func NodeFromExpr(e *Expr) (Node, error)
- func NodeFromNodePb(n *NodePb) Node
- func NodeFromPb(pb []byte) (Node, error)
- func NodesFromExprs(args []*Expr) ([]Node, error)
- func NodesFromNodesPb(pb []NodePb) []Node
- func NodesFromNodesPbPtr(pb []*NodePb) []Node
- func ParseExprWithFuncs(p TokenPager, fr FuncResolver) (Node, error)
- func ParseExpression(expressionText string) (Node, error)
- func ParsePager(pager TokenPager) (Node, error)
- type NodeArgs
- type NodePb
- func (*NodePb) Descriptor() ([]byte, []int)
- func (m *NodePb) Marshal() (data []byte, err error)
- func (m *NodePb) MarshalTo(data []byte) (int, error)
- func (*NodePb) ProtoMessage()
- func (m *NodePb) Reset()
- func (m *NodePb) Size() (n int)
- func (m *NodePb) String() string
- func (m *NodePb) Unmarshal(data []byte) error
- type NullNode
- func (m *NullNode) Equal(n Node) bool
- func (m *NullNode) Expr() *Expr
- func (m *NullNode) FromExpr(e *Expr) error
- func (m *NullNode) FromPB(n *NodePb) Node
- func (m *NullNode) NodePb() *NodePb
- func (m *NullNode) NodeType() string
- func (m *NullNode) String() string
- func (m *NullNode) Validate() error
- func (m *NullNode) WriteDialect(w DialectWriter)
- type NullNodePb
- func (*NullNodePb) Descriptor() ([]byte, []int)
- func (m *NullNodePb) Marshal() (data []byte, err error)
- func (m *NullNodePb) MarshalTo(data []byte) (int, error)
- func (*NullNodePb) ProtoMessage()
- func (m *NullNodePb) Reset()
- func (m *NullNodePb) Size() (n int)
- func (m *NullNodePb) String() string
- func (m *NullNodePb) Unmarshal(data []byte) error
- type NumberNode
- func (m *NumberNode) Equal(n Node) bool
- func (m *NumberNode) Expr() *Expr
- func (m *NumberNode) FromExpr(e *Expr) error
- func (m *NumberNode) FromPB(n *NodePb) Node
- func (m *NumberNode) NodePb() *NodePb
- func (m *NumberNode) NodeType() string
- func (n *NumberNode) String() string
- func (m *NumberNode) Validate() error
- func (m *NumberNode) WriteDialect(w DialectWriter)
- type NumberNodePb
- func (*NumberNodePb) Descriptor() ([]byte, []int)
- 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
- func (m *StringNode) Equal(n Node) bool
- func (m *StringNode) Expr() *Expr
- func (m *StringNode) FromExpr(e *Expr) error
- func (m *StringNode) FromPB(n *NodePb) Node
- func (m *StringNode) NodePb() *NodePb
- func (m *StringNode) NodeType() string
- func (m *StringNode) String() string
- func (m *StringNode) Validate() error
- func (m *StringNode) WriteDialect(w DialectWriter)
- type StringNodePb
- func (*StringNodePb) Descriptor() ([]byte, []int)
- 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 TriNode
- func (m *TriNode) ChildrenArgs() []Node
- func (m *TriNode) Collapse() Node
- func (m *TriNode) Equal(n Node) bool
- func (m *TriNode) Expr() *Expr
- func (m *TriNode) FromExpr(e *Expr) error
- func (m *TriNode) FromPB(n *NodePb) Node
- func (m *TriNode) Negated() bool
- func (m *TriNode) NodePb() *NodePb
- func (m *TriNode) NodeType() string
- func (m *TriNode) ReverseNegation() bool
- func (m *TriNode) String() string
- func (m *TriNode) StringNegate() string
- func (m *TriNode) Validate() error
- func (m *TriNode) WriteDialect(w DialectWriter)
- func (m *TriNode) WriteNegate(w DialectWriter)
- type TriNodePb
- func (*TriNodePb) Descriptor() ([]byte, []int)
- func (m *TriNodePb) Marshal() (data []byte, err error)
- func (m *TriNodePb) MarshalTo(data []byte) (int, error)
- func (*TriNodePb) ProtoMessage()
- func (m *TriNodePb) Reset()
- func (m *TriNodePb) Size() (n int)
- func (m *TriNodePb) String() string
- func (m *TriNodePb) Unmarshal(data []byte) error
- type UnaryNode
- func (m *UnaryNode) ChildrenArgs() []Node
- func (m *UnaryNode) Collapse() Node
- func (m *UnaryNode) Equal(n Node) bool
- func (m *UnaryNode) Expr() *Expr
- func (m *UnaryNode) FromExpr(e *Expr) error
- func (m *UnaryNode) FromPB(n *NodePb) Node
- func (m *UnaryNode) NodePb() *NodePb
- func (m *UnaryNode) NodeType() string
- func (m *UnaryNode) String() string
- func (m *UnaryNode) Validate() error
- func (m *UnaryNode) WriteDialect(w DialectWriter)
- type UnaryNodePb
- func (*UnaryNodePb) Descriptor() ([]byte, []int)
- 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
- func (m *ValueNode) Equal(n Node) bool
- func (m *ValueNode) Expr() *Expr
- func (m *ValueNode) FromExpr(e *Expr) error
- func (m *ValueNode) FromPB(n *NodePb) Node
- func (m *ValueNode) NodePb() *NodePb
- func (m *ValueNode) NodeType() string
- func (m *ValueNode) String() string
- func (m *ValueNode) Validate() error
- func (m *ValueNode) WriteDialect(w DialectWriter)
- type ValueNodePb
- func (*ValueNodePb) Descriptor() ([]byte, []int)
- 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 ( // ErrNotSupported indicates an error of a piece of expression syntax not // being supported. ErrNotSupported = fmt.Errorf("Not supported") // ErrNotImplemented an error of expression/statement syntax not being supported ErrNotImplemented = fmt.Errorf("Not implemented") // ErrUnknownCommand Unknown Command ErrUnknownCommand = fmt.Errorf("Unknown Command") // ErrInternalError Internal Error ErrInternalError = fmt.Errorf("Internal Error") // 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") // ErrIncludeNotFound Include Not Found ErrIncludeNotFound = fmt.Errorf("Include Not Found") )
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
var ( // If we hit max depth ErrMaxDepth = fmt.Errorf("Recursive Evaluation Error") )
var (
Trace bool
)
Functions ¶
func EmptyEvalFunc ¶
EmptyEvalFunc a no-op evaluation function for use in
func FilterSpecialIdentities ¶
FilterSpecialIdentities given a list of identities, filter out special identities such as "null", "*", "match_all"
func FindAllIdentityField ¶
FindAllIdentityField Recursively descend down a node looking for all Identity Fields
min(year) == {year} eq(min(user.name), max(month)) == {user.name, month}
func FindAllLeftIdentityFields ¶
FindAllLeftIdentityFields Recursively descend down a node looking for all LEFT Identity Fields
min(year) == {year} eq(min(user.name), max(month)) == {user, month}
func FindFirstIdentity ¶
FindFirstIdentity Recursively descend down a node looking for first Identity Field
min(year) == year eq(min(item), max(month)) == item eq(min(user.last_name), max(month)) == user.last_name
func FindIdentityName ¶
FindIdentityName Recursively walk 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 EXISTS url => "exists_url"
func FindIncludes ¶
FindIncludes recursively descend down a node looking for all Include identities
func FuncAdd ¶
func FuncAdd(name string, fn CustomFunc)
FuncAdd Global add Functions to the VM func registry occurs here.
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 IsValidIdentity ¶
IsValidIdentity test the given string to determine if any characters are not valid and therefore must be quoted
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 StringUnEscape ¶
StringUnEscape remove escaping on string that may need characters escaped
StringUnEscape(`"`,`item"s`) => "item""s", true
func ValueArray ¶
func ValueArray(depth int, pg TokenPager) (value.Value, error)
ValueArray
IN ("a","b","c") ["a","b","c"]
func ValueTypeFromNode ¶
ValueTypeFromNode Infer Value type from Node
Types ¶
type AggFunc ¶
type AggFunc interface {
IsAgg() bool
}
AggFunc allows custom functions to specify if they provide aggregation
type ArrayNode ¶
type ArrayNode struct { Args []Node // contains filtered or unexported fields }
ArrayNode 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) ChildrenArgs ¶
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) Descriptor ¶
func (*ArrayNodePb) Descriptor() ([]byte, []int)
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 ¶
type BinaryNode struct { Paren bool Args []Node Operator lex.Token // contains filtered or unexported fields }
BinaryNode 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) ChildrenArgs ¶
func (m *BinaryNode) ChildrenArgs() []Node
func (*BinaryNode) Equal ¶
func (m *BinaryNode) Equal(n Node) bool
func (*BinaryNode) Expr ¶
func (m *BinaryNode) Expr() *Expr
func (*BinaryNode) FromExpr ¶
func (m *BinaryNode) FromExpr(e *Expr) error
func (*BinaryNode) FromPB ¶
func (m *BinaryNode) FromPB(n *NodePb) Node
func (*BinaryNode) NodePb ¶
func (m *BinaryNode) NodePb() *NodePb
func (*BinaryNode) NodeType ¶
func (m *BinaryNode) NodeType() string
func (*BinaryNode) String ¶
func (m *BinaryNode) String() string
func (*BinaryNode) Validate ¶
func (m *BinaryNode) Validate() error
Negation I wanted to do negation on Binaries, but ended up not doing for now
ie, rewrite NOT (X == "y") => X != "y"
The general problem we ran into is that we lose some fidelity in collapsing AST that is necessary for other evaluation run-times.
logically `NOT (X > y)` is NOT THE SAME AS `(X <= y) due to lack of existence of X
func (m *BinaryNode) ReverseNegation() bool { switch m.Operator.T { case lex.TokenEqualEqual: m.Operator.T = lex.TokenNE m.Operator.V = m.Operator.T.String() case lex.TokenNE: m.Operator.T = lex.TokenEqualEqual m.Operator.V = m.Operator.T.String() case lex.TokenLT: m.Operator.T = lex.TokenGE m.Operator.V = m.Operator.T.String() case lex.TokenLE: m.Operator.T = lex.TokenGT m.Operator.V = m.Operator.T.String() case lex.TokenGT: m.Operator.T = lex.TokenLE m.Operator.V = m.Operator.T.String() case lex.TokenGE: m.Operator.T = lex.TokenLT m.Operator.V = m.Operator.T.String() default: //u.Warnf("What, what is this? %s", m) m.negated = !m.negated return true } return true }
func (m *BinaryNode) Collapse() Node { return m } func (m *BinaryNode) Negated() bool { return m.negated }
func (m *BinaryNode) StringNegate() string { w := NewDefaultWriter() m.WriteNegate(w) return w.String() }
func (m *BinaryNode) WriteNegate(w DialectWriter) { switch m.Operator.T { case lex.TokenIN, lex.TokenIntersects, lex.TokenLike, lex.TokenContains: m.writeToString(w, "NOT ") default: m.writeToString(w, "") } }
func (*BinaryNode) WriteDialect ¶
func (m *BinaryNode) WriteDialect(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) Descriptor ¶
func (*BinaryNodePb) Descriptor() ([]byte, []int)
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 BooleanNode ¶
type BooleanNode struct { Args []Node Operator lex.Token // contains filtered or unexported fields }
BooleanNode is n nodes and an operator operators can be only AND/OR
func NewBooleanNode ¶
func NewBooleanNode(operator lex.Token, args ...Node) *BooleanNode
NewBooleanNode Create a boolean node
@operator = AND, OR @args = nodes
func (*BooleanNode) ChildrenArgs ¶
func (m *BooleanNode) ChildrenArgs() []Node
func (*BooleanNode) Collapse ¶
func (m *BooleanNode) Collapse() Node
func (*BooleanNode) Equal ¶
func (m *BooleanNode) Equal(n Node) bool
func (*BooleanNode) Expr ¶
func (m *BooleanNode) Expr() *Expr
func (*BooleanNode) FromExpr ¶
func (m *BooleanNode) FromExpr(e *Expr) error
func (*BooleanNode) FromPB ¶
func (m *BooleanNode) FromPB(n *NodePb) Node
func (*BooleanNode) Negated ¶
func (m *BooleanNode) Negated() bool
func (*BooleanNode) NodePb ¶
func (m *BooleanNode) NodePb() *NodePb
func (*BooleanNode) NodeType ¶
func (m *BooleanNode) NodeType() string
func (*BooleanNode) ReverseNegation ¶
func (m *BooleanNode) ReverseNegation() bool
func (*BooleanNode) String ¶
func (m *BooleanNode) String() string
func (*BooleanNode) StringNegate ¶
func (m *BooleanNode) StringNegate() string
func (*BooleanNode) Validate ¶
func (m *BooleanNode) Validate() error
func (*BooleanNode) WriteDialect ¶
func (m *BooleanNode) WriteDialect(w DialectWriter)
func (*BooleanNode) WriteNegate ¶
func (m *BooleanNode) WriteNegate(w DialectWriter)
type BooleanNodePb ¶
type BooleanNodePb 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:"-"` }
Boolean Node, n child args
func (*BooleanNodePb) Descriptor ¶
func (*BooleanNodePb) Descriptor() ([]byte, []int)
func (*BooleanNodePb) Marshal ¶
func (m *BooleanNodePb) Marshal() (data []byte, err error)
func (*BooleanNodePb) ProtoMessage ¶
func (*BooleanNodePb) ProtoMessage()
func (*BooleanNodePb) Reset ¶
func (m *BooleanNodePb) Reset()
func (*BooleanNodePb) Size ¶
func (m *BooleanNodePb) Size() (n int)
func (*BooleanNodePb) String ¶
func (m *BooleanNodePb) String() string
func (*BooleanNodePb) Unmarshal ¶
func (m *BooleanNodePb) Unmarshal(data []byte) error
type ContextReadWriter ¶
type ContextReadWriter interface { ContextReader ContextWriter }
ContextReadWriter represents a Context which can be Read & Written.
type ContextReader ¶
type ContextReader interface { Get(key string) (value.Value, bool) Row() map[string]value.Value Ts() time.Time }
ContextReaderis 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 }
ContextWriter For evaluation storage vm writes results to this after evaluation
type CustomFunc ¶
type CustomFunc interface { // Type Define the Return Type of this function, or use value.Value for unknown. Type() value.ValueType // Validate is parse time syntax and type evaluation. Also returns the evaluation // function. Validate(n *FuncNode) (EvaluatorFunc, error) }
CustomFunc allows custom functions to be added for run-time evaluation
type DialectWriter ¶
type DialectWriter interface { io.Writer Len() int WriteLiteral(string) WriteIdentity(string) WriteIdentityQuote(string, byte) 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 = ` - bigquery: literal-escape = ", identity = []
func NewDefaultWriter ¶
func NewDefaultWriter() DialectWriter
NewDefaultWriter uses mysql escaping rules literals=", identity=`
func NewDialectWriter ¶
func NewDialectWriter(l, i byte) DialectWriter
NewDialectWriter creates a writer that is custom literal and identity escape characters
func NewFingerPrintWriter ¶
func NewFingerPrintWriter(replace string, w DialectWriter) DialectWriter
func NewFingerPrinter ¶
func NewFingerPrinter() DialectWriter
func NewJsonDialectWriter ¶
func NewJsonDialectWriter() DialectWriter
NewJsonDialectWriter escape literal " with \"
func NewKeywordDialect ¶
func NewKeywordDialect(kw []string) DialectWriter
type EvalContext ¶
type EvalContext interface { ContextReader }
EvalContext used to contain info for usage/lookup at runtime evaluation
type EvalIncludeContext ¶
type EvalIncludeContext interface { ContextReader Includer }
EvalIncludeContext context, used to contain info for usage/lookup at runtime evaluation
type EvaluatorFunc ¶
EvaluatorFunc defines the evaluator func which may be stateful (or not) for evaluating custom functions
type Expr ¶
type Expr struct { // The `Op` (aka token), and Args expressions are non // nil if it is an expression Op string `json:"op,omitempty"` Args []*Expr `json:"args,omitempty"` // If op is 0, and args nil then exactly one of these should be set Identity string `json:"ident,omitempty"` Value string `json:"val,omitempty"` }
Expr represents single part of an Expression, it is a generic AST structure that can be built in tree structure and JSON serialized to represent full AST as json.
func ExprsFromNodes ¶
type ExprPb ¶
type ExprPb struct { Op *int32 `protobuf:"varint,1,opt,name=op" json:"op,omitempty"` Args []*ExprPb `protobuf:"bytes,2,rep,name=args" json:"args,omitempty"` Ident *string `protobuf:"bytes,4,opt,name=ident" json:"ident,omitempty"` Val *string `protobuf:"bytes,5,opt,name=val" json:"val,omitempty"` Ival *int64 `protobuf:"varint,6,opt,name=ival" json:"ival,omitempty"` Bval *bool `protobuf:"varint,7,opt,name=bval" json:"bval,omitempty"` Fval *float64 `protobuf:"fixed64,8,opt,name=fval" json:"fval,omitempty"` XXX_unrecognized []byte `json:"-"` }
The generic Expr
func (*ExprPb) Descriptor ¶
func (*ExprPb) ProtoMessage ¶
func (*ExprPb) ProtoMessage()
type Func ¶
type Func struct { Name string // name of func, lower-cased Aggregate bool // is this aggregate func? CustomFunc // CustomFunc Is dynamic function that can be registered Eval EvaluatorFunc // The memoized evaluation function }
Func Describes a function expression which wraps and allows native go functions to be called in expression vm
type FuncNode ¶
type FuncNode struct { Name string // Name of func F Func // The actual function that this AST maps to Eval EvaluatorFunc // the evaluator function 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
func NewFuncNode ¶
NewFuncNode create new Function Expression Node.
func (*FuncNode) ChildrenArgs ¶
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) Descriptor ¶
func (*FuncNodePb) Descriptor() ([]byte, []int)
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
}
FuncRegistry contains lists of functions for different scope/run-time evaluation contexts.
func NewFuncRegistry ¶
func NewFuncRegistry() *FuncRegistry
NewFuncRegistry create a new function registry. By default their is a global one, but you can have local function registries as well.
func (*FuncRegistry) Add ¶
func (m *FuncRegistry) Add(name string, fn CustomFunc)
Add a name/function to registry
type FuncResolver ¶
FuncResolver is a function resolution interface 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) Equal ¶
func (m *IdentityNode) Equal(n Node) bool
func (*IdentityNode) Expr ¶
func (m *IdentityNode) Expr() *Expr
func (*IdentityNode) FromExpr ¶
func (m *IdentityNode) FromExpr(e *Expr) error
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) IdentityPb ¶
func (m *IdentityNode) IdentityPb() *IdentityNodePb
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) NodePb ¶
func (m *IdentityNode) NodePb() *NodePb
func (*IdentityNode) NodeType ¶
func (m *IdentityNode) NodeType() string
func (*IdentityNode) OriginalText ¶
func (m *IdentityNode) OriginalText() string
func (*IdentityNode) String ¶
func (m *IdentityNode) String() string
func (*IdentityNode) Validate ¶
func (m *IdentityNode) Validate() error
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) Descriptor ¶
func (*IdentityNodePb) Descriptor() ([]byte, []int)
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 IdentityNodes ¶
type IdentityNodes []*IdentityNode
IdentityNodes is a list of identities
func (IdentityNodes) LeftStrings ¶
func (m IdentityNodes) LeftStrings() []string
LeftStrings get all Left Identity fields.
func (IdentityNodes) Strings ¶
func (m IdentityNodes) Strings() []string
Strings get all identity strings
type IncludeContext ¶
type IncludeContext struct {
ContextReader
}
IncludeContext A ContextReader that implements Include interface.
func NewIncludeContext ¶
func NewIncludeContext(cr ContextReader) *IncludeContext
NewIncludeContext a new IncludeContext from contextreader.
type IncludeNode ¶
type IncludeNode struct { ExprNode Node // The expression of the referred to include Identity *IdentityNode Operator lex.Token // contains filtered or unexported fields }
IncludeNode references a named node
( ! INCLUDE <identity> | INCLUDE <identity> | NOT INCLUDE <identity> )
func NewInclude ¶
func NewInclude(operator lex.Token, id *IdentityNode) *IncludeNode
Include nodes
NOT INCLUDE <identity> ! INCLUDE <identity> INCLUDE <identity>
func (*IncludeNode) Collapse ¶
func (m *IncludeNode) Collapse() Node
func (*IncludeNode) Equal ¶
func (m *IncludeNode) Equal(n Node) bool
func (*IncludeNode) Expr ¶
func (m *IncludeNode) Expr() *Expr
func (*IncludeNode) FromExpr ¶
func (m *IncludeNode) FromExpr(e *Expr) error
func (*IncludeNode) FromPB ¶
func (m *IncludeNode) FromPB(n *NodePb) Node
func (*IncludeNode) Negated ¶
func (m *IncludeNode) Negated() bool
func (*IncludeNode) NodePb ¶
func (m *IncludeNode) NodePb() *NodePb
func (*IncludeNode) NodeType ¶
func (m *IncludeNode) NodeType() string
func (*IncludeNode) ReverseNegation ¶
func (m *IncludeNode) ReverseNegation() bool
func (*IncludeNode) String ¶
func (m *IncludeNode) String() string
func (*IncludeNode) StringNegate ¶
func (m *IncludeNode) StringNegate() string
func (*IncludeNode) Validate ¶
func (m *IncludeNode) Validate() error
func (*IncludeNode) WriteDialect ¶
func (m *IncludeNode) WriteDialect(w DialectWriter)
func (*IncludeNode) WriteNegate ¶
func (m *IncludeNode) WriteNegate(w DialectWriter)
type IncludeNodePb ¶
type IncludeNodePb struct { Op int32 `protobuf:"varint,1,req,name=op" json:"op"` Negated bool `protobuf:"varint,2,req,name=negated" json:"negated"` Identity IdentityNodePb `protobuf:"bytes,3,req,name=identity" json:"identity"` XXX_unrecognized []byte `json:"-"` }
Include Node, two child args
func (*IncludeNodePb) Descriptor ¶
func (*IncludeNodePb) Descriptor() ([]byte, []int)
func (*IncludeNodePb) Marshal ¶
func (m *IncludeNodePb) Marshal() (data []byte, err error)
func (*IncludeNodePb) ProtoMessage ¶
func (*IncludeNodePb) ProtoMessage()
func (*IncludeNodePb) Reset ¶
func (m *IncludeNodePb) Reset()
func (*IncludeNodePb) Size ¶
func (m *IncludeNodePb) Size() (n int)
func (*IncludeNodePb) String ¶
func (m *IncludeNodePb) String() string
func (*IncludeNodePb) Unmarshal ¶
func (m *IncludeNodePb) Unmarshal(data []byte) error
type Includer ¶
Includer defines an interface used for resolving INCLUDE clauses into a Indclude reference. Implementations should return an error if the name cannot be resolved.
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) ErrMsg ¶
func (m *LexTokenPager) ErrMsg(msg string) error
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 { // Node the negateable nodes also implement the entire Node Node // Negated Say if this node is negateable (it may not be), If the node // is negateable, we may collapse an surrounding negation into here Negated() bool // ReverseNegation if Possible: for instance: // "A" NOT IN ("a","b") => "A" IN ("a","b") ReverseNegation() bool // StringNegate StringNegate() string // WriteNegate write out this node into a writer WriteNegate(w DialectWriter) // Collapse Negateable nodes may be collapsed logically into new nodes // return this node collapsed down to simpliest form Collapse() Node }
NegateableNode 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 // WriteDialect Given a dialect writer write out, equivalent of String() // but allows different escape characters WriteDialect(w DialectWriter) // Validate Syntax validation of this expression node Validate() error // NodePb Convert this node to a Protobuf copy of it NodePb() *NodePb // FromPB Convert a protobuf presentation of node to Node. FromPB(*NodePb) Node // Expr Convert node into a simple expression syntax // which can be used for json respresentation Expr() *Expr // FromExpr FromExpr(*Expr) error // Equal compares deep equality of Equal(Node) bool // NodeType the String, Identity, etc NodeType() string }
Node is a node in an 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 InlineIncludes ¶
InlineIncludes take an expression and resolve any includes so that the included expression is "Inline"
func MustParse ¶
MustParse parse a single Expression, returning an Expression Node and panics if it cannot be parsed
MustParse("5 * toint(item_name)")
func NewUnary ¶
Unary nodes
NOT <expression> ! <expression> EXISTS <identity> <identity> IS NOT NULL
func NodeFromExpr ¶
func NodesFromExprs ¶
func NodesFromNodesPb ¶
func NodesFromNodesPbPtr ¶
func ParseExprWithFuncs ¶
func ParseExprWithFuncs(p TokenPager, fr FuncResolver) (Node, error)
Parse a single Expression, returning an Expression Node
@fr = function registry with any additional functions
ParseExprWithFuncs("5 * toint(item_name)", funcRegistry)
func ParseExpression ¶
ParseExpression parse a single Expression, returning an Expression Node
ParseExpression("5 * toint(item_name)")
func ParsePager ¶
func ParsePager(pager TokenPager) (Node, error)
Parse a single Expression, returning an Expression Node
@pager = Token Pager
type NodeArgs ¶
type NodeArgs interface {
ChildrenArgs() []Node
}
NodeArgs is an interface for nodes which have child arguments
type NodePb ¶
type NodePb struct { Bn *BinaryNodePb `protobuf:"bytes,1,opt,name=bn" json:"bn,omitempty"` Booln *BooleanNodePb `protobuf:"bytes,2,opt,name=booln" json:"booln,omitempty"` Un *UnaryNodePb `protobuf:"bytes,3,opt,name=un" json:"un,omitempty"` Fn *FuncNodePb `protobuf:"bytes,4,opt,name=fn" json:"fn,omitempty"` Tn *TriNodePb `protobuf:"bytes,5,opt,name=tn" json:"tn,omitempty"` An *ArrayNodePb `protobuf:"bytes,6,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"` Incn *IncludeNodePb `protobuf:"bytes,14,opt,name=incn" json:"incn,omitempty"` Niln *NullNodePb `protobuf:"bytes,15,opt,name=niln" json:"niln,omitempty"` XXX_unrecognized []byte `json:"-"` }
The generic Node, must be exactly one of these types
func NodesPbFromNodes ¶
func (*NodePb) Descriptor ¶
func (*NodePb) ProtoMessage ¶
func (*NodePb) ProtoMessage()
type NullNode ¶
type NullNode struct{}
NullNode is a simple NULL type node
func (*NullNode) WriteDialect ¶
func (m *NullNode) WriteDialect(w DialectWriter)
type NullNodePb ¶
type NullNodePb struct { Niltype int32 `protobuf:"varint,1,opt,name=niltype" json:"niltype"` XXX_unrecognized []byte `json:"-"` }
NullNode
func (*NullNodePb) Descriptor ¶
func (*NullNodePb) Descriptor() ([]byte, []int)
func (*NullNodePb) Marshal ¶
func (m *NullNodePb) Marshal() (data []byte, err error)
func (*NullNodePb) ProtoMessage ¶
func (*NullNodePb) ProtoMessage()
func (*NullNodePb) Reset ¶
func (m *NullNodePb) Reset()
func (*NullNodePb) Size ¶
func (m *NullNodePb) Size() (n int)
func (*NullNodePb) String ¶
func (m *NullNodePb) String() string
func (*NullNodePb) Unmarshal ¶
func (m *NullNodePb) Unmarshal(data []byte) error
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) Equal ¶
func (m *NumberNode) Equal(n Node) bool
func (*NumberNode) Expr ¶
func (m *NumberNode) Expr() *Expr
func (*NumberNode) FromExpr ¶
func (m *NumberNode) FromExpr(e *Expr) error
func (*NumberNode) FromPB ¶
func (m *NumberNode) FromPB(n *NodePb) Node
func (*NumberNode) NodePb ¶
func (m *NumberNode) NodePb() *NodePb
func (*NumberNode) NodeType ¶
func (m *NumberNode) NodeType() string
func (*NumberNode) String ¶
func (n *NumberNode) String() string
func (*NumberNode) Validate ¶
func (m *NumberNode) Validate() error
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) Descriptor ¶
func (*NumberNodePb) Descriptor() ([]byte, []int)
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 the given rowInfo to persist Commit(rowInfo []SchemaInfo, row RowWriter) error // Put (persist) given Column info write single column. Put(col SchemaInfo, readCtx ContextReader, v value.Value) error }
RowWriter for committing 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 NewStringNeedsEscape ¶
func NewStringNeedsEscape(t lex.Token) *StringNode
func NewStringNoQuoteNode ¶
func NewStringNoQuoteNode(text string) *StringNode
func NewStringNode ¶
func NewStringNode(text string) *StringNode
func NewStringNodeToken ¶
func NewStringNodeToken(t lex.Token) *StringNode
func (*StringNode) Equal ¶
func (m *StringNode) Equal(n Node) bool
func (*StringNode) Expr ¶
func (m *StringNode) Expr() *Expr
func (*StringNode) FromExpr ¶
func (m *StringNode) FromExpr(e *Expr) error
func (*StringNode) FromPB ¶
func (m *StringNode) FromPB(n *NodePb) Node
func (*StringNode) NodePb ¶
func (m *StringNode) NodePb() *NodePb
func (*StringNode) NodeType ¶
func (m *StringNode) NodeType() string
func (*StringNode) String ¶
func (m *StringNode) String() string
func (*StringNode) Validate ¶
func (m *StringNode) Validate() error
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) Descriptor ¶
func (*StringNodePb) Descriptor() ([]byte, []int)
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 ErrMsg(msg string) error }
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 TriNode ¶
TriNode
ARG1 Between ARG2 AND ARG3
func (*TriNode) ChildrenArgs ¶
func (*TriNode) ReverseNegation ¶
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) Descriptor ¶
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) ChildrenArgs ¶
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) Descriptor ¶
func (*UnaryNodePb) Descriptor() ([]byte, []int)
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 ¶
ValueNode 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) Descriptor ¶
func (*ValueNodePb) Descriptor() ([]byte, []int)
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
Source Files ¶
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. |