Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Avg ¶
Avg is the AVG aggregator function.
func (*Avg) Aggregator ¶
func (s *Avg) Aggregator() expr.Aggregator
Aggregator returns a Avg. It implements the AggregatorBuilder interface.
func (*Avg) Eval ¶
func (s *Avg) Eval(env *environment.Environment) (types.Value, error)
Eval extracts the average value from the given document and returns it.
type AvgAggregator ¶
AvgAggregator is an aggregator that returns the average non-null value.
func (*AvgAggregator) Aggregate ¶
func (s *AvgAggregator) Aggregate(env *environment.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.Environment) (types.Value, error)
Eval returns the aggregated average as a double.
func (*AvgAggregator) String ¶
func (s *AvgAggregator) String() string
type Count ¶
Count is the COUNT aggregator function. It counts the number of documents in a stream.
func (*Count) Aggregator ¶
func (c *Count) Aggregator() expr.Aggregator
Aggregator returns a CountAggregator. It implements the AggregatorBuilder interface.
func (*Count) Eval ¶
func (c *Count) Eval(env *environment.Environment) (types.Value, error)
type CountAggregator ¶
CountAggregator is an aggregator that counts non-null expressions.
func (*CountAggregator) Aggregate ¶
func (c *CountAggregator) Aggregate(env *environment.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.Environment) (types.Value, error)
Eval returns the result of the aggregation as an integer.
func (*CountAggregator) String ¶
func (c *CountAggregator) String() string
type Definition ¶
type Definition interface { Name() string String() string Function(...expr.Expr) (expr.Function, error) Arity() int }
A Definition transforms a list of expressions into a Function.
type Definitions ¶
type Definitions map[string]Definition
Definitions table holds a map of definition, indexed by their names.
func BuiltinDefinitions ¶
func BuiltinDefinitions() Definitions
BuiltinDefinitions returns a map of builtin functions.
func MathFunctions ¶
func MathFunctions() Definitions
MathFunctions returns all math package functions.
type Max ¶
Max is the MAX aggregator function.
func (*Max) Aggregator ¶
func (m *Max) Aggregator() expr.Aggregator
Aggregator returns a MaxAggregator. It implements the AggregatorBuilder interface.
func (*Max) Eval ¶
func (m *Max) Eval(env *environment.Environment) (types.Value, error)
Eval extracts the max value from the given document and returns it.
type MaxAggregator ¶
MaxAggregator is an aggregator that returns the minimum non-null value.
func (*MaxAggregator) Aggregate ¶
func (m *MaxAggregator) Aggregate(env *environment.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.Environment) (types.Value, error)
Eval return the maximum value.
func (*MaxAggregator) String ¶
func (m *MaxAggregator) String() string
type Min ¶
Min is the MIN aggregator function.
func (*Min) Aggregator ¶
func (m *Min) Aggregator() expr.Aggregator
Aggregator returns a MinAggregator. It implements the AggregatorBuilder interface.
func (*Min) Eval ¶
func (m *Min) Eval(env *environment.Environment) (types.Value, error)
Eval extracts the min value from the given document and returns it.
type MinAggregator ¶
MinAggregator is an aggregator that returns the minimum non-null value.
func (*MinAggregator) Aggregate ¶
func (m *MinAggregator) Aggregate(env *environment.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.Environment) (types.Value, error)
Eval return the minimum value.
func (*MinAggregator) String ¶
func (m *MinAggregator) String() string
type PK ¶
type PK struct{}
PK represents the pk() function. It returns the primary key of the current document.
func (*PK) Eval ¶
func (k *PK) Eval(env *environment.Environment) (types.Value, error)
Eval returns the primary key of the current document.
type Packages ¶
type Packages map[string]Definitions
Packages represent a table of SQL functions grouped by their packages
func DefaultPackages ¶
func DefaultPackages() Packages
type ScalarDefinition ¶
type ScalarDefinition struct {
// contains filtered or unexported fields
}
A ScalarDefinition is the definition type for functions which operates on scalar values in contrast to other SQL functions such as the SUM aggregator wich operates on expressions instead.
This difference allows to simply define them with a CallFn function that takes multiple document.Value and return another types.Value, rather than having to manually evaluate expressions (see Definition).
func NewScalarDefinition ¶
func (*ScalarDefinition) Arity ¶
func (fd *ScalarDefinition) Arity() int
Arity returns the arity of the defined function.
func (*ScalarDefinition) Name ¶
func (fd *ScalarDefinition) Name() string
Name returns the defined function named (as an ident, so no parentheses).
func (*ScalarDefinition) String ¶
func (fd *ScalarDefinition) String() string
String returns the defined function name and its arguments.
type ScalarFunction ¶
type ScalarFunction struct {
// contains filtered or unexported fields
}
A ScalarFunction is a function which operates on scalar values in contrast to other SQL functions such as the SUM aggregator wich operates on expressions instead.
func (*ScalarFunction) Eval ¶
func (sf *ScalarFunction) Eval(env *environment.Environment) (types.Value, error)
Eval returns a document.Value based on the given environment and the underlying function definition.
func (*ScalarFunction) Params ¶
func (sf *ScalarFunction) Params() []expr.Expr
Params return the function arguments.
func (*ScalarFunction) String ¶
func (sf *ScalarFunction) String() string
String returns a string represention of the function expression and its arguments.
type Sum ¶
Sum is the SUM aggregator function.
func (*Sum) Aggregator ¶
func (s *Sum) Aggregator() expr.Aggregator
Aggregator returns a Sum. It implements the AggregatorBuilder interface.
func (*Sum) Eval ¶
func (s *Sum) Eval(env *environment.Environment) (types.Value, error)
Eval extracts the sum value from the given document and returns it.
type SumAggregator ¶
SumAggregator is an aggregator that returns the minimum non-null value.
func (*SumAggregator) Aggregate ¶
func (s *SumAggregator) Aggregate(env *environment.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.Environment) (types.Value, error)
Eval return the aggregated sum.
func (*SumAggregator) String ¶
func (s *SumAggregator) String() string