expr

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Between

func Between(a Expr) func(x, b Expr) Expr

Between returns a function that creates a BETWEEN operator that returns true if x is between a and b.

func BuiltinFunctions

func BuiltinFunctions() map[string]func(args ...Expr) (Expr, error)

BuiltinFunctions returns default map of builtin functions.

func Equal

func Equal(a, b Expr) bool

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 IsArithmeticOperator

func IsArithmeticOperator(op Operator) bool

IsArithmeticOperator returns true if e is one of +, -, *, /, %, &, |, or ^ operators.

func IsComparisonOperator

func IsComparisonOperator(op Operator) bool

IsComparisonOperator returns true if e is one of =, !=, >, >=, <, <=, IS, IS NOT, IN, or NOT IN operators.

func OperatorIsIndexCompatible

func OperatorIsIndexCompatible(op Operator) bool

OperatorIsIndexCompatible returns whether the operator can be used to read from an index.

func Walk

func Walk(e Expr, fn func(Expr) bool) bool

Types

type Aggregator

type Aggregator interface {
	Expr

	Aggregate(env *Environment) error
}

A Aggregator is an expression that aggregates documents into one result.

type AggregatorBuilder

type AggregatorBuilder interface {
	Aggregator() Aggregator
}

An AggregatorBuilder is a type that can create aggregators.

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

func (op AndOp) IsEqual(other Expr) bool

Equal compares this expression with the other expression and returns true if they are equal.

func (AndOp) LeftHand

func (op AndOp) LeftHand() Expr

func (AndOp) Precedence

func (op AndOp) Precedence() int

func (AndOp) RightHand

func (op AndOp) RightHand() Expr

func (AndOp) SetLeftHandExpr

func (op AndOp) SetLeftHandExpr(a Expr)

func (AndOp) SetRightHandExpr

func (op AndOp) SetRightHandExpr(b Expr)

func (AndOp) String

func (op AndOp) String() string

func (AndOp) Token

func (op AndOp) Token() scanner.Token

type AvgAggregator

type AvgAggregator struct {
	Fn      *AvgFunc
	Avg     float64
	Counter int64
}

AvgAggregator is an aggregator that returns the average non-null value.

func (*AvgAggregator) Aggregate

func (s *AvgAggregator) Aggregate(env *Environment) error

Aggregate stores the average value of all non-NULL numeric values in the group.

func (*AvgAggregator) Eval

func (s *AvgAggregator) Eval(env *Environment) (document.Value, error)

Eval returns the aggregated average as a double.

func (*AvgAggregator) String

func (s *AvgAggregator) String() string

type AvgFunc

type AvgFunc struct {
	Expr Expr
}

AvgFunc is the AVG aggregator function.

func (*AvgFunc) Aggregator

func (s *AvgFunc) Aggregator() Aggregator

Aggregator returns a AvgFunc. It implements the AggregatorBuilder interface.

func (*AvgFunc) Eval

func (s *AvgFunc) Eval(env *Environment) (document.Value, error)

Eval extracts the average value from the given document and returns it.

func (*AvgFunc) IsEqual

func (s *AvgFunc) IsEqual(other Expr) bool

IsEqual compares this expression with the other expression and returns true if they are equal.

func (*AvgFunc) Params

func (s *AvgFunc) Params() []Expr

func (*AvgFunc) String

func (s *AvgFunc) String() string

String returns the alias if non-zero, otherwise it returns a string representation of the average expression.

type BetweenOperator

type BetweenOperator struct {
	X Expr
	// contains filtered or unexported fields
}

func (*BetweenOperator) Eval

func (op *BetweenOperator) Eval(env *Environment) (document.Value, error)

func (BetweenOperator) IsEqual

func (op BetweenOperator) IsEqual(other Expr) bool

Equal compares this expression with the other expression and returns true if they are equal.

func (BetweenOperator) LeftHand

func (op BetweenOperator) LeftHand() Expr

func (BetweenOperator) Precedence

func (op BetweenOperator) Precedence() int

func (BetweenOperator) RightHand

func (op BetweenOperator) RightHand() Expr

func (BetweenOperator) SetLeftHandExpr

func (op BetweenOperator) SetLeftHandExpr(a Expr)

func (BetweenOperator) SetRightHandExpr

func (op BetweenOperator) SetRightHandExpr(b Expr)

func (*BetweenOperator) String

func (op *BetweenOperator) String() string

func (BetweenOperator) Token

func (op BetweenOperator) Token() scanner.Token

type CastFunc

type CastFunc struct {
	Expr   Expr
	CastAs document.ValueType
}

CastFunc represents the CAST expression.

func (CastFunc) Eval

func (c CastFunc) Eval(env *Environment) (document.Value, error)

Eval returns the primary key of the current document.

func (CastFunc) IsEqual

func (c CastFunc) IsEqual(other Expr) bool

IsEqual compares this expression with the other expression and returns true if they are equal.

func (CastFunc) Params

func (c CastFunc) Params() []Expr

func (CastFunc) String

func (c CastFunc) String() string

type ConcatOperator

type ConcatOperator struct {
	// contains filtered or unexported fields
}

func (*ConcatOperator) Eval

func (op *ConcatOperator) Eval(env *Environment) (document.Value, error)

func (ConcatOperator) IsEqual

func (op ConcatOperator) IsEqual(other Expr) bool

Equal compares this expression with the other expression and returns true if they are equal.

func (ConcatOperator) LeftHand

func (op ConcatOperator) LeftHand() Expr

func (ConcatOperator) Precedence

func (op ConcatOperator) Precedence() int

func (ConcatOperator) RightHand

func (op ConcatOperator) RightHand() Expr

func (ConcatOperator) SetLeftHandExpr

func (op ConcatOperator) SetLeftHandExpr(a Expr)

func (ConcatOperator) SetRightHandExpr

func (op ConcatOperator) SetRightHandExpr(b Expr)

func (ConcatOperator) String

func (op ConcatOperator) String() string

func (ConcatOperator) Token

func (op ConcatOperator) Token() scanner.Token

type CountAggregator

type CountAggregator struct {
	Fn    *CountFunc
	Count int64
}

CountAggregator is an aggregator that counts non-null expressions.

func (*CountAggregator) Aggregate

func (c *CountAggregator) Aggregate(env *Environment) error

Aggregate increments the counter if the count expression evaluates to a non-null value.

func (*CountAggregator) Eval

func (c *CountAggregator) Eval(env *Environment) (document.Value, error)

Eval returns the result of the aggregation as an integer.

func (*CountAggregator) String

func (c *CountAggregator) String() string

type CountFunc

type CountFunc struct {
	Expr     Expr
	Wildcard bool
	Count    int64
}

CountFunc is the COUNT aggregator function. It counts the number of documents in a stream.

func (*CountFunc) Aggregator

func (c *CountFunc) Aggregator() Aggregator

Aggregator returns a CountAggregator. It implements the AggregatorBuilder interface.

func (*CountFunc) Eval

func (c *CountFunc) Eval(env *Environment) (document.Value, error)

func (*CountFunc) IsEqual

func (c *CountFunc) IsEqual(other Expr) bool

IsEqual compares this expression with the other expression and returns true if they are equal.

func (*CountFunc) Params

func (c *CountFunc) Params() []Expr

func (*CountFunc) String

func (c *CountFunc) String() string

type Environment

type Environment struct {
	Params []Param
	Vars   *document.FieldBuffer
	Doc    document.Document
	Tx     *database.Transaction

	Outer *Environment
}

Environment contains information about the context in which the expression is evaluated.

func NewEnvironment

func NewEnvironment(d document.Document, params ...Param) *Environment

func (*Environment) Clone

func (e *Environment) Clone() (*Environment, error)

func (*Environment) Get

func (e *Environment) Get(path document.Path) (v document.Value, ok bool)

func (*Environment) GetDocument

func (e *Environment) GetDocument() (document.Document, bool)

func (*Environment) GetParamByIndex

func (e *Environment) GetParamByIndex(pos int) (document.Value, error)

func (*Environment) GetParamByName

func (e *Environment) GetParamByName(name string) (v document.Value, err error)

func (*Environment) GetTx

func (e *Environment) GetTx() *database.Transaction

func (*Environment) Set

func (e *Environment) Set(name string, v document.Value)

func (*Environment) SetDocument

func (e *Environment) SetDocument(d document.Document)

type Expr

type Expr interface {
	Eval(*Environment) (document.Value, error)
	String() string
}

An Expr evaluates to a value.

func Add

func Add(a, b Expr) Expr

Add creates an expression thats evaluates to the result of a + b.

func And

func And(a, b Expr) Expr

And creates an expression that evaluates a And b And returns true if both are truthy.

func BitwiseAnd

func BitwiseAnd(a, b Expr) Expr

BitwiseAnd creates an expression thats evaluates to the result of a & b.

func BitwiseOr

func BitwiseOr(a, b Expr) Expr

BitwiseOr creates an expression thats evaluates to the result of a | b.

func BitwiseXor

func BitwiseXor(a, b Expr) Expr

BitwiseXor creates an expression thats evaluates to the result of a ^ b.

func Concat

func Concat(a, b Expr) Expr

Concat creates an expression that concatenates two text values together. It returns null if one of the values is not a text.

func Div

func Div(a, b Expr) Expr

Div creates an expression thats evaluates to the result of a / b.

func Eq

func Eq(a, b Expr) Expr

Eq creates an expression that returns true if a equals b.

func Gt

func Gt(a, b Expr) Expr

Gt creates an expression that returns true if a is greater than b.

func Gte

func Gte(a, b Expr) Expr

Gte creates an expression that returns true if a is greater than or equal to b.

func In

func In(a, b Expr) Expr

In creates an expression that evaluates to the result of a IN b.

func Is

func Is(a, b Expr) Expr

Is creates an expression that evaluates to the result of a IS b.

func IsNot

func IsNot(a, b Expr) Expr

IsNot creates an expression that evaluates to the result of a IS NOT b.

func Like

func Like(a, b Expr) Expr

Like creates an expression that evaluates to the result of a LIKE b.

func Lt

func Lt(a, b Expr) Expr

Lt creates an expression that returns true if a is lesser than b.

func Lte

func Lte(a, b Expr) Expr

Lte creates an expression that returns true if a is lesser than or equal to b.

func Mod

func Mod(a, b Expr) Expr

Mod creates an expression thats evaluates to the result of a % b.

func Mul

func Mul(a, b Expr) Expr

Mul creates an expression thats evaluates to the result of a * b.

func Neq

func Neq(a, b Expr) Expr

Neq creates an expression that returns true if a equals b.

func Not

func Not(e Expr) Expr

Not creates an expression that returns true if e is falsy.

func NotIn

func NotIn(a, b Expr) Expr

NotIn creates an expression that evaluates to the result of a NOT IN b.

func NotLike

func NotLike(a, b Expr) Expr

NotLike creates an expression that evaluates to the result of a NOT LIKE b.

func Or

func Or(a, b Expr) Expr

Or creates an expression that first evaluates a, returns true if truthy, then evaluates b, returns true if truthy Or false if falsy.

func Sub

func Sub(a, b Expr) Expr

Sub creates an expression thats evaluates to the result of a - b.

type Function

type Function interface {
	Expr

	// Returns the list of parameters this function has received.
	Params() []Expr
}

A Function is an expression that execute some arbitrary code.

type Functions

type Functions struct {
	// contains filtered or unexported fields
}

Functions represents a map of builtin SQL functions.

func NewFunctions

func NewFunctions() Functions

func (Functions) AddFunc

func (f Functions) AddFunc(name string, fn func(args ...Expr) (Expr, error))

AddFunc adds function to the map.

func (Functions) GetFunc

func (f Functions) GetFunc(name string, args ...Expr) (Expr, error)

GetFunc return a function expression by name.

type InOperator

type InOperator struct {
	// contains filtered or unexported fields
}

func (*InOperator) Eval

func (op *InOperator) Eval(env *Environment) (document.Value, error)

func (InOperator) IsEqual

func (op InOperator) IsEqual(other Expr) bool

Equal compares this expression with the other expression and returns true if they are equal.

func (InOperator) LeftHand

func (op InOperator) LeftHand() Expr

func (InOperator) Precedence

func (op InOperator) Precedence() int

func (InOperator) RightHand

func (op InOperator) RightHand() Expr

func (InOperator) SetLeftHandExpr

func (op InOperator) SetLeftHandExpr(a Expr)

func (InOperator) SetRightHandExpr

func (op InOperator) SetRightHandExpr(b Expr)

func (InOperator) String

func (op InOperator) String() string

func (InOperator) Token

func (op InOperator) Token() scanner.Token

type IsNotOperator

type IsNotOperator struct {
	// contains filtered or unexported fields
}

func (*IsNotOperator) Eval

func (op *IsNotOperator) Eval(env *Environment) (document.Value, error)

func (IsNotOperator) IsEqual

func (op IsNotOperator) IsEqual(other Expr) bool

Equal compares this expression with the other expression and returns true if they are equal.

func (IsNotOperator) LeftHand

func (op IsNotOperator) LeftHand() Expr

func (IsNotOperator) Precedence

func (op IsNotOperator) Precedence() int

func (IsNotOperator) RightHand

func (op IsNotOperator) RightHand() Expr

func (IsNotOperator) SetLeftHandExpr

func (op IsNotOperator) SetLeftHandExpr(a Expr)

func (IsNotOperator) SetRightHandExpr

func (op IsNotOperator) SetRightHandExpr(b Expr)

func (*IsNotOperator) String

func (op *IsNotOperator) String() string

func (IsNotOperator) Token

func (op IsNotOperator) Token() scanner.Token

type IsOperator

type IsOperator struct {
	// contains filtered or unexported fields
}

func (*IsOperator) Eval

func (op *IsOperator) Eval(env *Environment) (document.Value, error)

func (IsOperator) IsEqual

func (op IsOperator) IsEqual(other Expr) bool

Equal compares this expression with the other expression and returns true if they are equal.

func (IsOperator) LeftHand

func (op IsOperator) LeftHand() Expr

func (IsOperator) Precedence

func (op IsOperator) Precedence() int

func (IsOperator) RightHand

func (op IsOperator) RightHand() Expr

func (IsOperator) SetLeftHandExpr

func (op IsOperator) SetLeftHandExpr(a Expr)

func (IsOperator) SetRightHandExpr

func (op IsOperator) SetRightHandExpr(b Expr)

func (IsOperator) String

func (op IsOperator) String() string

func (IsOperator) Token

func (op IsOperator) Token() scanner.Token

type KVPair

type KVPair struct {
	K string
	V Expr
}

KVPair associates an identifier with an expression.

func (KVPair) String

func (p KVPair) String() string

String implements the stringutil.Stringer interface.

type KVPairs

type KVPairs struct {
	Pairs          []KVPair
	SelfReferenced bool
}

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.

func (*KVPairs) IsEqual

func (kvp *KVPairs) IsEqual(other Expr) bool

IsEqual compares this expression with the other expression and returns true if they are equal.

func (KVPairs) String

func (kvp KVPairs) String() string

String implements the stringutil.Stringer interface.

type LikeOperator

type LikeOperator struct {
	// contains filtered or unexported fields
}

func (*LikeOperator) Eval

func (op *LikeOperator) Eval(env *Environment) (document.Value, error)

func (LikeOperator) IsEqual

func (op LikeOperator) IsEqual(other Expr) bool

Equal compares this expression with the other expression and returns true if they are equal.

func (LikeOperator) LeftHand

func (op LikeOperator) LeftHand() Expr

func (LikeOperator) Precedence

func (op LikeOperator) Precedence() int

func (LikeOperator) RightHand

func (op LikeOperator) RightHand() Expr

func (LikeOperator) SetLeftHandExpr

func (op LikeOperator) SetLeftHandExpr(a Expr)

func (LikeOperator) SetRightHandExpr

func (op LikeOperator) SetRightHandExpr(b Expr)

func (LikeOperator) String

func (op LikeOperator) String() string

func (LikeOperator) Token

func (op LikeOperator) Token() scanner.Token

type LiteralExprList

type LiteralExprList []Expr

LiteralExprList is a list of expressions.

func (LiteralExprList) Eval

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 stringutil.Stringer interface.

type LiteralValue

type LiteralValue document.Value

A LiteralValue represents a litteral value of any type defined by the value package.

func (LiteralValue) Eval

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 stringutil.Stringer interface.

type MaxAggregator

type MaxAggregator struct {
	Fn  *MaxFunc
	Max document.Value
}

MaxAggregator is an aggregator that returns the minimum non-null value.

func (*MaxAggregator) Aggregate

func (m *MaxAggregator) Aggregate(env *Environment) error

Aggregate 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) Eval

func (m *MaxAggregator) Eval(env *Environment) (document.Value, error)

Eval return the maximum value.

func (*MaxAggregator) String

func (m *MaxAggregator) String() string

type MaxFunc

type MaxFunc struct {
	Expr Expr
}

MaxFunc is the MAX aggregator function.

func (*MaxFunc) Aggregator

func (m *MaxFunc) Aggregator() Aggregator

Aggregator returns a MaxAggregator. It implements the AggregatorBuilder interface.

func (*MaxFunc) Eval

func (m *MaxFunc) Eval(env *Environment) (document.Value, error)

Eval extracts the max value from the given document and returns it.

func (*MaxFunc) IsEqual

func (m *MaxFunc) IsEqual(other Expr) bool

IsEqual compares this expression with the other expression and returns true if they are equal.

func (*MaxFunc) Params

func (m *MaxFunc) Params() []Expr

func (*MaxFunc) String

func (m *MaxFunc) String() string

String returns the alias if non-zero, otherwise it returns a string representation of the count expression.

type MinAggregator

type MinAggregator struct {
	Fn  *MinFunc
	Min document.Value
}

MinAggregator is an aggregator that returns the minimum non-null value.

func (*MinAggregator) Aggregate

func (m *MinAggregator) Aggregate(env *Environment) error

Aggregate 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) Eval

func (m *MinAggregator) Eval(env *Environment) (document.Value, error)

Eval return the minimum value.

func (*MinAggregator) String

func (m *MinAggregator) String() string

type MinFunc

type MinFunc struct {
	Expr Expr
}

MinFunc is the MIN aggregator function.

func (*MinFunc) Aggregator

func (m *MinFunc) Aggregator() Aggregator

Aggregator returns a MinAggregator. It implements the AggregatorBuilder interface.

func (*MinFunc) Eval

func (m *MinFunc) Eval(env *Environment) (document.Value, error)

Eval extracts the min value from the given document and returns it.

func (*MinFunc) IsEqual

func (m *MinFunc) IsEqual(other Expr) bool

IsEqual compares this expression with the other expression and returns true if they are equal.

func (*MinFunc) Params

func (m *MinFunc) Params() []Expr

func (*MinFunc) String

func (m *MinFunc) String() string

String returns the alias if non-zero, otherwise it returns a string representation of the count expression.

type NamedExpr

type NamedExpr struct {
	Expr

	ExprName string
}

NamedExpr is an expression with a name.

func (NamedExpr) Name

func (e NamedExpr) Name() string

Name returns ExprName.

func (NamedExpr) String

func (e NamedExpr) String() string

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 stringutil.Stringer interface.

type NotInOperator

type NotInOperator struct {
	InOperator
}

func (*NotInOperator) Eval

func (op *NotInOperator) Eval(env *Environment) (document.Value, error)

func (NotInOperator) IsEqual

func (op NotInOperator) IsEqual(other Expr) bool

Equal compares this expression with the other expression and returns true if they are equal.

func (NotInOperator) LeftHand

func (op NotInOperator) LeftHand() Expr

func (NotInOperator) Precedence

func (op NotInOperator) Precedence() int

func (NotInOperator) RightHand

func (op NotInOperator) RightHand() Expr

func (NotInOperator) SetLeftHandExpr

func (op NotInOperator) SetLeftHandExpr(a Expr)

func (NotInOperator) SetRightHandExpr

func (op NotInOperator) SetRightHandExpr(b Expr)

func (*NotInOperator) String

func (op *NotInOperator) String() string

func (NotInOperator) Token

func (op NotInOperator) Token() scanner.Token

type NotLikeOperator

type NotLikeOperator struct {
	LikeOperator
}

func (*NotLikeOperator) Eval

func (op *NotLikeOperator) Eval(env *Environment) (document.Value, error)

func (NotLikeOperator) IsEqual

func (op NotLikeOperator) IsEqual(other Expr) bool

Equal compares this expression with the other expression and returns true if they are equal.

func (NotLikeOperator) LeftHand

func (op NotLikeOperator) LeftHand() Expr

func (NotLikeOperator) Precedence

func (op NotLikeOperator) Precedence() int

func (NotLikeOperator) RightHand

func (op NotLikeOperator) RightHand() Expr

func (NotLikeOperator) SetLeftHandExpr

func (op NotLikeOperator) SetLeftHandExpr(a Expr)

func (NotLikeOperator) SetRightHandExpr

func (op NotLikeOperator) SetRightHandExpr(b Expr)

func (*NotLikeOperator) String

func (op *NotLikeOperator) String() string

func (NotLikeOperator) Token

func (op NotLikeOperator) Token() scanner.Token

type NotOp

type NotOp struct {
	// contains filtered or unexported fields
}

NotOp is the NOT unary operator.

func (*NotOp) Eval

func (op *NotOp) Eval(env *Environment) (document.Value, error)

Eval implements the Expr interface. It evaluates e and returns true if b is falsy

func (NotOp) IsEqual

func (op NotOp) IsEqual(other Expr) bool

Equal compares this expression with the other expression and returns true if they are equal.

func (NotOp) LeftHand

func (op NotOp) LeftHand() Expr

func (NotOp) Precedence

func (op NotOp) Precedence() int

func (NotOp) RightHand

func (op NotOp) RightHand() Expr

func (NotOp) SetLeftHandExpr

func (op NotOp) SetLeftHandExpr(a Expr)

func (NotOp) SetRightHandExpr

func (op NotOp) SetRightHandExpr(b Expr)

func (*NotOp) String

func (op *NotOp) String() string

String implements the stringutil.Stringer interface.

func (NotOp) Token

func (op NotOp) Token() scanner.Token

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 Or 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

func (op OrOp) IsEqual(other Expr) bool

Equal compares this expression with the other expression and returns true if they are equal.

func (OrOp) LeftHand

func (op OrOp) LeftHand() Expr

func (OrOp) Precedence

func (op OrOp) Precedence() int

func (OrOp) RightHand

func (op OrOp) RightHand() Expr

func (OrOp) SetLeftHandExpr

func (op OrOp) SetLeftHandExpr(a Expr)

func (OrOp) SetRightHandExpr

func (op OrOp) SetRightHandExpr(b Expr)

func (OrOp) String

func (op OrOp) String() string

func (OrOp) Token

func (op OrOp) Token() scanner.Token

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.

func (*PKFunc) IsEqual

func (k *PKFunc) IsEqual(other Expr) bool

IsEqual compares this expression with the other expression and returns true if they are equal.

func (*PKFunc) Params

func (*PKFunc) Params() []Expr

func (*PKFunc) String

func (k *PKFunc) String() string

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

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

func (p Parentheses) Eval(env *Environment) (document.Value, error)

Eval calls the underlying expression Eval method.

func (Parentheses) IsEqual

func (p Parentheses) IsEqual(other Expr) bool

IsEqual compares this expression with the other expression and returns true if they are equal.

func (Parentheses) String

func (p Parentheses) String() string

type Path

type Path document.Path

A Path is an expression that extracts a value from a document at a given path.

func (Path) Eval

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.

func (Path) IsEqual

func (p Path) IsEqual(other Expr) bool

IsEqual compares this expression with the other expression and returns true if they are equal.

func (Path) String

func (p Path) String() string

type PositionalParam

type PositionalParam int

PositionalParam is an expression which represents the position of a parameter.

func (PositionalParam) Eval

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 stringutil.Stringer interface.

type SumAggregator

type SumAggregator struct {
	Fn   *SumFunc
	SumI *int64
	SumF *float64
}

SumAggregator is an aggregator that returns the minimum non-null value.

func (*SumAggregator) Aggregate

func (s *SumAggregator) Aggregate(env *Environment) error

Aggregate 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) Eval

func (s *SumAggregator) Eval(env *Environment) (document.Value, error)

Eval return the aggregated sum.

func (*SumAggregator) String

func (s *SumAggregator) String() string

type SumFunc

type SumFunc struct {
	Expr Expr
}

SumFunc is the SUM aggregator function.

func (*SumFunc) Aggregator

func (s *SumFunc) Aggregator() Aggregator

Aggregator returns a SumFunc. It implements the AggregatorBuilder interface.

func (*SumFunc) Eval

func (s *SumFunc) Eval(env *Environment) (document.Value, error)

Eval extracts the sum value from the given document and returns it.

func (*SumFunc) IsEqual

func (s *SumFunc) IsEqual(other Expr) bool

IsEqual compares this expression with the other expression and returns true if they are equal.

func (*SumFunc) Params

func (s *SumFunc) Params() []Expr

func (*SumFunc) String

func (s *SumFunc) String() string

String returns the alias if non-zero, otherwise it returns a string representation of the count expression.

type Wildcard

type Wildcard struct{}

A Wildcard is an expression that iterates over all the fields of a document.

func (Wildcard) Eval

func (w Wildcard) Eval(env *Environment) (document.Value, error)

func (Wildcard) Iterate

func (w Wildcard) Iterate(env *Environment, fn func(field string, value document.Value) error) error

Iterate call the document iterate method.

func (Wildcard) String

func (w Wildcard) String() string

Jump to

Keyboard shortcuts

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