Documentation
¶
Index ¶
- Constants
- Variables
- func FormatField(field string) string
- type ApdexFunction
- type BinaryExpr
- type CounterAvgFunction
- type DefaultFunction
- func (f *DefaultFunction) GetDefaultAlias(inner bool) string
- func (f *DefaultFunction) GetFields() []Node
- func (f *DefaultFunction) GetFlag() int
- func (f *DefaultFunction) GetName() string
- func (f *DefaultFunction) GetWiths() []Node
- func (f *DefaultFunction) Init()
- func (f *DefaultFunction) SetAlias(alias string, inner bool) string
- func (f *DefaultFunction) SetArgs(args []string)
- func (f *DefaultFunction) SetCondition(condition string)
- func (f *DefaultFunction) SetFields(fields []Node)
- func (f *DefaultFunction) SetFillNullAsZero(fillNullAsZero bool)
- func (f *DefaultFunction) SetFlag(flag int)
- func (f *DefaultFunction) SetIgnoreZero(ignoreZero bool)
- func (f *DefaultFunction) SetIsGroupArray(isGroupArray bool)
- func (f *DefaultFunction) SetMath(math string)
- func (f *DefaultFunction) SetTime(time *Time)
- func (f *DefaultFunction) ToString() string
- func (f *DefaultFunction) WriteTo(buf *bytes.Buffer)
- type DelayAvgFunction
- type DivFunction
- type Expr
- type Field
- type Filters
- type Function
- type Group
- type Groups
- type HistogramFunction
- type Limit
- type MinFunction
- type Model
- type Nested
- type Node
- type NodeBase
- type NodeSet
- type NodeSetBase
- type NonNegativeDerivativeFunction
- type Operator
- type Order
- type Orders
- type PerSecondFunction
- type PercentageFunction
- type RspreadFunction
- type SpreadFunction
- type SubView
- type Table
- type Tables
- type Tag
- type Tags
- type Time
- type UnaryExpr
- type View
- type With
- type Withs
Constants ¶
View Source
const ( NODE_FLAG_METRICS int = iota // 仅在计算层 NODE_FLAG_METRICS_INNER // 仅在计算层内层 NODE_FLAG_METRICS_OUTER // 仅在计算层外层 NODE_FLAG_METRICS_TOP // 仅在最外层 )
View Source
const ( METRICS_FLAG_INNER int = iota // METRICS专用FLAG,仅在计算层内层 METRICS_FLAG_OUTER // METRICS专用FLAG,仅在计算层外层 METRICS_FLAG_TOP // METRICS专用FLAG,在整体sql外再增加一层,仅包含该FLAG的字段 )
View Source
const ( GROUP_FLAG_DEFAULT int = iota // GROUP专用FLAG,计算层内外都携带group,with仅放计算层内层 GROUP_FLAG_METRICS_OUTER // GROUP专用FLAG,仅计算层外层携带该group GROUP_FLAG_METRICS_INNTER // GROUP专用FLAG,仅计算层内层携带该group )
View Source
const ( MODEL_METRICS_LEVEL_FLAG_UNLAY int = iota // 计算层不需要根据算子拆层 MODEL_METRICS_LEVEL_FLAG_LAYERED // 计算层需要根据算子拆层 )
View Source
const ( FUNCTION_DIV_TYPE_DEFAULT int = iota // 默认,不做任何处理 FUNCTION_DIV_TYPE_FILL_MINIMUM // 除数和被除数都+1e-15 FUNCTION_DIV_TYPE_0DIVIDER_AS_NULL // 除数为0时,结果为NULL FUNCTION_DIV_TYPE_0DIVIDER_AS_0 //除数为0时,结果为0 )
Div算子类型
View Source
const ( FUNCTION_SUM = "Sum" FUNCTION_MAX = "Max" FUNCTION_MIN = "Min" FUNCTION_AVG = "Avg" FUNCTION_COUNTER_AVG = "Counter_Avg" FUNCTION_DELAY_AVG = "Delay_Avg" FUNCTION_AAVG = "AAvg" FUNCTION_PCTL = "Percentile" FUNCTION_PCTL_EXACT = "PercentileExact" FUNCTION_STDDEV = "Stddev" FUNCTION_SPREAD = "Spread" FUNCTION_RSPREAD = "Rspread" FUNCTION_APDEX = "Apdex" FUNCTION_GROUP_ARRAY = "groupArray" FUNCTION_DIV = "/" FUNCTION_PLUS = "+" FUNCTION_MINUS = "-" FUNCTION_MULTIPLY = "*" FUNCTION_COUNT = "Count" FUNCTION_UNIQ = "Uniq" FUNCTION_UNIQ_EXACT = "UniqExact" FUNCTION_PERSECOND = "PerSecond" FUNCTION_PERCENTAG = "Percentage" FUNCTION_HISTOGRAM = "Histogram" FUNCTION_LAST = "Last" FUNCTION_TOPK = "TopK" FUNCTION_ANY = "Any" FUNCTION_DERIVATIVE = "nonNegativeDerivative" FUNCTION_COUNTDISTINCT = "countDistinct" )
View Source
const ( OPERATOER_UNKNOWN int = iota AND OR NOT GTE LTE EQ NEQ LIKE NLIKE REGEXP NREGEXP GT LT IN NIN )
Variables ¶
View Source
var FUNC_NAME_MAP map[string]string = map[string]string{ FUNCTION_SUM: "SUM", FUNCTION_MAX: "MAX", FUNCTION_MIN: "MIN", FUNCTION_AAVG: "AVG", FUNCTION_PCTL: "quantile", FUNCTION_PCTL_EXACT: "quantileExact", FUNCTION_STDDEV: "stddevPopStable", FUNCTION_GROUP_ARRAY: "groupArray", FUNCTION_PLUS: "plus", FUNCTION_DIV: "Div", FUNCTION_MINUS: "minus", FUNCTION_MULTIPLY: "multiply", FUNCTION_COUNT: "COUNT", FUNCTION_UNIQ: "uniq", FUNCTION_UNIQ_EXACT: "uniqExact", FUNCTION_LAST: "last_value", FUNCTION_TOPK: "topK", FUNCTION_ANY: "any", FUNCTION_DERIVATIVE: "nonNegativeDerivative", }
对外提供的算子与数据库实际算子转换
View Source
var MATH_FUNCTIONS = []string{ FUNCTION_DIV, FUNCTION_PLUS, FUNCTION_MINUS, FUNCTION_MULTIPLY, FUNCTION_PERCENTAG, FUNCTION_PERSECOND, FUNCTION_HISTOGRAM, }
Functions ¶
func FormatField ¶
Types ¶
type ApdexFunction ¶
type ApdexFunction struct {
DefaultFunction
// contains filtered or unexported fields
}
func (*ApdexFunction) GetWiths ¶
func (f *ApdexFunction) GetWiths() []Node
func (*ApdexFunction) Init ¶
func (f *ApdexFunction) Init()
func (*ApdexFunction) WriteTo ¶
func (f *ApdexFunction) WriteTo(buf *bytes.Buffer)
type BinaryExpr ¶
func (*BinaryExpr) ToString ¶
func (n *BinaryExpr) ToString() string
func (*BinaryExpr) WriteTo ¶
func (n *BinaryExpr) WriteTo(buf *bytes.Buffer)
type CounterAvgFunction ¶
type CounterAvgFunction struct {
DefaultFunction
}
func (*CounterAvgFunction) WriteTo ¶
func (f *CounterAvgFunction) WriteTo(buf *bytes.Buffer)
type DefaultFunction ¶
type DefaultFunction struct {
Name string // 算子名称
Fields []Node // 指标量名称
Args []string // 其他参数
DerivativeArgs []string // Derivative其他参数
Alias string // as
Condition string // 算子过滤 例:Condition:"code in [1,2]" SUMIf(byte, code in [1,2])
Withs []Node
Flag int
IgnoreZero bool
FillNullAsZero bool
IsGroupArray bool // 是否针对list做聚合,例:SUMArray(rtt_max)
Nest bool // 是否为内层嵌套算子
Time *Time
Math string
NodeBase
}
func (*DefaultFunction) GetDefaultAlias ¶
func (f *DefaultFunction) GetDefaultAlias(inner bool) string
func (*DefaultFunction) GetFields ¶
func (f *DefaultFunction) GetFields() []Node
func (*DefaultFunction) GetFlag ¶
func (f *DefaultFunction) GetFlag() int
func (*DefaultFunction) GetName ¶
func (f *DefaultFunction) GetName() string
func (*DefaultFunction) GetWiths ¶
func (f *DefaultFunction) GetWiths() []Node
func (*DefaultFunction) Init ¶
func (f *DefaultFunction) Init()
func (*DefaultFunction) SetAlias ¶
func (f *DefaultFunction) SetAlias(alias string, inner bool) string
func (*DefaultFunction) SetArgs ¶
func (f *DefaultFunction) SetArgs(args []string)
func (*DefaultFunction) SetCondition ¶
func (f *DefaultFunction) SetCondition(condition string)
func (*DefaultFunction) SetFields ¶
func (f *DefaultFunction) SetFields(fields []Node)
func (*DefaultFunction) SetFillNullAsZero ¶
func (f *DefaultFunction) SetFillNullAsZero(fillNullAsZero bool)
func (*DefaultFunction) SetFlag ¶
func (f *DefaultFunction) SetFlag(flag int)
func (*DefaultFunction) SetIgnoreZero ¶
func (f *DefaultFunction) SetIgnoreZero(ignoreZero bool)
func (*DefaultFunction) SetIsGroupArray ¶
func (f *DefaultFunction) SetIsGroupArray(isGroupArray bool)
func (*DefaultFunction) SetMath ¶
func (f *DefaultFunction) SetMath(math string)
func (*DefaultFunction) SetTime ¶
func (f *DefaultFunction) SetTime(time *Time)
func (*DefaultFunction) ToString ¶
func (f *DefaultFunction) ToString() string
func (*DefaultFunction) WriteTo ¶
func (f *DefaultFunction) WriteTo(buf *bytes.Buffer)
type DelayAvgFunction ¶
type DelayAvgFunction struct {
DefaultFunction
// contains filtered or unexported fields
}
func (*DelayAvgFunction) GetWiths ¶
func (f *DelayAvgFunction) GetWiths() []Node
func (*DelayAvgFunction) Init ¶
func (f *DelayAvgFunction) Init()
func (*DelayAvgFunction) WriteTo ¶
func (f *DelayAvgFunction) WriteTo(buf *bytes.Buffer)
type DivFunction ¶
type DivFunction struct {
DefaultFunction
DivType int
}
func (*DivFunction) GetWiths ¶
func (f *DivFunction) GetWiths() []Node
func (*DivFunction) WriteTo ¶
func (f *DivFunction) WriteTo(buf *bytes.Buffer)
type Field ¶
type Field struct {
DefaultFunction
Value string
Withs []Node
}
func (*Field) GetDefaultAlias ¶
type Filters ¶
type Filters struct {
Expr Node
Withs []Node
NodeSetBase
}
type Function ¶
type Function interface {
Node
SetFields([]Node)
SetArgs([]string)
SetFlag(int)
SetAlias(string, bool) string
GetDefaultAlias(bool) string
SetIgnoreZero(bool)
SetFillNullAsZero(bool)
SetIsGroupArray(bool)
SetCondition(string)
SetTime(*Time)
SetMath(string)
GetFlag() int
GetName() string
GetFields() []Node
Init()
}
type Groups ¶
type Groups struct {
NodeSetBase
// contains filtered or unexported fields
}
NodeSet Group结构体集合
type HistogramFunction ¶
type HistogramFunction struct {
DefaultFunction
}
func (*HistogramFunction) WriteTo ¶
func (f *HistogramFunction) WriteTo(buf *bytes.Buffer)
type MinFunction ¶
type MinFunction struct {
DefaultFunction
}
func (*MinFunction) GetWiths ¶
func (f *MinFunction) GetWiths() []Node
func (*MinFunction) WriteTo ¶
func (f *MinFunction) WriteTo(buf *bytes.Buffer)
type Model ¶
type Model struct {
DB string
Time *Time
Tags *Tags
Filters *Filters
From *Tables
Groups *Groups
Havings *Filters
Orders *Orders
Limit *Limit
Callbacks map[string]func(*common.Result) error
//Havings Havings
MetricsLevelFlag int //Metrics是否需要拆层的标识
HasAggFunc bool
IsDerivative bool
DerivativeGroupBy []string
}
对外接口:
struct: Model 包含withs tags filters等结构用于构造view View 由Model生成,用于构造df-clickhouse-sql func: NewModel() Model 初始化Model结构 Model.AddTag() Model.AddTable() Model.AddGroup() Model.AddFilter() NewView(*Model) View 使用model初始化View结构 NewView.ToString() string 生成df-clickhouse-sql
type NodeSetBase ¶
type NodeSetBase struct{ NodeBase }
type NonNegativeDerivativeFunction ¶
type NonNegativeDerivativeFunction struct {
DefaultFunction
}
func (*NonNegativeDerivativeFunction) WriteTo ¶
func (f *NonNegativeDerivativeFunction) WriteTo(buf *bytes.Buffer)
type Operator ¶
func GetOperator ¶
type Orders ¶
type Orders struct {
NodeSetBase
Orders []Node
}
type PerSecondFunction ¶
type PerSecondFunction struct {
DefaultFunction
// contains filtered or unexported fields
}
func (*PerSecondFunction) GetWiths ¶
func (f *PerSecondFunction) GetWiths() []Node
func (*PerSecondFunction) Init ¶
func (f *PerSecondFunction) Init()
func (*PerSecondFunction) WriteTo ¶
func (f *PerSecondFunction) WriteTo(buf *bytes.Buffer)
type PercentageFunction ¶
type PercentageFunction struct {
DefaultFunction
// contains filtered or unexported fields
}
func (*PercentageFunction) GetWiths ¶
func (f *PercentageFunction) GetWiths() []Node
func (*PercentageFunction) Init ¶
func (f *PercentageFunction) Init()
func (*PercentageFunction) WriteTo ¶
func (f *PercentageFunction) WriteTo(buf *bytes.Buffer)
type RspreadFunction ¶
type RspreadFunction struct {
DefaultFunction
// contains filtered or unexported fields
}
func (*RspreadFunction) GetWiths ¶
func (f *RspreadFunction) GetWiths() []Node
func (*RspreadFunction) Init ¶
func (f *RspreadFunction) Init()
func (*RspreadFunction) WriteTo ¶
func (f *RspreadFunction) WriteTo(buf *bytes.Buffer)
type SpreadFunction ¶
type SpreadFunction struct {
DefaultFunction
// contains filtered or unexported fields
}
func (*SpreadFunction) GetWiths ¶
func (f *SpreadFunction) GetWiths() []Node
func (*SpreadFunction) Init ¶
func (f *SpreadFunction) Init()
func (*SpreadFunction) WriteTo ¶
func (f *SpreadFunction) WriteTo(buf *bytes.Buffer)
type SubView ¶
type Tables ¶
type Tables struct {
NodeSetBase
// contains filtered or unexported fields
}
NodeSet Table结构体集合
type Tags ¶
type Tags struct {
NodeSetBase
// contains filtered or unexported fields
}
NodeSet Tag结构体集合
type Time ¶
type Time struct {
TimeStart int64
TimeEnd int64
Interval int
DatasourceInterval int
WindowSize int
Offset int
Fill string
Alias string
TimeStartOperator string
TimeEndOperator string
}
func (*Time) AddInterval ¶
func (*Time) AddTimeEnd ¶
func (*Time) AddTimeStart ¶
func (*Time) AddWindowSize ¶
type View ¶
type View struct {
Model *Model //初始化view
SubViewLevels []*SubView //由RawView拆层
NoPreWhere bool // Whether to use prewhere
}
func (*View) GetCallbacks ¶
Click to show internal directories.
Click to hide internal directories.