Documentation ¶
Index ¶
- Variables
- func Eval(expr Expr, m Valuer) interface{}
- func GetStreams(stmt *SelectStatement) (result []string)
- func HasAggFuncs(node Node) bool
- func HasNoAggFuncs(node Node) bool
- func IsAggStatement(stmt *SelectStatement) bool
- func LowercaseKeyMap(m map[string]interface{}) map[string]interface{}
- func NewAggregateFunctionValuers(p *funcPlugins) (*FunctionValuer, *AggregateFunctionValuer)
- func NewFuncPlugins(ctx api.StreamContext) *funcPlugins
- func NewFunctionValuersForOp(ctx api.StreamContext) (*FunctionValuer, *AggregateFunctionValuer)
- func PrintFieldType(ft FieldType) (result string)
- func PrintFieldTypeForJson(ft FieldType) (result interface{})
- func Validate(stmt *SelectStatement) error
- func Walk(v Visitor, node Node)
- func WalkFunc(node Node, fn func(Node))
- type AggregateCallValuer
- type AggregateData
- type AggregateFunctionValuer
- func (v *AggregateFunctionValuer) Call(name string, args []interface{}) (interface{}, bool)
- func (v *AggregateFunctionValuer) GetAllTuples() AggregateData
- func (v *AggregateFunctionValuer) GetSingleCallValuer() CallValuer
- func (v *AggregateFunctionValuer) Meta(key string) (interface{}, bool)
- func (v *AggregateFunctionValuer) SetData(data AggregateData)
- func (v *AggregateFunctionValuer) Value(key string) (interface{}, bool)
- type AllowTypes
- type ArrayType
- type ArrowExpr
- type BasicType
- type BinaryExpr
- type BooleanLiteral
- type BracketEvalResult
- type BracketExpr
- type Call
- type CallValuer
- type ColonExpr
- type DataType
- type DataValuer
- type DescribeStreamStatement
- type Dimension
- type Dimensions
- type DropStreamStatement
- type EvalResultMessage
- type Event
- type ExplainStreamStatement
- type Expr
- type ExpressionEvaluator
- type ExpressionVisitor
- type ExpressionVisitorAdaptor
- type Field
- type FieldRef
- type FieldType
- type Fields
- type FunctionValuer
- type GroupedTuples
- type GroupedTuplesSet
- type IndexExpr
- type IntegerLiteral
- type Join
- type JoinTuple
- type JoinTupleSets
- type JoinType
- type Joins
- type Literal
- type Message
- type MetaRef
- type Metadata
- type MultiSorter
- type Node
- type NumberLiteral
- type Options
- type ParenExpr
- type ParseTree
- type Parser
- func (p *Parser) ConvertToWindows(wtype WindowType, args []Expr) (*Window, error)
- func (p *Parser) Parse() (*SelectStatement, error)
- func (p *Parser) ParseCreateStreamStmt() (*StreamStmt, error)
- func (p *Parser) ParseExpr() (Expr, error)
- func (p *Parser) ParseJoin(joinType JoinType) (*Join, error)
- func (p *Parser) ParseQueries() (SelectStatements, error)
- type RecType
- type ResultsAndMessages
- type Scanner
- func (s *Scanner) Scan() (tok Token, lit string)
- func (s *Scanner) ScanBackquoteIdent() (tok Token, lit string)
- func (s *Scanner) ScanDigit() (tok Token, lit string)
- func (s *Scanner) ScanIdent() (tok Token, lit string)
- func (s *Scanner) ScanNumber(startWithDot bool, isNeg bool) (tok Token, lit string)
- func (s *Scanner) ScanString() (tok Token, lit string)
- func (s *Scanner) ScanWhiteSpace() (tok Token, lit string)
- type SelectStatement
- type SelectStatements
- type ShowStreamsStatement
- type SortField
- type SortFields
- type SortingData
- type Source
- type Sources
- type Statement
- type StreamField
- type StreamFields
- type StreamName
- type StreamStmt
- type StringLiteral
- type Table
- type TimeLiteral
- type Token
- type Tuple
- func (t *Tuple) AggregateEval(expr Expr, v CallValuer) []interface{}
- func (t *Tuple) All(stream string) (interface{}, bool)
- func (t *Tuple) GetMetadata() Metadata
- func (t *Tuple) GetTimestamp() int64
- func (t *Tuple) IsWatermark() bool
- func (t *Tuple) Meta(key string) (interface{}, bool)
- func (t *Tuple) Value(key string) (interface{}, bool)
- type Valuer
- type ValuerEval
- type Visitor
- type Wildcard
- type WildcardValuer
- type Wildcarder
- type Window
- type WindowTuples
- type WindowTuplesSet
- func (w WindowTuplesSet) AddTuple(tuple *Tuple) WindowTuplesSet
- func (w WindowTuplesSet) AggregateEval(expr Expr, v CallValuer) []interface{}
- func (w WindowTuplesSet) GetBySrc(src string) []Tuple
- func (w WindowTuplesSet) Index(i int) Valuer
- func (w WindowTuplesSet) Len() int
- func (w WindowTuplesSet) Sort()
- func (w WindowTuplesSet) Swap(i, j int)
- type WindowType
Constants ¶
This section is empty.
Variables ¶
var AsteriskExpr = StringLiteral{Val: "*"}
var COLUMN_SEPARATOR = tokens[COLSEP]
var Language = &ParseTree{}
Functions ¶
func GetStreams ¶
func GetStreams(stmt *SelectStatement) (result []string)
func HasAggFuncs ¶
func HasNoAggFuncs ¶
func IsAggStatement ¶
func IsAggStatement(stmt *SelectStatement) bool
func LowercaseKeyMap ¶
func NewAggregateFunctionValuers ¶
func NewAggregateFunctionValuers(p *funcPlugins) (*FunctionValuer, *AggregateFunctionValuer)
Should only be called by stream to make sure a single instance for an operation
func NewFuncPlugins ¶
func NewFuncPlugins(ctx api.StreamContext) *funcPlugins
func NewFunctionValuersForOp ¶
func NewFunctionValuersForOp(ctx api.StreamContext) (*FunctionValuer, *AggregateFunctionValuer)
func PrintFieldType ¶
func PrintFieldTypeForJson ¶
func PrintFieldTypeForJson(ft FieldType) (result interface{})
func Validate ¶
func Validate(stmt *SelectStatement) error
Types ¶
type AggregateCallValuer ¶
type AggregateCallValuer interface { CallValuer GetAllTuples() AggregateData GetSingleCallValuer() CallValuer }
type AggregateData ¶
type AggregateData interface {
AggregateEval(expr Expr, v CallValuer) []interface{}
}
type AggregateFunctionValuer ¶
type AggregateFunctionValuer struct {
// contains filtered or unexported fields
}
func (*AggregateFunctionValuer) Call ¶
func (v *AggregateFunctionValuer) Call(name string, args []interface{}) (interface{}, bool)
func (*AggregateFunctionValuer) GetAllTuples ¶
func (v *AggregateFunctionValuer) GetAllTuples() AggregateData
func (*AggregateFunctionValuer) GetSingleCallValuer ¶
func (v *AggregateFunctionValuer) GetSingleCallValuer() CallValuer
func (*AggregateFunctionValuer) Meta ¶
func (v *AggregateFunctionValuer) Meta(key string) (interface{}, bool)
func (*AggregateFunctionValuer) SetData ¶
func (v *AggregateFunctionValuer) SetData(data AggregateData)
func (*AggregateFunctionValuer) Value ¶
func (v *AggregateFunctionValuer) Value(key string) (interface{}, bool)
type AllowTypes ¶
type AllowTypes struct {
// contains filtered or unexported fields
}
type BinaryExpr ¶
type BooleanLiteral ¶
type BooleanLiteral struct {
Val bool
}
type BracketEvalResult ¶
type BracketEvalResult struct {
Start, End int
}
type BracketExpr ¶
type BracketExpr struct {
Expr Expr
}
type CallValuer ¶
type CallValuer interface { Valuer // Call is invoked to evaluate a function call (if possible). Call(name string, args []interface{}) (interface{}, bool) }
CallValuer implements the Call method for evaluating function calls.
type DataValuer ¶
type DataValuer interface { Valuer Wildcarder }
type DescribeStreamStatement ¶
type DescribeStreamStatement struct {
Name string
}
func (*DescribeStreamStatement) Stmt ¶
func (dss *DescribeStreamStatement) Stmt()
type Dimensions ¶
type Dimensions []Dimension
func (*Dimensions) GetGroups ¶
func (d *Dimensions) GetGroups() Dimensions
func (*Dimensions) GetWindow ¶
func (d *Dimensions) GetWindow() *Window
type DropStreamStatement ¶
type DropStreamStatement struct {
Name string
}
func (*DropStreamStatement) Stmt ¶
func (dss *DropStreamStatement) Stmt()
type EvalResultMessage ¶
type ExplainStreamStatement ¶
type ExplainStreamStatement struct {
Name string
}
func (*ExplainStreamStatement) Stmt ¶
func (ess *ExplainStreamStatement) Stmt()
type ExpressionEvaluator ¶
type ExpressionEvaluator struct { *ExpressionVisitorAdaptor // contains filtered or unexported fields }
func (*ExpressionEvaluator) Visit ¶
func (ee *ExpressionEvaluator) Visit(expr Node) Visitor
func (*ExpressionEvaluator) VisitBinaryExpr ¶
func (ee *ExpressionEvaluator) VisitBinaryExpr(expr *BinaryExpr)
func (*ExpressionEvaluator) VisitFieldRef ¶
func (ee *ExpressionEvaluator) VisitFieldRef(expr *FieldRef)
func (*ExpressionEvaluator) VisitIntegerLiteral ¶
func (ee *ExpressionEvaluator) VisitIntegerLiteral(expr *IntegerLiteral)
type ExpressionVisitor ¶
type ExpressionVisitor interface { Visit(Node) Visitor VisitBinaryExpr(*BinaryExpr) VisitFieldRef(*FieldRef) VisitIntegerLiteral(*IntegerLiteral) }
type ExpressionVisitorAdaptor ¶
type ExpressionVisitorAdaptor struct { }
func (*ExpressionVisitorAdaptor) DoVisit ¶
func (eva *ExpressionVisitorAdaptor) DoVisit(v ExpressionVisitor, expr Node)
func (*ExpressionVisitorAdaptor) Visit ¶
func (eva *ExpressionVisitorAdaptor) Visit(expr Node) Visitor
func (*ExpressionVisitorAdaptor) VisitBinaryExpr ¶
func (eva *ExpressionVisitorAdaptor) VisitBinaryExpr(expr *BinaryExpr)
func (*ExpressionVisitorAdaptor) VisitFieldRef ¶
func (eva *ExpressionVisitorAdaptor) VisitFieldRef(expr *FieldRef)
type FieldRef ¶
type FieldRef struct { StreamName StreamName Name string }
type FunctionValuer ¶
type FunctionValuer struct {
// contains filtered or unexported fields
}
ONLY use NewFunctionValuer function to initialize
func NewFunctionValuer ¶
func NewFunctionValuer(p *funcPlugins) *FunctionValuer
Should only be called by stream to make sure a single instance for an operation
func (*FunctionValuer) Call ¶
func (fv *FunctionValuer) Call(name string, args []interface{}) (interface{}, bool)
func (*FunctionValuer) Meta ¶
func (*FunctionValuer) Meta(_ string) (interface{}, bool)
func (*FunctionValuer) Value ¶
func (*FunctionValuer) Value(_ string) (interface{}, bool)
type GroupedTuples ¶
type GroupedTuples []DataValuer
func (GroupedTuples) AggregateEval ¶
func (s GroupedTuples) AggregateEval(expr Expr, v CallValuer) []interface{}
type GroupedTuplesSet ¶
type GroupedTuplesSet []GroupedTuples
func (GroupedTuplesSet) Index ¶
func (s GroupedTuplesSet) Index(i int) Valuer
func (GroupedTuplesSet) Len ¶
func (s GroupedTuplesSet) Len() int
func (GroupedTuplesSet) Swap ¶
func (s GroupedTuplesSet) Swap(i, j int)
type IntegerLiteral ¶
type IntegerLiteral struct {
Val int
}
type JoinTupleSets ¶
type JoinTupleSets []JoinTuple
func (JoinTupleSets) AggregateEval ¶
func (s JoinTupleSets) AggregateEval(expr Expr, v CallValuer) []interface{}
func (JoinTupleSets) Index ¶
func (s JoinTupleSets) Index(i int) Valuer
func (JoinTupleSets) Len ¶
func (s JoinTupleSets) Len() int
func (JoinTupleSets) Swap ¶
func (s JoinTupleSets) Swap(i, j int)
type Message ¶
type Message map[string]interface{}
Message is a valuer that substitutes values for the mapped interface.
type MetaRef ¶
type MetaRef struct { StreamName StreamName Name string }
type MultiSorter ¶
type MultiSorter struct { SortingData // contains filtered or unexported fields }
multiSorter implements the Sort interface, sorting the changes within.Hi
func OrderedBy ¶
func OrderedBy(fields SortFields, fv *FunctionValuer) *MultiSorter
OrderedBy returns a Sorter that sorts using the less functions, in order. Call its Sort method to sort the data.
func (*MultiSorter) Less ¶
func (ms *MultiSorter) Less(i, j int) bool
Less is part of sort.Interface. It is implemented by looping along the less functions until it finds a comparison that discriminates between the two items (one is less than the other). Note that it can call the less functions twice per call. We could change the functions to return -1, 0, 1 and reduce the number of calls for greater efficiency: an exercise for the reader.
func (*MultiSorter) Sort ¶
func (ms *MultiSorter) Sort(data SortingData) error
Sort sorts the argument slice according to the less functions passed to OrderedBy.
type NumberLiteral ¶
type NumberLiteral struct {
Val float64
}
type ParseTree ¶
type ParseTree struct { Handlers map[Token]func(*Parser) (Statement, error) Tokens map[Token]*ParseTree Keys []string }
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) ConvertToWindows ¶
func (p *Parser) ConvertToWindows(wtype WindowType, args []Expr) (*Window, error)
func (*Parser) Parse ¶
func (p *Parser) Parse() (*SelectStatement, error)
func (*Parser) ParseCreateStreamStmt ¶
func (p *Parser) ParseCreateStreamStmt() (*StreamStmt, error)
func (*Parser) ParseQueries ¶
func (p *Parser) ParseQueries() (SelectStatements, error)
type RecType ¶
type RecType struct {
StreamFields StreamFields
}
type ResultsAndMessages ¶
type ResultsAndMessages []EvalResultMessage
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
func NewScanner ¶
func (*Scanner) ScanBackquoteIdent ¶
func (*Scanner) ScanNumber ¶
func (*Scanner) ScanString ¶
func (*Scanner) ScanWhiteSpace ¶
type SelectStatement ¶
type SelectStatement struct { Fields Fields Sources Sources Joins Joins Condition Expr Dimensions Dimensions Having Expr SortFields SortFields }
func GetStatementFromSql ¶
func GetStatementFromSql(sql string) (*SelectStatement, error)
func (*SelectStatement) Stmt ¶
func (ss *SelectStatement) Stmt()
type SelectStatements ¶
type SelectStatements []SelectStatement
type ShowStreamsStatement ¶
type ShowStreamsStatement struct { }
func (*ShowStreamsStatement) Stmt ¶
func (ss *ShowStreamsStatement) Stmt()
type SortFields ¶
type SortFields []SortField
type StreamField ¶
func (*StreamField) MarshalJSON ¶
func (u *StreamField) MarshalJSON() ([]byte, error)
type StreamFields ¶
type StreamFields []StreamField
type StreamName ¶
type StreamName string
type StreamStmt ¶
type StreamStmt struct { Name StreamName StreamFields StreamFields Options Options }
func (*StreamStmt) Stmt ¶
func (ss *StreamStmt) Stmt()
type StringLiteral ¶
type StringLiteral struct {
Val string
}
type TimeLiteral ¶
type TimeLiteral struct {
Val Token
}
type Token ¶
type Token int
const ( // Special tokens ILLEGAL Token = iota EOF WS COMMENT AS // Literals IDENT // main INTEGER // 12345 NUMBER //12345.67 STRING // "abc" BADSTRING // "abc // ADD and the following are InfluxQL Operators ADD // + SUB // - MUL // * DIV // / MOD // % BITWISE_AND // & BITWISE_OR // | BITWISE_XOR // ^ AND // AND OR // OR EQ // = NEQ // != LT // < LTE // <= GT // > GTE // >= SUBSET //[ ARROW //-> // Misc characters ASTERISK // * COMMA // , LPAREN // ( RPAREN // ) LBRACKET //[ RBRACKET //] HASH // # DOT // . COLON //: SEMICOLON //; COLSEP //\007 // Keywords SELECT FROM JOIN INNER LEFT RIGHT FULL CROSS ON WHERE GROUP ORDER HAVING BY ASC DESC FILTER TRUE FALSE CREATE DROP EXPLAIN DESCRIBE SHOW STREAM STREAMS WITH XBIGINT XFLOAT XSTRING XBYTEA XDATETIME XBOOLEAN XARRAY XSTRUCT DATASOURCE KEY FORMAT CONF_KEY TYPE STRICT_VALIDATION TIMESTAMP TIMESTAMP_FORMAT JSONCONFIG DD HH MI SS MS )
func (Token) Precedence ¶
type Tuple ¶
func (*Tuple) AggregateEval ¶
func (t *Tuple) AggregateEval(expr Expr, v CallValuer) []interface{}
func (*Tuple) GetMetadata ¶
func (*Tuple) GetTimestamp ¶
func (*Tuple) IsWatermark ¶
type Valuer ¶
type Valuer interface { // Value returns the value and existence flag for a given key. Value(key string) (interface{}, bool) Meta(key string) (interface{}, bool) }
Valuer is the interface that wraps the Value() method.
func MultiAggregateValuer ¶
func MultiAggregateValuer(data AggregateData, singleCallValuer CallValuer, valuers ...Valuer) Valuer
func MultiValuer ¶
MultiValuer returns a Valuer that iterates over multiple Valuer instances to find a match.
type ValuerEval ¶
type ValuerEval struct { Valuer Valuer // IntegerFloatDivision will set the eval system to treat // a division between two integers as a floating point division. IntegerFloatDivision bool }
ValuerEval will evaluate an expression using the Valuer.
func (*ValuerEval) Eval ¶
func (v *ValuerEval) Eval(expr Expr) interface{}
Eval evaluates an expression and returns a value.
type WildcardValuer ¶
type WildcardValuer struct {
Data Wildcarder
}
func (*WildcardValuer) Meta ¶
func (wv *WildcardValuer) Meta(key string) (interface{}, bool)
func (*WildcardValuer) Value ¶
func (wv *WildcardValuer) Value(key string) (interface{}, bool)
TODO deal with wildcard of a stream, e.g. SELECT Table.* from Table inner join Table1
type Wildcarder ¶
type Window ¶
type Window struct { WindowType WindowType Length *IntegerLiteral Interval *IntegerLiteral Filter Expr }
type WindowTuples ¶
type WindowTuplesSet ¶
type WindowTuplesSet []WindowTuples
func (WindowTuplesSet) AddTuple ¶
func (w WindowTuplesSet) AddTuple(tuple *Tuple) WindowTuplesSet
func (WindowTuplesSet) AggregateEval ¶
func (w WindowTuplesSet) AggregateEval(expr Expr, v CallValuer) []interface{}
func (WindowTuplesSet) GetBySrc ¶
func (w WindowTuplesSet) GetBySrc(src string) []Tuple
func (WindowTuplesSet) Index ¶
func (w WindowTuplesSet) Index(i int) Valuer
func (WindowTuplesSet) Len ¶
func (w WindowTuplesSet) Len() int
func (WindowTuplesSet) Swap ¶
func (w WindowTuplesSet) Swap(i, j int)
type WindowType ¶
type WindowType int
const ( NOT_WINDOW WindowType = iota TUMBLING_WINDOW HOPPING_WINDOW SLIDING_WINDOW SESSION_WINDOW COUNT_WINDOW )