Documentation ¶
Index ¶
- Constants
- Variables
- func FormatDuration(dur time.Duration) string
- func FormatStringLiteral(value string) string
- func FormatTime(t time.Time) string
- func FormatValue(tp *types.FieldType, value []byte) string
- func Rd(n int) int
- func RdAggregateExpr(column *database.Column) ast.ExprNode
- func RdBinaryOperator(ops []opcode.Op) opcode.Op
- func RdBool() bool
- func RdColumns(columnsList [][]*database.Column) *database.Column
- func RdDate() time.Time
- func RdDuration() time.Duration
- func RdFloat64() float64
- func RdGreaterValue(exec executor.Executor, column *database.Column, less []byte) (value []byte, err error)
- func RdInRange(column *database.Column, value []byte, exec executor.Executor) (rg []ast.ExprNode, err error)
- func RdInt63(n int64) int64
- func RdInt64() int64
- func RdLessValue(exec executor.Executor, column *database.Column, less []byte) (value []byte, err error)
- func RdLogicOp() opcode.Op
- func RdNotEqualValue(exec executor.Executor, column *database.Column, value []byte) (other []byte, err error)
- func RdRange(n, m int64) int64
- func RdRangeConditionExpr(exec executor.Executor, column *database.Column, value []byte) ast.ExprNode
- func RdSQLValue(tp *types.FieldType) string
- func RdString(length int) string
- func RdStringChar(length int) string
- func RdTimestamp() time.Time
- func RdTowColumns(columnsList [][]*database.Column) []*database.Column
- func RdValue(exec executor.Executor, column *database.Column) (value []byte, err error)
- func SetAndOpWeight(weight int)
- func SumSelect(source ast.ResultSetNode) *ast.SelectStmt
- type AggregateFunc
- type Generator
- func (g *Generator) AggregateSelect(options Options, tables []string, columnsList [][]*database.Column) (stmt *ast.SelectStmt, err error)
- func (g *Generator) BenchSelect(options Options, tables []string, columnsList [][]*database.Column) (*ast.SelectStmt, error)
- func (g *Generator) BenchStmt(options Options) (query string, err error)
- func (g *Generator) ComposeSelect(options Options, tables []string, columnsList [][]*database.Column, ...) (*ast.SelectStmt, error)
- func (g *Generator) ComposeStmt(options Options) (query string, err error)
- func (g *Generator) ComposeUnion(options Options, tables []string, columnsList [][]*database.Column, ...) (stmt *ast.SelectStmt, err error)
- func (g *Generator) NormalSelect(options Options, tables []string, columnsList [][]*database.Column) (stmt *ast.SelectStmt, err error)
- func (g *Generator) PrepareSelect(tables []string, columnsList [][]*database.Column) (*ast.SelectStmt, error)
- func (g *Generator) RdGroupBy(maxByItems int, tableColumns [][]*database.Column) ([]*ast.ByItem, map[*database.Column]bool)
- func (g *Generator) RdOrderBy(options Options, tables []string, tableColumns [][]*database.Column) []*ast.ByItem
- func (g *Generator) RdTablesAndKeys(option *Options) ([]string, [][]*database.Column)
- func (g *Generator) RdValues(table string, columns []*database.Column) (values [][]byte, err error)
- func (g *Generator) RdValuesList(tableRefs *ast.TableRefsClause, columnsList [][]*database.Column) (valuesList [][][]byte, err error)
- func (g *Generator) TableRefsClause(tables []string) *ast.TableRefsClause
- func (g *Generator) WhereExpr(columnsList [][]*database.Column, valuesList [][][]byte) ast.ExprNode
- type Options
- type RangeCondition
Constants ¶
View Source
const ( Count AggregateFunc = ast.AggFuncCount Sum = ast.AggFuncSum Avg = ast.AggFuncAvg Max = ast.AggFuncMax Min = ast.AggFuncMin VarPop = ast.AggFuncVarPop )
View Source
const ( /// = Equal = RangeCondition(opcode.EQ) /// <=> NullSafeEqual = RangeCondition(opcode.NullEQ) /// IN() In = RangeCondition(opcode.In) /// IS NULL IsNull = RangeCondition(opcode.IsNull) /// > Greater = RangeCondition(opcode.GT) /// < Less = RangeCondition(opcode.LT) ///>= GreaterEqual = RangeCondition(opcode.GE) /// <= LessEqual = RangeCondition(opcode.LE) /// != NotEqual = RangeCondition(opcode.NE) /// LIKE Like = RangeCondition(opcode.Like) /// BETWEEN ... AND Between = RangeCondition(iota + opcode.IsFalsity + 1) IsNotNull )
Variables ¶
View Source
var ( ComposeTmpTable = model.NewCIStr("tmp") ComposeValueAsName = model.NewCIStr("val") ComposeSumExpr = &ast.AggregateFuncExpr{ F: ast.AggFuncSum, Args: []ast.ExprNode{ &ast.ColumnNameExpr{ Name: &ast.ColumnName{ Name: ComposeValueAsName, Table: ComposeTmpTable, }, }, }, } UnionOperator = ast.Union )
Functions ¶
func FormatDuration ¶
TODO: Implement `FormatDuration`
func FormatStringLiteral ¶
func FormatTime ¶
func RdDuration ¶
func RdGreaterValue ¶
func RdLessValue ¶
func RdNotEqualValue ¶
func RdRangeConditionExpr ¶
func RdSQLValue ¶
func RdStringChar ¶
RdStringChar rand string with given length, letter chars only
func RdTimestamp ¶
RdTimestamp return same format as RdDate except rand range TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07'
func RdTowColumns ¶ added in v0.9.1
func SumSelect ¶ added in v0.9.1
func SumSelect(source ast.ResultSetNode) *ast.SelectStmt
Types ¶
type AggregateFunc ¶
type AggregateFunc string
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶
func (*Generator) AggregateSelect ¶
func (*Generator) BenchSelect ¶ added in v0.9.1
func (*Generator) ComposeSelect ¶ added in v0.9.1
func (g *Generator) ComposeSelect(options Options, tables []string, columnsList [][]*database.Column, composedStmt *ast.SelectStmt) (*ast.SelectStmt, error)
func (*Generator) ComposeStmt ¶ added in v0.9.1
func (*Generator) ComposeUnion ¶ added in v0.9.1
func (g *Generator) ComposeUnion(options Options, tables []string, columnsList [][]*database.Column, composedStmt *ast.SelectStmt) (stmt *ast.SelectStmt, err error)
func (*Generator) NormalSelect ¶
func (*Generator) PrepareSelect ¶
func (*Generator) RdTablesAndKeys ¶
func (*Generator) RdValuesList ¶
func (*Generator) TableRefsClause ¶
func (g *Generator) TableRefsClause(tables []string) *ast.TableRefsClause
type Options ¶
type Options struct { MaxTables int `json:"max_tables"` MinDurationThreshold time.Duration `json:"min_duration_threshold"` Limit int `json:"limit"` KeyOnly bool `json:"key_only"` // control order by UnstableOrderBy bool `json:"unstable_order_by"` MaxByItems int `json:"max_by_items"` EnableKeyMap bool `json:"enable_key_map"` AggregateWeight float64 `json:"aggregate_weight"` }
Click to show internal directories.
Click to hide internal directories.