本文整理匯總了Golang中github.com/pingcap/tidb/ast.AggregateFuncExpr.SetValue方法的典型用法代碼示例。如果您正苦於以下問題:Golang AggregateFuncExpr.SetValue方法的具體用法?Golang AggregateFuncExpr.SetValue怎麽用?Golang AggregateFuncExpr.SetValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pingcap/tidb/ast.AggregateFuncExpr
的用法示例。
在下文中一共展示了AggregateFuncExpr.SetValue方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: evalAggGroupConcat
func (e *Evaluator) evalAggGroupConcat(v *ast.AggregateFuncExpr) {
ctx := v.GetContext()
if ctx.Buffer != nil {
v.SetValue(ctx.Buffer.String())
} else {
v.SetValue(nil)
}
}
示例2: evalAggAvg
func (e *Evaluator) evalAggAvg(v *ast.AggregateFuncExpr) {
ctx := v.GetContext()
switch x := ctx.Value.(type) {
case float64:
ctx.Value = x / float64(ctx.Count)
case mysql.Decimal:
ctx.Value = x.Div(mysql.NewDecimalFromUint(uint64(ctx.Count), 0))
}
v.SetValue(ctx.Value)
}
示例3: aggregateFunc
func (e *Evaluator) aggregateFunc(v *ast.AggregateFuncExpr) bool {
idx := e.aggregateMap[v]
aggr := e.aggregators[idx]
if e.aggregateDone {
v.SetValue(aggr.Output())
return true
}
// TODO: currently only single argument aggregate functions are supported.
e.err = aggr.Input(v.Args[0].GetValue())
return e.err == nil
}
示例4: evalAggAvg
func (e *Evaluator) evalAggAvg(v *ast.AggregateFuncExpr) {
ctx := v.GetContext()
switch ctx.Value.Kind() {
case types.KindFloat64:
t := ctx.Value.GetFloat64() / float64(ctx.Count)
v.SetValue(t)
case types.KindMysqlDecimal:
x := ctx.Value.GetMysqlDecimal()
t := x.Div(mysql.NewDecimalFromUint(uint64(ctx.Count), 0))
v.SetMysqlDecimal(t)
}
ctx.Value = *v.GetDatum()
}
示例5: evalAggAvg
func (e *Evaluator) evalAggAvg(v *ast.AggregateFuncExpr) {
ctx := v.GetContext()
switch ctx.Value.Kind() {
case types.KindFloat64:
t := ctx.Value.GetFloat64() / float64(ctx.Count)
v.SetValue(t)
case types.KindMysqlDecimal:
x := ctx.Value.GetMysqlDecimal()
var y, to mysql.MyDecimal
y.FromUint(uint64(ctx.Count))
mysql.DecimalDiv(x, &y, &to, mysql.DivFracIncr)
to.Round(&to, ctx.Value.Frac()+mysql.DivFracIncr)
v.SetMysqlDecimal(&to)
}
ctx.Value = *v.GetDatum()
}
示例6: evalAggFirstRow
func (e *Evaluator) evalAggFirstRow(v *ast.AggregateFuncExpr) {
ctx := v.GetContext()
v.SetValue(ctx.Value)
}
示例7: evalAggCount
func (e *Evaluator) evalAggCount(v *ast.AggregateFuncExpr) {
ctx := v.GetContext()
v.SetValue(ctx.Count)
}