filter

package
v1.1.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Code generated by goyacc -l -o gram_y.go gram.y. DO NOT EDIT.

Index

Constants

View Source
const (
	FillNil int = iota + 1
	FillInt
	FillFloat
	FillStr
	FillLinear
	FillPrevious
)
View Source
const (
	Digits    = "0123456789"
	HexDigits = "0123456789abcdefABCDEF"
)
View Source
const ADD = 57368
View Source
const AND = 57394
View Source
const AS = 57381
View Source
const ASC = 57382
View Source
const AUTO = 57383
View Source
const BY = 57384
View Source
const COLON = 57347
View Source
const COMMA = 57349
View Source
const COMMENT = 57350
View Source
const DESC = 57387
View Source
const DIV = 57369
View Source
const DOT = 57366
View Source
const DURATION = 57351
View Source
const EOF = 57352
View Source
const EQ = 57346
View Source
const ERROR = 57353
View Source
const FALSE = 57389
View Source
const FILTER = 57390
View Source
const FLOAT = 57406
View Source
const GT = 57371
View Source
const GTE = 57370
View Source
const ID = 57354
View Source
const IDENTIFIER = 57391
View Source
const IN = 57392
View Source
const INT = 57405
View Source
const LEFT_BRACE = 57355
View Source
const LEFT_BRACKET = 57356
View Source
const LEFT_PAREN = 57357
View Source
const LIMIT = 57396
View Source
const LINK = 57395
View Source
const LT = 57372
View Source
const LTE = 57373
View Source
const MATCH = 57385
View Source
const MOD = 57374
View Source
const MUL = 57375
View Source
const NAMESPACE = 57365
View Source
const NEQ = 57376
View Source
const NIL = 57399
View Source
const NOT_IN = 57393
View Source
const NOT_MATCH = 57386
View Source
const NULL = 57400
View Source
const NUMBER = 57358
View Source
const (
	Nil = "nil"
)
View Source
const OFFSET = 57401
View Source
const OR = 57398
View Source
const ORDER = 57403
View Source
const POINT = 57407
View Source
const POW = 57377
View Source
const QUOTED_STRING = 57364
View Source
const RE = 57404
View Source
const RIGHT_BRACE = 57359
View Source
const RIGHT_BRACKET = 57360
View Source
const RIGHT_PAREN = 57361
View Source
const SEMICOLON = 57348
View Source
const SLIMIT = 57397
View Source
const SOFFSET = 57402
View Source
const SPACE = 57362
View Source
const START_BINARY_EXPRESSION = 57413
View Source
const START_FUNC_EXPRESSION = 57414
View Source
const START_STMTS = 57412
View Source
const START_WHERE_CONDITION = 57415
View Source
const STRING = 57363
View Source
const SUB = 57378
View Source
const TIMEZONE = 57408
View Source
const TRUE = 57388
View Source
const WITH = 57409

Variables

View Source
var (
	ItemTypeStr = map[ItemType]string{
		LEFT_PAREN:    "(",
		RIGHT_PAREN:   ")",
		LEFT_BRACE:    "{",
		RIGHT_BRACE:   "}",
		LEFT_BRACKET:  "[",
		RIGHT_BRACKET: "]",
		COMMA:         ",",
		EQ:            "=",
		COLON:         ":",
		SEMICOLON:     ";",
		SPACE:         "<space>",
		DOT:           ".",
		NAMESPACE:     "::",

		SUB: "-",
		ADD: "+",
		MUL: "*",
		MOD: "%",
		DIV: "/",
		NEQ: "!=",
		LTE: "<=",
		LT:  "<",
		GTE: ">=",
		GT:  ">",
		POW: "^",
		AND: "&&",
		OR:  "||",
	}
)

Functions

func Init

func Init()

Types

type Anonymous

type Anonymous struct{}

func (*Anonymous) Pos

func (n *Anonymous) Pos() *PositionRange

func (*Anonymous) String

func (n *Anonymous) String() string

type AttrExpr

type AttrExpr struct {
	Obj  Node `json:"object,omitempty"`
	Attr Node `json:"attr,omitempty"`
}

func (*AttrExpr) Pos

func (n *AttrExpr) Pos() *PositionRange

func (*AttrExpr) String

func (n *AttrExpr) String() string

type BinaryExpr

type BinaryExpr struct {
	Op         ItemType `json:"operator,omitempty"`
	LHS        Node     `json:"left,omitempty"`
	RHS        Node     `json:"right,omitempty"`
	ReturnBool bool     `json:"-"`
}

func (*BinaryExpr) DQLExpr

func (e *BinaryExpr) DQLExpr()

func (*BinaryExpr) Eval

func (e *BinaryExpr) Eval(data KVs) bool

func (*BinaryExpr) Pos

func (e *BinaryExpr) Pos() *PositionRange

func (*BinaryExpr) String

func (e *BinaryExpr) String() string

func (*BinaryExpr) Type

func (e *BinaryExpr) Type() ValueType

type BoolLiteral

type BoolLiteral struct {
	Val bool `json:"val,omitempty"`
}

func (*BoolLiteral) Pos

func (n *BoolLiteral) Pos() *PositionRange

func (*BoolLiteral) String

func (n *BoolLiteral) String() string

type CascadeFunctions

type CascadeFunctions struct {
	Funcs []*FuncExpr `json:"function_list,omitempty"`
}

func (*CascadeFunctions) Pos

func (n *CascadeFunctions) Pos() *PositionRange

func (*CascadeFunctions) String

func (n *CascadeFunctions) String() string

type DFQuery

type DFQuery struct {

	// data source
	Names          []string  `json:"names,omitempty"`
	RegexNames     []*Regex  `json:"regex_names,omitempty"`
	Targets        []*Target `json:"targets,omitempty"`
	WhereCondition []Node    `json:"where_condition,omitempty"`

	Namespace string `json:"namespace,omitempty"`

	Subquery *DFQuery `json:"subquery,omitempty"`

	GroupBy     *GroupBy     `json:"groupby,omitempty"`
	OrderBy     *OrderBy     `json:"orderby,omitempty"`
	Limit       *Limit       `json:"limit,omitempty"`
	Offset      *Offset      `json:"offset,omitempty"`
	SLimit      *SLimit      `json:"slimit,omitempty"`
	SOffset     *SOffset     `json:"soffset,omitempty"`
	TimeZone    *TimeZone    `json:"timezone,omitempty"`
	SearchAfter *SearchAfter `json:"search_after,omitempty"` // search_after
	Helper      *Helper      `json:"-"`

	Anonymous bool `json:"-"`
	Highlight bool `json:"highlight,omitempty"`
}

func (*DFQuery) From

func (m *DFQuery) From() string

func (*DFQuery) GroupByList

func (m *DFQuery) GroupByList() []string

func (*DFQuery) IsAllTargets

func (m *DFQuery) IsAllTargets() bool

IsAllTargets 未指定 target 或为手动填写 "*",即 ALL,like SELECT * FROM XX.

func (*DFQuery) IsMatchTargetsNum

func (m *DFQuery) IsMatchTargetsNum(num int) bool

func (*DFQuery) JSON

func (m *DFQuery) JSON() ([]byte, error)

func (*DFQuery) Pos

func (m *DFQuery) Pos() *PositionRange

func (*DFQuery) String

func (m *DFQuery) String() string

type DeleteFunc

type DeleteFunc struct {
	// (1) dql语句;
	// (2) es indexName, 索引名称不包含wsid,例如: rum, log等;
	// (3) influxdb measurement name, 例如: cpu,mem等
	StrDql            string
	Func              *FuncExpr
	DeleteIndex       bool // 是否删除整个ES索引
	DeleteMeasurement bool // 是否删除整个Influxdb measurement
}

DeleteFunc delete info.

func (*DeleteFunc) Pos

func (d *DeleteFunc) Pos() *PositionRange

func (*DeleteFunc) String

func (d *DeleteFunc) String() string

type ESTRes

type ESTRes struct {
	Alias           map[string]string // 别名信息
	SortFields      []string          // 返回字段有序列表
	ClassNames      string            // metric 类型名称
	Show            bool              // 是否是show查询
	ShowFields      bool              // 是否是show fields查询
	TimeField       string            // time字段
	FLFuncCount     int               // first,last函数个数
	AggsFromSize    int               // 聚合的分页
	StartTime       int64             // 开始时间
	EndTime         int64             // 结束时间
	HighlightFields []string          // 高亮字段
}

type Evaluable

type Evaluable interface {
	Eval(data KVs) bool
}

type Expr

type Expr interface {
	Node
	Type() ValueType
	DQLExpr()
}

type Fill

type Fill struct {
	FillType int     `json:"-"`
	Str      string  `json:"-"`
	Float    float64 `json:"-"`
	Int      int64   `json:"-"`
	Boolean  bool    `json:"-"`
}

func (*Fill) MarshalJSON

func (n *Fill) MarshalJSON() ([]byte, error)

func (*Fill) Pos

func (n *Fill) Pos() *PositionRange

func (*Fill) String

func (n *Fill) String() string

func (*Fill) StringInfluxql

func (n *Fill) StringInfluxql() string

type FuncArg

type FuncArg struct {
	ArgName string `json:"name,omitempty"`
	ArgVal  Node   `json:"val,omitempty"`
}

func (*FuncArg) Pos

func (n *FuncArg) Pos() *PositionRange

func (*FuncArg) String

func (n *FuncArg) String() string

type FuncArgList

type FuncArgList []Node

func (FuncArgList) Pos

func (n FuncArgList) Pos() *PositionRange

func (FuncArgList) String

func (n FuncArgList) String() string

type FuncExpr

type FuncExpr struct {
	Name  string `json:"name,omitempty"`
	Param []Node `json:"param,omitempty"`
}

func (*FuncExpr) Pos

func (n *FuncExpr) Pos() *PositionRange

func (*FuncExpr) SplitFill

func (n *FuncExpr) SplitFill() (val Node, fill *Fill, err error)

func (*FuncExpr) String

func (n *FuncExpr) String() string

type GroupBy

type GroupBy struct {
	List NodeList `json:"val_list,omitempty"`
}

func (*GroupBy) ColumnList

func (n *GroupBy) ColumnList() []string

func (*GroupBy) Pos

func (n *GroupBy) Pos() *PositionRange

func (*GroupBy) String

func (n *GroupBy) String() string

type Helper

type Helper struct {
	ESTResPtr *ESTRes // es translate,当结果转为influxdb结构使用
}

Helper tranlate中间结果.

type Identifier

type Identifier struct {
	Name string `json:"val,omitempty"`
}

func (*Identifier) DQLExpr

func (e *Identifier) DQLExpr()

func (*Identifier) Pos

func (e *Identifier) Pos() *PositionRange

func (*Identifier) String

func (e *Identifier) String() string

func (*Identifier) Type

func (e *Identifier) Type() ValueType

type Item

type Item struct {
	Typ ItemType
	Pos Pos
	Val string
}

func (*Item) PositionRange

func (i *Item) PositionRange() *PositionRange

func (Item) String

func (i Item) String() string

type ItemType

type ItemType int

func (ItemType) IsKeyword

func (i ItemType) IsKeyword() bool

func (ItemType) IsOperator

func (i ItemType) IsOperator() bool

func (*ItemType) MarshalJSON

func (i *ItemType) MarshalJSON() ([]byte, error)

func (ItemType) String

func (i ItemType) String() string

type KVs

type KVs interface {
	Get(k string) (v any, ok bool)
}

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer holds the state of the scanner.

func Lex

func Lex(input string) *Lexer

func (*Lexer) NextItem

func (l *Lexer) NextItem(itemp *Item)

type Limit

type Limit struct {
	Limit int64 `json:"val,omitempty"`
}

func (*Limit) Pos

func (n *Limit) Pos() *PositionRange

func (*Limit) String

func (n *Limit) String() string

type NilLiteral

type NilLiteral struct{}

func (*NilLiteral) Pos

func (n *NilLiteral) Pos() *PositionRange

func (*NilLiteral) String

func (n *NilLiteral) String() string

type Node

type Node interface {
	String() string
	Pos() *PositionRange
}

type NodeList

type NodeList []Node

func (NodeList) Pos

func (n NodeList) Pos() *PositionRange

func (NodeList) String

func (n NodeList) String() string

type NumberLiteral

type NumberLiteral struct {
	IsInt bool
	Float float64
	Int   int64
}

func (*NumberLiteral) DQLExpr

func (e *NumberLiteral) DQLExpr()

func (*NumberLiteral) IsPositiveInteger

func (e *NumberLiteral) IsPositiveInteger() bool

func (*NumberLiteral) MarshalJSON

func (e *NumberLiteral) MarshalJSON() ([]byte, error)

func (*NumberLiteral) Pos

func (e *NumberLiteral) Pos() *PositionRange

func (*NumberLiteral) Reverse

func (e *NumberLiteral) Reverse()

func (*NumberLiteral) String

func (e *NumberLiteral) String() string

func (*NumberLiteral) Type

func (e *NumberLiteral) Type() ValueType

type Offset

type Offset struct {
	Offset int64 `json:"val,omitempty"`
}

func (*Offset) Pos

func (n *Offset) Pos() *PositionRange

func (*Offset) String

func (n *Offset) String() string

type OrderBy

type OrderBy struct {
	List NodeList
}

func (*OrderBy) Pos

func (n *OrderBy) Pos() *PositionRange

func (*OrderBy) String

func (n *OrderBy) String() string

type OrderByElem

type OrderByElem struct {
	Column string    `json:"-"`
	Opt    OrderType `json:"-"`
}

func (*OrderByElem) MarshalJSON

func (n *OrderByElem) MarshalJSON() ([]byte, error)

func (*OrderByElem) Pos

func (n *OrderByElem) Pos() *PositionRange

func (*OrderByElem) String

func (n *OrderByElem) String() string

type OrderType

type OrderType int
const (
	OrderAsc OrderType = iota
	OrderDesc
)

type OuterFunc

type OuterFunc struct {
	Func         *FuncExpr     `json:"func,omitempty"`
	FuncArgVals  []interface{} `json:"func_arg_vals,omitempty"`
	FuncArgTypes []string      `json:"func_arg_types,omitempty"`
	FuncArgNames []string      `json:"func_arg_names,omitempty"`
}

OuterFunc outerFunc.

func (*OuterFunc) Pos

func (ofuncs *OuterFunc) Pos() *PositionRange

func (*OuterFunc) String

func (ofuncs *OuterFunc) String() string

type OuterFuncs

type OuterFuncs struct {
	Funcs []*OuterFunc `json:"funcs,omitempty"`
}

func (*OuterFuncs) JSON

func (ofuncs *OuterFuncs) JSON() ([]byte, error)

func (*OuterFuncs) Pos

func (ofuncs *OuterFuncs) Pos() *PositionRange

func (*OuterFuncs) String

func (ofuncs *OuterFuncs) String() string

type ParenExpr

type ParenExpr struct {
	Param Node `json:"paren"`
}

func (*ParenExpr) DQLExpr

func (*ParenExpr) DQLExpr()

func (*ParenExpr) Eval

func (p *ParenExpr) Eval(data KVs) bool

func (*ParenExpr) Pos

func (*ParenExpr) Pos() *PositionRange

func (*ParenExpr) String

func (p *ParenExpr) String() string

func (*ParenExpr) Type

func (*ParenExpr) Type() ValueType

type ParseError

type ParseError struct {
	Pos        *PositionRange
	Err        error
	Query      string
	LineOffset int
}

func (*ParseError) Error

func (e *ParseError) Error() string

type ParseErrors

type ParseErrors []ParseError

func (ParseErrors) Error

func (errs ParseErrors) Error() string

Error impl Error() interface.

type Pos

type Pos int

Pos is the position in a string. Negative numbers indicate undefined positions.

type PositionRange

type PositionRange struct {
	Start, End Pos
}

type Regex

type Regex struct {
	Regex string `json:"regex,omitempty"`
	Re    *regexp.Regexp
}

func (*Regex) DQLExpr

func (e *Regex) DQLExpr()

func (*Regex) MarshalJSON

func (e *Regex) MarshalJSON() ([]byte, error)

func (*Regex) Pos

func (e *Regex) Pos() *PositionRange

func (*Regex) String

func (e *Regex) String() string

func (*Regex) Type

func (e *Regex) Type() ValueType

type SLimit

type SLimit struct {
	SLimit int64 `json:"val,omitempty"`
}

func (*SLimit) Pos

func (n *SLimit) Pos() *PositionRange

func (*SLimit) String

func (n *SLimit) String() string

type SOffset

type SOffset struct {
	SOffset int64 `json:"val,omitempty"`
}

func (*SOffset) Pos

func (n *SOffset) Pos() *PositionRange

func (*SOffset) String

func (n *SOffset) String() string

type SearchAfter

type SearchAfter struct {
	Vals []interface{} `json:"vals,omitempty"`
}

SearchAfter 深度分页.

func (*SearchAfter) Pos

func (sa *SearchAfter) Pos() *PositionRange

Pos pos.

func (*SearchAfter) String

func (sa *SearchAfter) String() string

String string.

type Star

type Star struct{}

func (*Star) MarshalJSON

func (n *Star) MarshalJSON() ([]byte, error)

func (*Star) Pos

func (n *Star) Pos() *PositionRange

func (*Star) String

func (n *Star) String() string

type Statement

type Statement interface {
	Node
	DQLStmt() // not used
}

type StaticCast

type StaticCast struct {
	IsInt   bool
	IsFloat bool
	Val     *Identifier
}

func (*StaticCast) DQLExpr

func (e *StaticCast) DQLExpr()

func (*StaticCast) MarshalJSON

func (e *StaticCast) MarshalJSON() ([]byte, error)

func (*StaticCast) Pos

func (e *StaticCast) Pos() *PositionRange

func (*StaticCast) String

func (e *StaticCast) String() string

func (*StaticCast) Type

func (e *StaticCast) Type() ValueType

type Stmts

type Stmts []Node

func (Stmts) Pos

func (n Stmts) Pos() *PositionRange

func (Stmts) String

func (n Stmts) String() string

type StringLiteral

type StringLiteral struct {
	Val string `json:"val,omitempty"`
}

func (*StringLiteral) DQLExpr

func (e *StringLiteral) DQLExpr()

func (*StringLiteral) Pos

func (e *StringLiteral) Pos() *PositionRange

func (*StringLiteral) String

func (e *StringLiteral) String() string

func (*StringLiteral) Type

func (e *StringLiteral) Type() ValueType

type Target

type Target struct {
	Col    Node   `json:"col,omitempty"`
	Alias  string `json:"alias,omitempty"`
	Fill   *Fill  `json:"fill,omitempty"`
	Talias string `json:"tailas,omitempty"` // dql翻译别名
}

func (*Target) Pos

func (n *Target) Pos() *PositionRange

func (*Target) String

func (n *Target) String() string

func (*Target) String2

func (n *Target) String2() string

type TimeResolution

type TimeResolution struct {
	Duration time.Duration
	Auto     bool
	PointNum *NumberLiteral
}

func (*TimeResolution) Pos

func (n *TimeResolution) Pos() *PositionRange

func (*TimeResolution) String

func (n *TimeResolution) String() string

type TimeZone

type TimeZone struct {
	Input    string `json:"input,omitempty"`
	TimeZone string `json:"-"`
}

func (*TimeZone) Pos

func (n *TimeZone) Pos() *PositionRange

func (*TimeZone) String

func (n *TimeZone) String() string

type Value

type Value interface {
	Type() ValueType
	String() string
}

type ValueType

type ValueType string

type WhereCondition

type WhereCondition struct {
	// contains filtered or unexported fields
}

func (*WhereCondition) Eval

func (x *WhereCondition) Eval(data KVs) bool

func (*WhereCondition) Pos

func (x *WhereCondition) Pos() *PositionRange

func (*WhereCondition) String

func (x *WhereCondition) String() string

type WhereConditions

type WhereConditions []Node

func GetConds

func GetConds(input string) (WhereConditions, error)

func (WhereConditions) Eval

func (x WhereConditions) Eval(data KVs) int

func (WhereConditions) Pos

func (x WhereConditions) Pos() *PositionRange

func (WhereConditions) String

func (x WhereConditions) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL