Documentation
¶
Index ¶
- func BuiltinFunctions() map[string]func(args ...Expr) (Expr, error)
- func Equal(a, b Expr) bool
- func IsAndOperator(op Operator) bool
- func IsArithmeticOperator(op Operator) bool
- func IsComparisonOperator(op Operator) bool
- func IsInOperator(e Expr) bool
- func IsOrOperator(e Expr) bool
- type AndOp
- func (op *AndOp) Eval(env *Environment) (document.Value, error)
- func (op AndOp) IsEqual(other Expr) bool
- func (op AndOp) LeftHand() Expr
- func (op AndOp) Precedence() int
- func (op AndOp) RightHand() Expr
- func (op AndOp) SetLeftHandExpr(a Expr)
- func (op AndOp) SetRightHandExpr(b Expr)
- func (op *AndOp) String() string
- func (op AndOp) Token() scanner.Token
- type AvgAggregator
- type AvgFunc
- type CastFunc
- type CountAggregator
- type CountFunc
- type Environment
- func (e *Environment) Clone() (*Environment, error)
- func (e *Environment) Get(path document.Path) (v document.Value, ok bool)
- func (e *Environment) GetDocument() (document.Document, bool)
- func (e *Environment) GetParamByIndex(pos int) (document.Value, error)
- func (e *Environment) GetParamByName(name string) (v document.Value, err error)
- func (e *Environment) Set(name string, v document.Value)
- func (e *Environment) SetDocument(d document.Document)
- type Expr
- func Add(a, b Expr) Expr
- func And(a, b Expr) Expr
- func BitwiseAnd(a, b Expr) Expr
- func BitwiseOr(a, b Expr) Expr
- func BitwiseXor(a, b Expr) Expr
- func Div(a, b Expr) Expr
- func Eq(a, b Expr) Expr
- func Gt(a, b Expr) Expr
- func Gte(a, b Expr) Expr
- func In(a, b Expr) Expr
- func Is(a, b Expr) Expr
- func IsNot(a, b Expr) Expr
- func Like(a, b Expr) Expr
- func Lt(a, b Expr) Expr
- func Lte(a, b Expr) Expr
- func Mod(a, b Expr) Expr
- func Mul(a, b Expr) Expr
- func Neq(a, b Expr) Expr
- func NotIn(a, b Expr) Expr
- func NotLike(a, b Expr) Expr
- func Or(a, b Expr) Expr
- func Sub(a, b Expr) Expr
- type Functions
- type KVPair
- type KVPairs
- type LiteralExprList
- type LiteralValue
- func ArrayValue(a document.Array) LiteralValue
- func BlobValue(v []byte) LiteralValue
- func BoolValue(v bool) LiteralValue
- func DocumentValue(d document.Document) LiteralValue
- func DoubleValue(v float64) LiteralValue
- func IntegerValue(v int64) LiteralValue
- func NullValue() LiteralValue
- func TextValue(v string) LiteralValue
- type MaxAggregator
- type MaxFunc
- type MinAggregator
- type MinFunc
- type NamedParam
- type Operator
- type OrOp
- func (op *OrOp) Eval(env *Environment) (document.Value, error)
- func (op OrOp) IsEqual(other Expr) bool
- func (op OrOp) LeftHand() Expr
- func (op OrOp) Precedence() int
- func (op OrOp) RightHand() Expr
- func (op OrOp) SetLeftHandExpr(a Expr)
- func (op OrOp) SetRightHandExpr(b Expr)
- func (op *OrOp) String() string
- func (op OrOp) Token() scanner.Token
- type PKFunc
- type Param
- type Parentheses
- type Path
- type PositionalParam
- type SumAggregator
- type SumFunc
- type Wildcard
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuiltinFunctions ¶ added in v0.9.0
BuiltinFunctions returns default map of builtin functions.
func Equal ¶
Equal reports whether a and b are equal by first calling IsEqual if they have an IsEqual method with this signature:
IsEqual(Expr) bool
If not, it returns whether a and b values are equal.
func IsAndOperator ¶
IsAndOperator reports if e is the AND operator.
func IsArithmeticOperator ¶
IsArithmeticOperator returns true if e is one of +, -, *, /, %, &, |, or ^ operators.
func IsComparisonOperator ¶
IsComparisonOperator returns true if e is one of =, !=, >, >=, <, <=, IS, IS NOT, IN, or NOT IN operators.
Types ¶
type AndOp ¶
type AndOp struct {
// contains filtered or unexported fields
}
AndOp is the And operator.
func (*AndOp) Eval ¶
func (op *AndOp) Eval(env *Environment) (document.Value, error)
Eval implements the Expr interface. It evaluates a and b and returns true if both evaluate to true.
func (AndOp) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (AndOp) Precedence ¶
func (op AndOp) Precedence() int
func (AndOp) SetLeftHandExpr ¶
func (op AndOp) SetLeftHandExpr(a Expr)
func (AndOp) SetRightHandExpr ¶
func (op AndOp) SetRightHandExpr(b Expr)
type AvgAggregator ¶ added in v0.9.0
AvgAggregator is an aggregator that returns the average non-null value.
func (*AvgAggregator) Add ¶ added in v0.9.0
func (s *AvgAggregator) Add(d document.Document) error
Add stores the average value of all non-NULL numeric values in the group.
func (*AvgAggregator) Aggregate ¶ added in v0.9.0
func (s *AvgAggregator) Aggregate(fb *document.FieldBuffer) error
Aggregate adds a field to the given buffer with the maximum value.
type AvgFunc ¶ added in v0.9.0
AvgFunc is the AVG aggregator function.
func (*AvgFunc) Aggregator ¶ added in v0.10.0
func (s *AvgFunc) Aggregator(group document.Value) document.Aggregator
Aggregator implements the planner.AggregatorBuilder interface.
func (*AvgFunc) Eval ¶ added in v0.9.0
func (s *AvgFunc) Eval(env *Environment) (document.Value, error)
Eval extracts the average value from the given document and returns it.
func (*AvgFunc) IsEqual ¶ added in v0.9.0
IsEqual compares this expression with the other expression and returns true if they are equal.
type CastFunc ¶ added in v0.8.0
CastFunc represents the CAST expression.
func (CastFunc) Eval ¶ added in v0.8.0
func (c CastFunc) Eval(env *Environment) (document.Value, error)
Eval returns the primary key of the current document.
type CountAggregator ¶ added in v0.8.0
CountAggregator is an aggregator that counts non-null expressions.
func (*CountAggregator) Add ¶ added in v0.8.0
func (c *CountAggregator) Add(d document.Document) error
Add increments the counter if the count expression evaluates to a non-null value.
func (*CountAggregator) Aggregate ¶ added in v0.8.0
func (c *CountAggregator) Aggregate(fb *document.FieldBuffer) error
Aggregate adds a field to the given buffer with the value of the counter.
type CountFunc ¶ added in v0.8.0
CountFunc is the COUNT aggregator function. It aggregates documents
func (*CountFunc) Aggregator ¶ added in v0.10.0
func (c *CountFunc) Aggregator(group document.Value) document.Aggregator
func (*CountFunc) Eval ¶ added in v0.8.0
func (c *CountFunc) Eval(env *Environment) (document.Value, error)
type Environment ¶ added in v0.10.0
type Environment struct { Params []Param Vars *document.FieldBuffer Doc document.Document Outer *Environment }
Environment contains information about the context in which the expression is evaluated.
func NewEnvironment ¶ added in v0.10.0
func NewEnvironment(d document.Document, params ...Param) *Environment
func (*Environment) Clone ¶ added in v0.10.0
func (e *Environment) Clone() (*Environment, error)
func (*Environment) GetDocument ¶ added in v0.10.0
func (e *Environment) GetDocument() (document.Document, bool)
func (*Environment) GetParamByIndex ¶ added in v0.10.0
func (e *Environment) GetParamByIndex(pos int) (document.Value, error)
func (*Environment) GetParamByName ¶ added in v0.10.0
func (e *Environment) GetParamByName(name string) (v document.Value, err error)
func (*Environment) SetDocument ¶ added in v0.10.0
func (e *Environment) SetDocument(d document.Document)
type Expr ¶
type Expr interface {
Eval(*Environment) (document.Value, error)
}
An Expr evaluates to a value.
func BitwiseAnd ¶
BitwiseAnd creates an expression thats evaluates to the result of a & b.
func BitwiseXor ¶
BitwiseXor creates an expression thats evaluates to the result of a ^ b.
func NotLike ¶ added in v0.9.0
NotLike creates an expression that evaluates to the result of a NOT LIKE b.
type Functions ¶ added in v0.9.0
type Functions struct {
// contains filtered or unexported fields
}
Functions represents a map of builtin SQL functions.
func NewFunctions ¶ added in v0.9.0
func NewFunctions() Functions
type KVPairs ¶
type KVPairs []KVPair
KVPairs is a list of KVPair.
func (KVPairs) Eval ¶
func (kvp KVPairs) Eval(env *Environment) (document.Value, error)
Eval turns a list of KVPairs into a document.
type LiteralExprList ¶
type LiteralExprList []Expr
LiteralExprList is a list of expressions.
func (LiteralExprList) Eval ¶
func (l LiteralExprList) Eval(env *Environment) (document.Value, error)
Eval evaluates all the expressions and returns a litteralValueList. It implements the Expr interface.
func (LiteralExprList) IsEqual ¶
func (l LiteralExprList) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (LiteralExprList) String ¶
func (l LiteralExprList) String() string
String implements the fmt.Stringer interface.
type LiteralValue ¶
A LiteralValue represents a litteral value of any type defined by the value package.
func ArrayValue ¶
func ArrayValue(a document.Array) LiteralValue
ArrayValue creates a litteral value of type Array.
func BlobValue ¶
func BlobValue(v []byte) LiteralValue
BlobValue creates a litteral value of type Blob.
func BoolValue ¶
func BoolValue(v bool) LiteralValue
BoolValue creates a litteral value of type Bool.
func DocumentValue ¶
func DocumentValue(d document.Document) LiteralValue
DocumentValue creates a litteral value of type Document.
func DoubleValue ¶ added in v0.7.0
func DoubleValue(v float64) LiteralValue
DoubleValue creates a litteral value of type Double.
func IntegerValue ¶ added in v0.7.0
func IntegerValue(v int64) LiteralValue
IntegerValue creates a litteral value of type Integer.
func TextValue ¶
func TextValue(v string) LiteralValue
TextValue creates a litteral value of type Text.
func (LiteralValue) Eval ¶
func (v LiteralValue) Eval(*Environment) (document.Value, error)
Eval returns l. It implements the Expr interface.
func (LiteralValue) IsEqual ¶
func (v LiteralValue) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (LiteralValue) String ¶
func (v LiteralValue) String() string
String implements the fmt.Stringer interface.
type MaxAggregator ¶ added in v0.8.0
MaxAggregator is an aggregator that returns the minimum non-null value.
func (*MaxAggregator) Add ¶ added in v0.8.0
func (m *MaxAggregator) Add(d document.Document) error
Add stores the maximum value. Values are compared based on their types, then if the type is equal their value is compared. Numbers are considered of the same type.
func (*MaxAggregator) Aggregate ¶ added in v0.8.0
func (m *MaxAggregator) Aggregate(fb *document.FieldBuffer) error
Aggregate adds a field to the given buffer with the maximum value.
type MaxFunc ¶ added in v0.8.0
MaxFunc is the MAX aggregator function.
func (*MaxFunc) Aggregator ¶ added in v0.10.0
func (m *MaxFunc) Aggregator(group document.Value) document.Aggregator
Aggregator implements the planner.AggregatorBuilder interface.
func (*MaxFunc) Eval ¶ added in v0.8.0
func (m *MaxFunc) Eval(env *Environment) (document.Value, error)
Eval extracts the max value from the given document and returns it.
func (*MaxFunc) IsEqual ¶ added in v0.8.0
IsEqual compares this expression with the other expression and returns true if they are equal.
type MinAggregator ¶ added in v0.8.0
MinAggregator is an aggregator that returns the minimum non-null value.
func (*MinAggregator) Add ¶ added in v0.8.0
func (m *MinAggregator) Add(d document.Document) error
Add stores the minimum value. Values are compared based on their types, then if the type is equal their value is compared. Numbers are considered of the same type.
func (*MinAggregator) Aggregate ¶ added in v0.8.0
func (m *MinAggregator) Aggregate(fb *document.FieldBuffer) error
Aggregate adds a field to the given buffer with the minimum value.
type MinFunc ¶ added in v0.8.0
MinFunc is the MIN aggregator function.
func (*MinFunc) Aggregator ¶ added in v0.10.0
func (m *MinFunc) Aggregator(group document.Value) document.Aggregator
Aggregator implements the planner.AggregatorBuilder interface.
func (*MinFunc) Eval ¶ added in v0.8.0
func (m *MinFunc) Eval(env *Environment) (document.Value, error)
Eval extracts the min value from the given document and returns it.
func (*MinFunc) IsEqual ¶ added in v0.8.0
IsEqual compares this expression with the other expression and returns true if they are equal.
type NamedParam ¶
type NamedParam string
NamedParam is an expression which represents the name of a parameter.
func (NamedParam) Eval ¶
func (p NamedParam) Eval(env *Environment) (document.Value, error)
Eval looks up for the parameters in the env for the one that has the same name as p and returns the value.
func (NamedParam) IsEqual ¶
func (p NamedParam) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (NamedParam) String ¶
func (p NamedParam) String() string
String implements the fmt.Stringer interface.
type Operator ¶
type Operator interface { Expr Precedence() int LeftHand() Expr RightHand() Expr SetLeftHandExpr(Expr) SetRightHandExpr(Expr) Token() scanner.Token }
An Operator is a binary expression that takes two operands and executes an operation on them.
type OrOp ¶
type OrOp struct {
// contains filtered or unexported fields
}
OrOp is the And operator.
func (*OrOp) Eval ¶
func (op *OrOp) Eval(env *Environment) (document.Value, error)
Eval implements the Expr interface. It evaluates a and b and returns true if a or b evalutate to true.
func (OrOp) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (OrOp) Precedence ¶
func (op OrOp) Precedence() int
func (OrOp) SetLeftHandExpr ¶
func (op OrOp) SetLeftHandExpr(a Expr)
func (OrOp) SetRightHandExpr ¶
func (op OrOp) SetRightHandExpr(b Expr)
type PKFunc ¶
type PKFunc struct{}
PKFunc represents the pk() function. It returns the primary key of the current document.
func (PKFunc) Eval ¶
func (k PKFunc) Eval(env *Environment) (document.Value, error)
Eval returns the primary key of the current document.
type Param ¶
type Param struct { // Name of the param Name string // Value is the parameter value. Value interface{} }
A Param represents a parameter passed by the user to the statement.
type Parentheses ¶ added in v0.7.0
type Parentheses struct {
E Expr
}
Parentheses is a special expression which turns any sub-expression as unary. It hides the underlying operator, if any, from the parser so that it doesn't get reordered by precedence.
func (Parentheses) Eval ¶ added in v0.7.0
func (p Parentheses) Eval(env *Environment) (document.Value, error)
Eval calls the underlying expression Eval method.
func (Parentheses) IsEqual ¶ added in v0.10.0
func (p Parentheses) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
type Path ¶ added in v0.9.0
A Path is an expression that extracts a value from a document at a given path.
func (Path) Eval ¶ added in v0.9.0
func (p Path) Eval(env *Environment) (document.Value, error)
Eval extracts the current value from the environment and returns the value stored at p. It implements the Expr interface.
type PositionalParam ¶
type PositionalParam int
PositionalParam is an expression which represents the position of a parameter.
func (PositionalParam) Eval ¶
func (p PositionalParam) Eval(env *Environment) (document.Value, error)
Eval looks up for the parameters in the env for the one that is has the same position as p and returns the value.
func (PositionalParam) IsEqual ¶
func (p PositionalParam) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (PositionalParam) String ¶
func (p PositionalParam) String() string
String implements the fmt.Stringer interface.
type SumAggregator ¶ added in v0.8.0
SumAggregator is an aggregator that returns the minimum non-null value.
func (*SumAggregator) Add ¶ added in v0.8.0
func (s *SumAggregator) Add(d document.Document) error
Add stores the sum of all non-NULL numeric values in the group. The result is an integer value if all summed values are integers. If any of the value is a double, the returned result will be a double.
func (*SumAggregator) Aggregate ¶ added in v0.8.0
func (s *SumAggregator) Aggregate(fb *document.FieldBuffer) error
Aggregate adds a field to the given buffer with the maximum value.
type SumFunc ¶ added in v0.8.0
SumFunc is the SUM aggregator function.
func (*SumFunc) Aggregator ¶ added in v0.10.0
func (s *SumFunc) Aggregator(group document.Value) document.Aggregator
Aggregator implements the planner.AggregatorBuilder interface.
func (*SumFunc) Eval ¶ added in v0.8.0
func (s *SumFunc) Eval(env *Environment) (document.Value, error)
Eval extracts the sum value from the given document and returns it.
func (*SumFunc) IsEqual ¶ added in v0.8.0
IsEqual compares this expression with the other expression and returns true if they are equal.