Documentation
¶
Overview ¶
Package ast defines the cirql abstract syntax tree: the typed pipeline, stages, and expressions a parsed query produces. Nodes are pure data; the closed Stage and Expr sets are enforced by unexported tag methods.
Index ¶
- type BinOp
- type BinaryExpr
- type Expr
- type FieldAccess
- type FileStage
- type FilterStage
- type FlatMapStage
- type FuncCall
- type HTTPStage
- type LimitStage
- type Literal
- type MapStage
- type Mapping
- type PathSegment
- type Pipeline
- type QueryStage
- type ReduceOp
- type ReduceStage
- type SortStage
- type Stage
- type StdinStage
- type UnOp
- type UnaryExpr
- type UniqStage
- type VarRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinOp ¶
type BinOp string
BinOp names a binary operator.
const ( // OpOr is logical ||. OpOr BinOp = "||" // OpAnd is logical &&. OpAnd BinOp = "&&" // OpEq is ==. OpEq BinOp = "==" // OpNe is !=. OpNe BinOp = "!=" // OpGt is >. OpGt BinOp = ">" // OpLt is <. OpLt BinOp = "<" // OpGe is >=. OpGe BinOp = ">=" // OpLe is <=. OpLe BinOp = "<=" // OpAdd is +. OpAdd BinOp = "+" // OpSub is -. OpSub BinOp = "-" // OpMul is *. OpMul BinOp = "*" // OpDiv is /. OpDiv BinOp = "/" // OpMod is %. OpMod BinOp = "%" )
type Expr ¶
type Expr interface {
// contains filtered or unexported methods
}
Expr is an expression evaluated against the current object. Closed via isExpr.
type FieldAccess ¶
type FieldAccess struct{ Path []PathSegment }
FieldAccess is .a.b[] etc.; an empty Path is the identity ".".
type FilterStage ¶
type FilterStage struct{ Cond Expr }
FilterStage keeps objects for which Cond is truthy.
type FlatMapStage ¶
type FlatMapStage struct{ Mappings []Mapping }
FlatMapStage transforms and flattens: list-valued mappings expand into multiple output objects.
type LimitStage ¶
type LimitStage struct{ N int }
LimitStage truncates the result set to at most N objects.
type MapStage ¶
type MapStage struct{ Mappings []Mapping }
MapStage transforms each object 1:1 into a new object.
type PathSegment ¶
PathSegment is one step of a field access: a named field, or [] iteration.
type Pipeline ¶
type Pipeline struct {
Stages []Stage
}
Pipeline is a parsed cirql query: an ordered list of stages.
type ReduceOp ¶
type ReduceOp string
ReduceOp names an aggregation in a reduce stage.
const ( // OpCount counts the result set. OpCount ReduceOp = "count" // OpSum sums the argument expression over the result set. OpSum ReduceOp = "sum" // OpMin takes the minimum of the argument expression. OpMin ReduceOp = "min" // OpMax takes the maximum of the argument expression. OpMax ReduceOp = "max" // OpAvg averages the argument expression. OpAvg ReduceOp = "avg" // OpFirst returns the first object. OpFirst ReduceOp = "first" // OpLast returns the last object. OpLast ReduceOp = "last" // OpGroupBy groups objects by the argument expression. OpGroupBy ReduceOp = "group_by" // OpCollect collects the argument expression from each object into a list. OpCollect ReduceOp = "collect" )
type ReduceStage ¶
ReduceStage aggregates the result set into a single object.
type Stage ¶
type Stage interface {
// contains filtered or unexported methods
}
Stage is one step in a pipeline. The set is closed via isStage.