Documentation
¶
Index ¶
- Variables
- type BaseOperator
- type ConcatIterator
- type ConcatOperator
- type DiscardIterator
- type DiscardOperator
- type Iterator
- type Operator
- type OperatorFunc
- type Range
- type Ranges
- type RowsIterator
- type RowsOperator
- type Stream
- func (s *Stream) Columns(env *environment.Environment) ([]string, error)
- func (s *Stream) First() Operator
- func (s *Stream) Iterate(in *environment.Environment, fn func(database.Row) error) error
- func (s *Stream) Iterator(in *environment.Environment) (Iterator, error)
- func (s *Stream) Pipe(op Operator) *Stream
- func (s *Stream) Remove(op Operator)
- func (s *Stream) String() string
- type UnionIterator
- type UnionOperator
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidResult = errors.New("expression must evaluate to an object")
ErrInvalidResult is returned when an expression supposed to evaluate to an object returns something else.
var ErrStreamClosed = errors.New("stream closed")
ErrStreamClosed is used to indicate that a stream must be closed.
Functions ¶
This section is empty.
Types ¶
type BaseOperator ¶
func (*BaseOperator) Columns ¶ added in v0.17.0
func (op *BaseOperator) Columns(env *environment.Environment) ([]string, error)
func (*BaseOperator) GetNext ¶
func (op *BaseOperator) GetNext() Operator
func (*BaseOperator) GetPrev ¶
func (op *BaseOperator) GetPrev() Operator
func (*BaseOperator) SetNext ¶
func (op *BaseOperator) SetNext(o Operator)
func (*BaseOperator) SetPrev ¶
func (op *BaseOperator) SetPrev(o Operator)
type ConcatIterator ¶ added in v0.17.0
type ConcatIterator struct {
// contains filtered or unexported fields
}
func (*ConcatIterator) Close ¶ added in v0.17.0
func (it *ConcatIterator) Close() error
func (*ConcatIterator) Error ¶ added in v0.17.0
func (it *ConcatIterator) Error() error
func (*ConcatIterator) Next ¶ added in v0.17.0
func (it *ConcatIterator) Next() bool
type ConcatOperator ¶
type ConcatOperator struct {
BaseOperator
Streams []*Stream
}
A ConcatOperator concatenates two streams.
func Concat ¶
func Concat(s ...*Stream) *ConcatOperator
Concat turns two individual streams into one.
func (*ConcatOperator) Columns ¶ added in v0.17.0
func (it *ConcatOperator) Columns(env *environment.Environment) ([]string, error)
func (*ConcatOperator) Iterator ¶ added in v0.17.0
func (it *ConcatOperator) Iterator(in *environment.Environment) (Iterator, error)
func (*ConcatOperator) String ¶
func (it *ConcatOperator) String() string
type DiscardIterator ¶ added in v0.17.0
type DiscardIterator struct {
Iterator
}
func (*DiscardIterator) Next ¶ added in v0.17.0
func (it *DiscardIterator) Next() bool
type DiscardOperator ¶
type DiscardOperator struct {
BaseOperator
}
DiscardOperator is an operator that doesn't do anything.
func Discard ¶
func Discard() *DiscardOperator
Discard is an operator that doesn't produce any row. It iterates over the previous operator and discards all the objects.
func (*DiscardOperator) Iterator ¶ added in v0.17.0
func (op *DiscardOperator) Iterator(in *environment.Environment) (Iterator, error)
Iterator returns an iterator which discards all rows.
func (*DiscardOperator) String ¶
func (it *DiscardOperator) String() string
type Operator ¶
type Operator interface {
// Iterate(in *environment.Environment, fn func(out *environment.Environment) error) error
Iterator(in *environment.Environment) (Iterator, error)
SetPrev(prev Operator)
SetNext(next Operator)
GetNext() Operator
GetPrev() Operator
String() string
Columns(env *environment.Environment) ([]string, error)
}
An Operator is used to modify a stream. It takes an environment containing the current value as well as any other metadata created by other operators and returns a new environment which will be passed to the next operator. If it returns a nil environment, the env will be ignored. If it returns an error, the stream will be interrupted and that error will bubble up and returned by this function, unless that error is ErrStreamClosed, in which case the Iterate method will stop the iteration and return nil. Stream operators can be reused, and thus, any state or side effect should be kept within the Op closure unless the nature of the operator prevents that.
func InsertAfter ¶
func InsertBefore ¶
type OperatorFunc ¶
type OperatorFunc func(func(env *environment.Environment) error) error
An OperatorFunc is the function that will receive each value of the stream.
type Range ¶
type Range struct {
Min, Max expr.LiteralExprList
Columns []string
// Exclude Min and Max from the results.
// By default, min and max are inclusive.
// Exclusive and Exact cannot be set to true at the same time.
Exclusive bool
// Used to match an exact value equal to Min.
// If set to true, Max will be ignored for comparison
// and for determining the global upper bound.
Exact bool
}
Range represents a range to select values after or before a given boundary.
func (*Range) Eval ¶
func (r *Range) Eval(env *environment.Environment) (*database.Range, error)
type Ranges ¶
type Ranges []Range
func (Ranges) Eval ¶
func (r Ranges) Eval(env *environment.Environment) ([]*database.Range, error)
Encode each range using the given value encoder.
type RowsIterator ¶ added in v0.17.0
type RowsIterator struct {
// contains filtered or unexported fields
}
func (*RowsIterator) Close ¶ added in v0.17.0
func (it *RowsIterator) Close() error
func (*RowsIterator) Env ¶ added in v0.17.0
func (it *RowsIterator) Env() *environment.Environment
func (*RowsIterator) Error ¶ added in v0.17.0
func (it *RowsIterator) Error() error
func (*RowsIterator) Next ¶ added in v0.17.0
func (it *RowsIterator) Next() bool
type RowsOperator ¶ added in v0.17.0
type RowsOperator struct {
BaseOperator
Rows []database.Row
// contains filtered or unexported fields
}
func Rows ¶ added in v0.17.0
func Rows(columns []string, rows ...database.Row) *RowsOperator
Rows creates an operator that iterates over the given rows.
func (*RowsOperator) Columns ¶ added in v0.17.0
func (it *RowsOperator) Columns(env *environment.Environment) ([]string, error)
func (*RowsOperator) Iterator ¶ added in v0.17.0
func (op *RowsOperator) Iterator(in *environment.Environment) (Iterator, error)
func (*RowsOperator) String ¶ added in v0.17.0
func (op *RowsOperator) String() string
type Stream ¶
type Stream struct {
Op Operator
}
func (*Stream) Columns ¶ added in v0.17.0
func (s *Stream) Columns(env *environment.Environment) ([]string, error)
func (*Stream) Iterate ¶
func (s *Stream) Iterate(in *environment.Environment, fn func(database.Row) error) error
func (*Stream) Iterator ¶ added in v0.17.0
func (s *Stream) Iterator(in *environment.Environment) (Iterator, error)
type UnionIterator ¶ added in v0.17.0
type UnionIterator struct {
// contains filtered or unexported fields
}
func (*UnionIterator) Close ¶ added in v0.17.0
func (it *UnionIterator) Close() error
func (*UnionIterator) Error ¶ added in v0.17.0
func (it *UnionIterator) Error() error
func (*UnionIterator) Next ¶ added in v0.17.0
func (it *UnionIterator) Next() bool
type UnionOperator ¶
type UnionOperator struct {
BaseOperator
Streams []*Stream
}
UnionOperator is an operator that merges the results of multiple operators.
func (*UnionOperator) Columns ¶ added in v0.17.0
func (it *UnionOperator) Columns(env *environment.Environment) ([]string, error)
func (*UnionOperator) Iterator ¶ added in v0.17.0
func (op *UnionOperator) Iterator(in *environment.Environment) (Iterator, error)
Iterate iterates over all the streams and returns their union.
func (*UnionOperator) String ¶
func (it *UnionOperator) String() string