Documentation
¶
Index ¶
- Constants
- Variables
- func AddAggrFunction(f *AggrFunc)
- func AddScalarFunction(f *Function)
- func BuildExecutor(query string) (*SelectStmt, *FilterExec, error)
- func GetFuncNameFromExpr(expr Expression) (string, error)
- func IsAggrFunc(fname string) bool
- func IsAggrFuncExpr(expr Expression) bool
- func IsScalarFuncExpr(expr Expression) bool
- func NewExecuteError(pos int, msg string, args ...any) error
- func NewSyntaxError(pos int, msg string, args ...any) error
- func ScanTypeToString(tp byte) string
- type AggrFunc
- type AggrFunction
- type AggrFunctor
- type AggrPlanField
- type AggregatePlan
- func (a *AggregatePlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
- func (a *AggregatePlan) Explain() []string
- func (a *AggregatePlan) FieldNameList() []string
- func (a *AggregatePlan) FieldTypeList() []Type
- func (a *AggregatePlan) Init() error
- func (a *AggregatePlan) Next(ctx *ExecuteCtx) ([]Column, error)
- func (a *AggregatePlan) String() string
- type BinaryOpExpr
- func (e *BinaryOpExpr) Check(ctx *CheckCtx) error
- func (e *BinaryOpExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *BinaryOpExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *BinaryOpExpr) GetPos() int
- func (e *BinaryOpExpr) ReturnType() Type
- func (e *BinaryOpExpr) String() string
- func (e *BinaryOpExpr) Walk(cb WalkCallback)
- type BoolExpr
- func (e *BoolExpr) Check(ctx *CheckCtx) error
- func (e *BoolExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *BoolExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *BoolExpr) GetPos() int
- func (e *BoolExpr) ReturnType() Type
- func (e *BoolExpr) String() string
- func (e *BoolExpr) Walk(cb WalkCallback)
- type CheckCtx
- type Column
- type Cursor
- type DeletePlan
- func (p *DeletePlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
- func (p *DeletePlan) Explain() []string
- func (p *DeletePlan) FieldNameList() []string
- func (p *DeletePlan) FieldTypeList() []Type
- func (p *DeletePlan) Init() error
- func (p *DeletePlan) Next(ctx *ExecuteCtx) ([]Column, error)
- func (p *DeletePlan) String() string
- type DeleteStmt
- type EmptyResultPlan
- type ExecuteCtx
- func (c *ExecuteCtx) AdjustChunkCache(chooseIdxes []int)
- func (c *ExecuteCtx) AppendChunkFieldResult(name string, chunk []any)
- func (c *ExecuteCtx) Clear()
- func (c *ExecuteCtx) GetChunkFieldFinalResult(name string) ([]any, bool)
- func (c *ExecuteCtx) GetChunkFieldResult(name string, key []byte) ([]any, bool)
- func (c *ExecuteCtx) GetFieldResult(name string) (any, bool)
- func (c *ExecuteCtx) SetChunkFieldResult(name string, key []byte, chunk []any)
- func (c *ExecuteCtx) SetFieldResult(name string, value any)
- func (c *ExecuteCtx) UpdateHit()
- type ExecuteError
- type Expression
- type ExpressionOptimizer
- type FieldAccessExpr
- func (e *FieldAccessExpr) Check(ctx *CheckCtx) error
- func (e *FieldAccessExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *FieldAccessExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *FieldAccessExpr) GetPos() int
- func (e *FieldAccessExpr) ReturnType() Type
- func (e *FieldAccessExpr) String() string
- func (e *FieldAccessExpr) Walk(cb WalkCallback)
- type FieldExpr
- func (e *FieldExpr) Check(ctx *CheckCtx) error
- func (e *FieldExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *FieldExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *FieldExpr) GetPos() int
- func (e *FieldExpr) ReturnType() Type
- func (e *FieldExpr) String() string
- func (e *FieldExpr) Walk(cb WalkCallback)
- type FieldReferenceExpr
- func (e *FieldReferenceExpr) Check(ctx *CheckCtx) error
- func (e *FieldReferenceExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *FieldReferenceExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *FieldReferenceExpr) GetPos() int
- func (e *FieldReferenceExpr) ReturnType() Type
- func (e *FieldReferenceExpr) String() string
- func (e *FieldReferenceExpr) Walk(cb WalkCallback)
- type FilterExec
- type FilterOptimizer
- type FinalLimitPlan
- func (p *FinalLimitPlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
- func (p *FinalLimitPlan) Explain() []string
- func (p *FinalLimitPlan) FieldNameList() []string
- func (p *FinalLimitPlan) FieldTypeList() []Type
- func (p *FinalLimitPlan) Init() error
- func (p *FinalLimitPlan) Next(ctx *ExecuteCtx) ([]Column, error)
- func (p *FinalLimitPlan) String() string
- type FinalOrderPlan
- func (p *FinalOrderPlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
- func (p *FinalOrderPlan) Explain() []string
- func (p *FinalOrderPlan) FieldNameList() []string
- func (p *FinalOrderPlan) FieldTypeList() []Type
- func (p *FinalOrderPlan) Init() error
- func (p *FinalOrderPlan) Next(ctx *ExecuteCtx) ([]Column, error)
- func (p *FinalOrderPlan) String() string
- type FinalPlan
- type FloatExpr
- func (e *FloatExpr) Check(ctx *CheckCtx) error
- func (e *FloatExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *FloatExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *FloatExpr) GetPos() int
- func (e *FloatExpr) ReturnType() Type
- func (e *FloatExpr) String() string
- func (e *FloatExpr) Walk(cb WalkCallback)
- type FullScanPlan
- type Function
- type FunctionBody
- type FunctionCallExpr
- func (e *FunctionCallExpr) Check(ctx *CheckCtx) error
- func (e *FunctionCallExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *FunctionCallExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *FunctionCallExpr) GetPos() int
- func (e *FunctionCallExpr) ReturnType() Type
- func (e *FunctionCallExpr) String() string
- func (e *FunctionCallExpr) Walk(cb WalkCallback)
- type GroupByField
- type GroupByStmt
- type JSON
- type KVKeyword
- type KVPair
- type Lexer
- type LimitPlan
- type LimitStmt
- type ListExpr
- func (e *ListExpr) Check(ctx *CheckCtx) error
- func (e *ListExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *ListExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *ListExpr) GetPos() int
- func (e *ListExpr) ReturnType() Type
- func (e *ListExpr) String() string
- func (e *ListExpr) Walk(cb WalkCallback)
- type MultiGetPlan
- type NameExpr
- func (e *NameExpr) Check(ctx *CheckCtx) error
- func (e *NameExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *NameExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *NameExpr) GetPos() int
- func (e *NameExpr) ReturnType() Type
- func (e *NameExpr) String() string
- func (e *NameExpr) Walk(cb WalkCallback)
- type NotExpr
- func (e *NotExpr) Check(ctx *CheckCtx) error
- func (e *NotExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *NotExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *NotExpr) GetPos() int
- func (e *NotExpr) ReturnType() Type
- func (e *NotExpr) String() string
- func (e *NotExpr) Walk(cb WalkCallback)
- type NumberExpr
- func (e *NumberExpr) Check(ctx *CheckCtx) error
- func (e *NumberExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *NumberExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *NumberExpr) GetPos() int
- func (e *NumberExpr) ReturnType() Type
- func (e *NumberExpr) String() string
- func (e *NumberExpr) Walk(cb WalkCallback)
- type Operator
- type Optimizer
- type OrderField
- type OrderStmt
- type Parser
- type Plan
- func NewEmptyResultPlan(s Storage, f *FilterExec) Plan
- func NewFullScanPlan(s Storage, f *FilterExec) Plan
- func NewMultiGetPlan(s Storage, f *FilterExec, keys []string) Plan
- func NewPrefixScanPlan(s Storage, f *FilterExec, p string) Plan
- func NewRangeScanPlan(s Storage, f *FilterExec, start []byte, end []byte) Plan
- type PrefixScanPlan
- type ProjectionPlan
- func (p *ProjectionPlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
- func (p *ProjectionPlan) Explain() []string
- func (p *ProjectionPlan) FieldNameList() []string
- func (p *ProjectionPlan) FieldTypeList() []Type
- func (p *ProjectionPlan) Init() error
- func (p *ProjectionPlan) Next(ctx *ExecuteCtx) ([]Column, error)
- func (p *ProjectionPlan) String() string
- type PutKVPair
- type PutPlan
- func (p *PutPlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
- func (p *PutPlan) Explain() []string
- func (p *PutPlan) FieldNameList() []string
- func (p *PutPlan) FieldTypeList() []Type
- func (p *PutPlan) Init() error
- func (p *PutPlan) Next(ctx *ExecuteCtx) ([]Column, error)
- func (p *PutPlan) String() string
- type PutStmt
- type QueryBinder
- type RangeScanPlan
- type RemovePlan
- func (p *RemovePlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
- func (p *RemovePlan) Explain() []string
- func (p *RemovePlan) FieldNameList() []string
- func (p *RemovePlan) FieldTypeList() []Type
- func (p *RemovePlan) Init() error
- func (p *RemovePlan) Next(ctx *ExecuteCtx) ([]Column, error)
- func (p *RemovePlan) String() string
- type RemoveStmt
- type ScanType
- type SelectStmt
- type Statement
- type Storage
- type StringExpr
- func (e *StringExpr) Check(ctx *CheckCtx) error
- func (e *StringExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
- func (e *StringExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
- func (e *StringExpr) GetPos() int
- func (e *StringExpr) ReturnType() Type
- func (e *StringExpr) String() string
- func (e *StringExpr) Walk(cb WalkCallback)
- type SyntaxError
- type Token
- type TokenType
- type Type
- type VectorFunctionBody
- type WalkCallback
- type WhereStmt
Constants ¶
View Source
const ( KeyKW KVKeyword = 1 ValueKW KVKeyword = 2 Unknown Operator = 0 And Operator = 1 Or Operator = 2 Not Operator = 3 Eq Operator = 4 NotEq Operator = 5 PrefixMatch Operator = 6 RegExpMatch Operator = 7 Add Operator = 8 Sub Operator = 9 Mul Operator = 10 Div Operator = 11 Gt Operator = 12 Gte Operator = 13 Lt Operator = 14 Lte Operator = 15 In Operator = 16 Between Operator = 17 KWAnd Operator = 18 KWOr Operator = 19 TUNKNOWN Type = 0 TBOOL Type = 1 TSTR Type = 2 TNUMBER Type = 3 TIDENT Type = 4 TLIST Type = 5 TJSON Type = 6 )
* Scan Type is priority of scan operator * Lower value operator means the result set is smaller than higher value operator
View Source
const ( LowestPrec = 0 // non-operators UnaryPrec = 6 HighestPrec = 7 )
View Source
const MaxNestLevel = 1e5
Variables ¶
View Source
var ( KVKeywordToString = map[KVKeyword]string{ KeyKW: "KEY", ValueKW: "VALUE", } OperatorToString = map[Operator]string{ Eq: "=", NotEq: "!=", And: "&", Or: "|", Not: "!", PrefixMatch: "^=", RegExpMatch: "~=", Add: "+", Sub: "-", Mul: "*", Div: "/", Gt: ">", Gte: ">=", Lt: "<", Lte: "<=", In: "in", Between: "between", KWAnd: "and", KWOr: "or", } StringToOperator = map[string]Operator{ "=": Eq, "&": And, "|": Or, "!": Not, "^=": PrefixMatch, "~=": RegExpMatch, "!=": NotEq, "+": Add, "-": Sub, "*": Mul, "/": Div, ">": Gt, ">=": Gte, "<": Lt, "<=": Lte, "in": In, "between": Between, "and": KWAnd, "or": KWOr, } )
View Source
var ( PlanBatchSize = 32 EnableFieldCache = true )
View Source
var (
DefaultErrorPadding = 7
)
View Source
var ( TokenTypeToString = map[TokenType]string{ SELECT: "SELECT", WHERE: "WHERE", KEY: "KEY", VALUE: "VALUE", OPERATOR: "OP", STRING: "STR", LPAREN: "(", RPAREN: ")", NAME: "NAME", SEP: "SEP", NUMBER: "NUM", FLOAT: "FLOAT", LIMIT: "LIMIT", ORDER: "ORDER", BY: "BY", ASC: "ASC", DESC: "DESC", TRUE: "true", FALSE: "false", AS: "AS", GROUP: "GROUP", IN: "IN", BETWEEN: "BETWEEN", AND: "AND", LBRACK: "[", RBRACK: "]", PUT: "PUT", REMOVE: "REMOVE", SEMI: "SEMI", OR: "OR", DELETE: "DELETE", } )
Functions ¶
func AddAggrFunction ¶
func AddAggrFunction(f *AggrFunc)
func AddScalarFunction ¶
func AddScalarFunction(f *Function)
func BuildExecutor ¶
func BuildExecutor(query string) (*SelectStmt, *FilterExec, error)
func GetFuncNameFromExpr ¶
func GetFuncNameFromExpr(expr Expression) (string, error)
func IsAggrFunc ¶
func IsAggrFuncExpr ¶
func IsAggrFuncExpr(expr Expression) bool
func IsScalarFuncExpr ¶
func IsScalarFuncExpr(expr Expression) bool
func ScanTypeToString ¶
Types ¶
type AggrFunc ¶
type AggrFunc struct { Name string NumArgs int VarArgs bool ReturnType Type Body AggrFunctor }
func GetAggrFunctionByName ¶
type AggrFunction ¶
type AggrFunction interface { Update(kv KVPair, args []Expression, ctx *ExecuteCtx) error Complete() (any, error) Clone() AggrFunction }
type AggrFunctor ¶
type AggrFunctor func(args []Expression) (AggrFunction, error)
type AggrPlanField ¶
type AggrPlanField struct { ID int Name string IsKey bool Expr Expression FuncExprs []*FunctionCallExpr Funcs []AggrFunction Value Column }
type AggregatePlan ¶
type AggregatePlan struct { Storage Storage ChildPlan Plan FieldNames []string FieldTypes []Type Fields []Expression GroupByFields []GroupByField AggrAll bool Limit int Start int // contains filtered or unexported fields }
func (*AggregatePlan) Batch ¶
func (a *AggregatePlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
func (*AggregatePlan) Explain ¶
func (a *AggregatePlan) Explain() []string
func (*AggregatePlan) FieldNameList ¶
func (a *AggregatePlan) FieldNameList() []string
func (*AggregatePlan) FieldTypeList ¶
func (a *AggregatePlan) FieldTypeList() []Type
func (*AggregatePlan) Init ¶
func (a *AggregatePlan) Init() error
func (*AggregatePlan) Next ¶
func (a *AggregatePlan) Next(ctx *ExecuteCtx) ([]Column, error)
func (*AggregatePlan) String ¶
func (a *AggregatePlan) String() string
type BinaryOpExpr ¶
type BinaryOpExpr struct { Pos int Op Operator Left Expression Right Expression }
func (*BinaryOpExpr) Check ¶
func (e *BinaryOpExpr) Check(ctx *CheckCtx) error
func (*BinaryOpExpr) Execute ¶
func (e *BinaryOpExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
func (*BinaryOpExpr) ExecuteBatch ¶
func (e *BinaryOpExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*BinaryOpExpr) GetPos ¶
func (e *BinaryOpExpr) GetPos() int
func (*BinaryOpExpr) ReturnType ¶
func (e *BinaryOpExpr) ReturnType() Type
func (*BinaryOpExpr) String ¶
func (e *BinaryOpExpr) String() string
func (*BinaryOpExpr) Walk ¶
func (e *BinaryOpExpr) Walk(cb WalkCallback)
type BoolExpr ¶
func (*BoolExpr) ExecuteBatch ¶
func (e *BoolExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*BoolExpr) ReturnType ¶
func (*BoolExpr) Walk ¶
func (e *BoolExpr) Walk(cb WalkCallback)
type CheckCtx ¶
type CheckCtx struct { Fields []Expression FieldNames []string FieldTypes []Type NotAllowKey bool NotAllowValue bool }
func (*CheckCtx) GetNamedExpr ¶
func (c *CheckCtx) GetNamedExpr(name string) (Expression, bool)
type DeletePlan ¶
func (*DeletePlan) Batch ¶
func (p *DeletePlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
func (*DeletePlan) Explain ¶
func (p *DeletePlan) Explain() []string
func (*DeletePlan) FieldNameList ¶
func (p *DeletePlan) FieldNameList() []string
func (*DeletePlan) FieldTypeList ¶
func (p *DeletePlan) FieldTypeList() []Type
func (*DeletePlan) Init ¶
func (p *DeletePlan) Init() error
func (*DeletePlan) Next ¶
func (p *DeletePlan) Next(ctx *ExecuteCtx) ([]Column, error)
func (*DeletePlan) String ¶
func (p *DeletePlan) String() string
type DeleteStmt ¶
func (*DeleteStmt) Name ¶
func (s *DeleteStmt) Name() string
func (*DeleteStmt) Validate ¶
func (s *DeleteStmt) Validate(ctx *CheckCtx) error
type EmptyResultPlan ¶
type EmptyResultPlan struct {
Storage Storage
}
func (*EmptyResultPlan) Batch ¶
func (p *EmptyResultPlan) Batch(ctx *ExecuteCtx) ([]KVPair, error)
func (*EmptyResultPlan) Explain ¶
func (p *EmptyResultPlan) Explain() []string
func (*EmptyResultPlan) Init ¶
func (p *EmptyResultPlan) Init() error
func (*EmptyResultPlan) Next ¶
func (p *EmptyResultPlan) Next(ctx *ExecuteCtx) ([]byte, []byte, error)
func (*EmptyResultPlan) String ¶
func (p *EmptyResultPlan) String() string
type ExecuteCtx ¶
type ExecuteCtx struct { Hit int EnableCache bool FieldCaches map[string]any FieldChunkKeyCaches map[string][]any FieldChunkCaches map[string][]any }
func NewExecuteCtx ¶
func NewExecuteCtx() *ExecuteCtx
func (*ExecuteCtx) AdjustChunkCache ¶
func (c *ExecuteCtx) AdjustChunkCache(chooseIdxes []int)
func (*ExecuteCtx) AppendChunkFieldResult ¶
func (c *ExecuteCtx) AppendChunkFieldResult(name string, chunk []any)
func (*ExecuteCtx) Clear ¶
func (c *ExecuteCtx) Clear()
func (*ExecuteCtx) GetChunkFieldFinalResult ¶
func (c *ExecuteCtx) GetChunkFieldFinalResult(name string) ([]any, bool)
func (*ExecuteCtx) GetChunkFieldResult ¶
func (c *ExecuteCtx) GetChunkFieldResult(name string, key []byte) ([]any, bool)
func (*ExecuteCtx) GetFieldResult ¶
func (c *ExecuteCtx) GetFieldResult(name string) (any, bool)
func (*ExecuteCtx) SetChunkFieldResult ¶
func (c *ExecuteCtx) SetChunkFieldResult(name string, key []byte, chunk []any)
func (*ExecuteCtx) SetFieldResult ¶
func (c *ExecuteCtx) SetFieldResult(name string, value any)
func (*ExecuteCtx) UpdateHit ¶
func (c *ExecuteCtx) UpdateHit()
type ExecuteError ¶
func (*ExecuteError) BindQuery ¶
func (e *ExecuteError) BindQuery(query string)
func (*ExecuteError) Error ¶
func (e *ExecuteError) Error() string
func (*ExecuteError) SetPadding ¶
func (e *ExecuteError) SetPadding(pad int)
type Expression ¶
type Expression interface { Check(ctx *CheckCtx) error String() string Execute(kv KVPair, ctx *ExecuteCtx) (any, error) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error) ReturnType() Type GetPos() int Walk(cb WalkCallback) }
type ExpressionOptimizer ¶
type ExpressionOptimizer struct { Root Expression // contains filtered or unexported fields }
func (*ExpressionOptimizer) Optimize ¶
func (o *ExpressionOptimizer) Optimize() Expression
type FieldAccessExpr ¶
type FieldAccessExpr struct { Pos int Left Expression FieldName Expression }
func (*FieldAccessExpr) Check ¶
func (e *FieldAccessExpr) Check(ctx *CheckCtx) error
func (*FieldAccessExpr) Execute ¶
func (e *FieldAccessExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
func (*FieldAccessExpr) ExecuteBatch ¶
func (e *FieldAccessExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*FieldAccessExpr) GetPos ¶
func (e *FieldAccessExpr) GetPos() int
func (*FieldAccessExpr) ReturnType ¶
func (e *FieldAccessExpr) ReturnType() Type
func (*FieldAccessExpr) String ¶
func (e *FieldAccessExpr) String() string
func (*FieldAccessExpr) Walk ¶
func (e *FieldAccessExpr) Walk(cb WalkCallback)
type FieldExpr ¶
func (*FieldExpr) ExecuteBatch ¶
func (e *FieldExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*FieldExpr) ReturnType ¶
func (*FieldExpr) Walk ¶
func (e *FieldExpr) Walk(cb WalkCallback)
type FieldReferenceExpr ¶
type FieldReferenceExpr struct { Name *NameExpr FieldExpr Expression }
func (*FieldReferenceExpr) Check ¶
func (e *FieldReferenceExpr) Check(ctx *CheckCtx) error
func (*FieldReferenceExpr) Execute ¶
func (e *FieldReferenceExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
func (*FieldReferenceExpr) ExecuteBatch ¶
func (e *FieldReferenceExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*FieldReferenceExpr) GetPos ¶
func (e *FieldReferenceExpr) GetPos() int
func (*FieldReferenceExpr) ReturnType ¶
func (e *FieldReferenceExpr) ReturnType() Type
func (*FieldReferenceExpr) String ¶
func (e *FieldReferenceExpr) String() string
func (*FieldReferenceExpr) Walk ¶
func (e *FieldReferenceExpr) Walk(cb WalkCallback)
type FilterExec ¶
type FilterExec struct {
Ast *WhereStmt
}
func (*FilterExec) Explain ¶
func (e *FilterExec) Explain() string
func (*FilterExec) Filter ¶
func (e *FilterExec) Filter(kvp KVPair, ctx *ExecuteCtx) (bool, error)
func (*FilterExec) FilterBatch ¶
func (e *FilterExec) FilterBatch(chunk []KVPair, ctx *ExecuteCtx) ([]bool, error)
type FilterOptimizer ¶
type FilterOptimizer struct {
// contains filtered or unexported fields
}
func NewFilterOptimizer ¶
func NewFilterOptimizer(ast *WhereStmt, s Storage, filter *FilterExec) *FilterOptimizer
func (*FilterOptimizer) Optimize ¶
func (o *FilterOptimizer) Optimize() Plan
type FinalLimitPlan ¶
type FinalLimitPlan struct { Storage Storage Start int Count int ChildPlan FinalPlan FieldNames []string FieldTypes []Type // contains filtered or unexported fields }
func (*FinalLimitPlan) Batch ¶
func (p *FinalLimitPlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
func (*FinalLimitPlan) Explain ¶
func (p *FinalLimitPlan) Explain() []string
func (*FinalLimitPlan) FieldNameList ¶
func (p *FinalLimitPlan) FieldNameList() []string
func (*FinalLimitPlan) FieldTypeList ¶
func (p *FinalLimitPlan) FieldTypeList() []Type
func (*FinalLimitPlan) Init ¶
func (p *FinalLimitPlan) Init() error
func (*FinalLimitPlan) Next ¶
func (p *FinalLimitPlan) Next(ctx *ExecuteCtx) ([]Column, error)
func (*FinalLimitPlan) String ¶
func (p *FinalLimitPlan) String() string
type FinalOrderPlan ¶
type FinalOrderPlan struct { Storage Storage Orders []OrderField FieldNames []string FieldTypes []Type ChildPlan FinalPlan // contains filtered or unexported fields }
func (*FinalOrderPlan) Batch ¶
func (p *FinalOrderPlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
func (*FinalOrderPlan) Explain ¶
func (p *FinalOrderPlan) Explain() []string
func (*FinalOrderPlan) FieldNameList ¶
func (p *FinalOrderPlan) FieldNameList() []string
func (*FinalOrderPlan) FieldTypeList ¶
func (p *FinalOrderPlan) FieldTypeList() []Type
func (*FinalOrderPlan) Init ¶
func (p *FinalOrderPlan) Init() error
func (*FinalOrderPlan) Next ¶
func (p *FinalOrderPlan) Next(ctx *ExecuteCtx) ([]Column, error)
func (*FinalOrderPlan) String ¶
func (p *FinalOrderPlan) String() string
type FloatExpr ¶
func (*FloatExpr) ExecuteBatch ¶
func (e *FloatExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*FloatExpr) ReturnType ¶
func (*FloatExpr) Walk ¶
func (e *FloatExpr) Walk(cb WalkCallback)
type FullScanPlan ¶
type FullScanPlan struct { Storage Storage Filter *FilterExec // contains filtered or unexported fields }
func (*FullScanPlan) Batch ¶
func (p *FullScanPlan) Batch(ctx *ExecuteCtx) ([]KVPair, error)
func (*FullScanPlan) Explain ¶
func (p *FullScanPlan) Explain() []string
func (*FullScanPlan) Init ¶
func (p *FullScanPlan) Init() (err error)
func (*FullScanPlan) Next ¶
func (p *FullScanPlan) Next(ctx *ExecuteCtx) ([]byte, []byte, error)
func (*FullScanPlan) String ¶
func (p *FullScanPlan) String() string
type Function ¶
type Function struct { Name string NumArgs int VarArgs bool ReturnType Type Body FunctionBody BodyVec VectorFunctionBody }
func GetScalarFunction ¶
func GetScalarFunction(expr Expression) (*Function, error)
func GetScalarFunctionByName ¶
type FunctionBody ¶
type FunctionBody func(kv KVPair, args []Expression, ctx *ExecuteCtx) (any, error)
type FunctionCallExpr ¶
type FunctionCallExpr struct { Pos int Name Expression Args []Expression Result any }
func (*FunctionCallExpr) Check ¶
func (e *FunctionCallExpr) Check(ctx *CheckCtx) error
func (*FunctionCallExpr) Execute ¶
func (e *FunctionCallExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
func (*FunctionCallExpr) ExecuteBatch ¶
func (e *FunctionCallExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*FunctionCallExpr) GetPos ¶
func (e *FunctionCallExpr) GetPos() int
func (*FunctionCallExpr) ReturnType ¶
func (e *FunctionCallExpr) ReturnType() Type
func (*FunctionCallExpr) String ¶
func (e *FunctionCallExpr) String() string
func (*FunctionCallExpr) Walk ¶
func (e *FunctionCallExpr) Walk(cb WalkCallback)
type GroupByField ¶
type GroupByField struct { Name string Expr Expression }
type GroupByStmt ¶
type GroupByStmt struct { Pos int Fields []GroupByField }
func (*GroupByStmt) Name ¶
func (s *GroupByStmt) Name() string
type LimitPlan ¶
type ListExpr ¶
type ListExpr struct { Pos int List []Expression }
func (*ListExpr) ExecuteBatch ¶
func (e *ListExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*ListExpr) ReturnType ¶
func (*ListExpr) Walk ¶
func (e *ListExpr) Walk(cb WalkCallback)
type MultiGetPlan ¶
type MultiGetPlan struct { Storage Storage Filter *FilterExec Keys []string // contains filtered or unexported fields }
func (*MultiGetPlan) Batch ¶
func (p *MultiGetPlan) Batch(ctx *ExecuteCtx) ([]KVPair, error)
func (*MultiGetPlan) Explain ¶
func (p *MultiGetPlan) Explain() []string
func (*MultiGetPlan) Init ¶
func (p *MultiGetPlan) Init() error
func (*MultiGetPlan) Next ¶
func (p *MultiGetPlan) Next(ctx *ExecuteCtx) ([]byte, []byte, error)
func (*MultiGetPlan) String ¶
func (p *MultiGetPlan) String() string
type NameExpr ¶
func (*NameExpr) ExecuteBatch ¶
func (e *NameExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*NameExpr) ReturnType ¶
func (*NameExpr) Walk ¶
func (e *NameExpr) Walk(cb WalkCallback)
type NotExpr ¶
type NotExpr struct { Pos int Right Expression }
func (*NotExpr) ExecuteBatch ¶
func (e *NotExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*NotExpr) ReturnType ¶
func (*NotExpr) Walk ¶
func (e *NotExpr) Walk(cb WalkCallback)
type NumberExpr ¶
func (*NumberExpr) Check ¶
func (e *NumberExpr) Check(ctx *CheckCtx) error
func (*NumberExpr) Execute ¶
func (e *NumberExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
func (*NumberExpr) ExecuteBatch ¶
func (e *NumberExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*NumberExpr) GetPos ¶
func (e *NumberExpr) GetPos() int
func (*NumberExpr) ReturnType ¶
func (e *NumberExpr) ReturnType() Type
func (*NumberExpr) String ¶
func (e *NumberExpr) String() string
func (*NumberExpr) Walk ¶
func (e *NumberExpr) Walk(cb WalkCallback)
type Optimizer ¶
type Optimizer struct { Query string // contains filtered or unexported fields }
func NewOptimizer ¶
type OrderField ¶
type OrderField struct { Name string Field Expression Order TokenType }
type OrderStmt ¶
type OrderStmt struct { Pos int Orders []OrderField }
type Plan ¶
type Plan interface { String() string Explain() []string Init() error Next(ctx *ExecuteCtx) (key []byte, value []byte, err error) Batch(ctx *ExecuteCtx) (rows []KVPair, err error) }
func NewEmptyResultPlan ¶
func NewEmptyResultPlan(s Storage, f *FilterExec) Plan
func NewFullScanPlan ¶
func NewFullScanPlan(s Storage, f *FilterExec) Plan
func NewMultiGetPlan ¶
func NewMultiGetPlan(s Storage, f *FilterExec, keys []string) Plan
func NewPrefixScanPlan ¶
func NewPrefixScanPlan(s Storage, f *FilterExec, p string) Plan
func NewRangeScanPlan ¶
func NewRangeScanPlan(s Storage, f *FilterExec, start []byte, end []byte) Plan
type PrefixScanPlan ¶
type PrefixScanPlan struct { Storage Storage Filter *FilterExec Prefix string // contains filtered or unexported fields }
func (*PrefixScanPlan) Batch ¶
func (p *PrefixScanPlan) Batch(ctx *ExecuteCtx) ([]KVPair, error)
func (*PrefixScanPlan) Explain ¶
func (p *PrefixScanPlan) Explain() []string
func (*PrefixScanPlan) Init ¶
func (p *PrefixScanPlan) Init() (err error)
func (*PrefixScanPlan) Next ¶
func (p *PrefixScanPlan) Next(ctx *ExecuteCtx) ([]byte, []byte, error)
func (*PrefixScanPlan) String ¶
func (p *PrefixScanPlan) String() string
type ProjectionPlan ¶
type ProjectionPlan struct { Storage Storage ChildPlan Plan AllFields bool FieldNames []string FieldTypes []Type Fields []Expression }
func (*ProjectionPlan) Batch ¶
func (p *ProjectionPlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
func (*ProjectionPlan) Explain ¶
func (p *ProjectionPlan) Explain() []string
func (*ProjectionPlan) FieldNameList ¶
func (p *ProjectionPlan) FieldNameList() []string
func (*ProjectionPlan) FieldTypeList ¶
func (p *ProjectionPlan) FieldTypeList() []Type
func (*ProjectionPlan) Init ¶
func (p *ProjectionPlan) Init() error
func (*ProjectionPlan) Next ¶
func (p *ProjectionPlan) Next(ctx *ExecuteCtx) ([]Column, error)
func (*ProjectionPlan) String ¶
func (p *ProjectionPlan) String() string
type PutKVPair ¶
type PutKVPair struct { Key Expression Value Expression }
type PutPlan ¶
type PutPlan struct { Storage Storage KVPairs []*PutKVPair // contains filtered or unexported fields }
func (*PutPlan) FieldNameList ¶
func (*PutPlan) FieldTypeList ¶
type QueryBinder ¶
type RangeScanPlan ¶
type RangeScanPlan struct { Storage Storage Filter *FilterExec Start []byte End []byte // contains filtered or unexported fields }
func (*RangeScanPlan) Batch ¶
func (p *RangeScanPlan) Batch(ctx *ExecuteCtx) ([]KVPair, error)
func (*RangeScanPlan) Explain ¶
func (p *RangeScanPlan) Explain() []string
func (*RangeScanPlan) Init ¶
func (p *RangeScanPlan) Init() (err error)
func (*RangeScanPlan) Next ¶
func (p *RangeScanPlan) Next(ctx *ExecuteCtx) ([]byte, []byte, error)
func (*RangeScanPlan) String ¶
func (p *RangeScanPlan) String() string
type RemovePlan ¶
type RemovePlan struct { Storage Storage Keys []Expression // contains filtered or unexported fields }
func (*RemovePlan) Batch ¶
func (p *RemovePlan) Batch(ctx *ExecuteCtx) ([][]Column, error)
func (*RemovePlan) Explain ¶
func (p *RemovePlan) Explain() []string
func (*RemovePlan) FieldNameList ¶
func (p *RemovePlan) FieldNameList() []string
func (*RemovePlan) FieldTypeList ¶
func (p *RemovePlan) FieldTypeList() []Type
func (*RemovePlan) Init ¶
func (p *RemovePlan) Init() error
func (*RemovePlan) Next ¶
func (p *RemovePlan) Next(ctx *ExecuteCtx) ([]Column, error)
func (*RemovePlan) String ¶
func (p *RemovePlan) String() string
type RemoveStmt ¶
type RemoveStmt struct { Pos int Keys []Expression }
func (*RemoveStmt) Name ¶
func (s *RemoveStmt) Name() string
func (*RemoveStmt) Validate ¶
func (s *RemoveStmt) Validate(ctx *CheckCtx) error
type SelectStmt ¶
type SelectStmt struct { Pos int AllFields bool FieldNames []string FieldTypes []Type Fields []Expression Where *WhereStmt Order *OrderStmt Limit *LimitStmt GroupBy *GroupByStmt }
func (*SelectStmt) Name ¶
func (s *SelectStmt) Name() string
func (*SelectStmt) ValidateFields ¶
func (s *SelectStmt) ValidateFields(ctx *CheckCtx) error
type StringExpr ¶
func (*StringExpr) Check ¶
func (e *StringExpr) Check(ctx *CheckCtx) error
func (*StringExpr) Execute ¶
func (e *StringExpr) Execute(kv KVPair, ctx *ExecuteCtx) (any, error)
func (*StringExpr) ExecuteBatch ¶
func (e *StringExpr) ExecuteBatch(chunk []KVPair, ctx *ExecuteCtx) ([]any, error)
func (*StringExpr) GetPos ¶
func (e *StringExpr) GetPos() int
func (*StringExpr) ReturnType ¶
func (e *StringExpr) ReturnType() Type
func (*StringExpr) String ¶
func (e *StringExpr) String() string
func (*StringExpr) Walk ¶
func (e *StringExpr) Walk(cb WalkCallback)
type SyntaxError ¶
func (*SyntaxError) BindQuery ¶
func (e *SyntaxError) BindQuery(query string)
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
func (*SyntaxError) SetPadding ¶
func (e *SyntaxError) SetPadding(pad int)
type Token ¶
func (*Token) Precedence ¶
type TokenType ¶
type TokenType byte
const ( SELECT TokenType = 1 WHERE TokenType = 2 KEY TokenType = 3 VALUE TokenType = 4 OPERATOR TokenType = 5 STRING TokenType = 6 LPAREN TokenType = 7 RPAREN TokenType = 8 NAME TokenType = 9 SEP TokenType = 10 NUMBER TokenType = 11 FLOAT TokenType = 12 LIMIT TokenType = 13 ORDER TokenType = 14 BY TokenType = 15 ASC TokenType = 16 DESC TokenType = 17 TRUE TokenType = 18 FALSE TokenType = 19 AS TokenType = 20 GROUP TokenType = 21 IN TokenType = 22 BETWEEN TokenType = 23 AND TokenType = 24 LBRACK TokenType = 25 RBRACK TokenType = 26 PUT TokenType = 27 REMOVE TokenType = 28 SEMI TokenType = 29 OR TokenType = 30 DELETE TokenType = 31 )
type VectorFunctionBody ¶
type VectorFunctionBody func(chunk []KVPair, args []Expression, ctx *ExecuteCtx) ([]any, error)
type WalkCallback ¶
type WalkCallback func(e Expression) bool
Source Files
¶
- aggr_func.go
- aggregate_plan.go
- checker.go
- delete_plan.go
- errors.go
- expression.go
- expression_exec.go
- expression_exec_vec.go
- expression_optimizer.go
- filter_optimizer.go
- func.go
- kv.go
- lexer.go
- limit_plan.go
- optimizer.go
- order_plan.go
- parser.go
- plan.go
- projection_plan.go
- put_plan.go
- remove_plan.go
- scalar_func.go
- scalar_func_vec.go
- scan_plan.go
- statement.go
- utils.go
- walker.go
Click to show internal directories.
Click to hide internal directories.