func (af *aggFunction) getStreamedContext() *ast.AggEvaluateContext { if af.streamCtx == nil { af.streamCtx = &ast.AggEvaluateContext{} if af.Distinct { af.streamCtx.DistinctChecker = distinct.CreateDistinctChecker() } } return af.streamCtx }
func (af *aggFunction) getContext(groupKey []byte) *ast.AggEvaluateContext { ctx, ok := af.resultMapper[string(groupKey)] if !ok { ctx = &ast.AggEvaluateContext{} if af.Distinct { ctx.DistinctChecker = distinct.CreateDistinctChecker() } af.resultMapper[string(groupKey)] = ctx } return ctx }
// GetContext gets aggregate evaluation context for the current group. // If it is nil, add a new context into contextPerGroupMap. func (n *AggregateFuncExpr) GetContext() *AggEvaluateContext { if n.contextPerGroupMap == nil { n.contextPerGroupMap = make(map[string](*AggEvaluateContext)) } if _, ok := n.contextPerGroupMap[n.CurrentGroup]; !ok { c := &AggEvaluateContext{} if n.Distinct { c.distinctChecker = distinct.CreateDistinctChecker() } n.contextPerGroupMap[n.CurrentGroup] = c } return n.contextPerGroupMap[n.CurrentGroup] }
// Next implements Executor Next interface. func (e *DistinctExec) Next() (*Row, error) { if e.checker == nil { e.checker = distinct.CreateDistinctChecker() } for { row, err := e.Src.Next() if err != nil { return nil, errors.Trace(err) } if row == nil { return nil, nil } ok, err := e.checker.Check(types.DatumsToInterfaces(row.Data)) if err != nil { return nil, errors.Trace(err) } if !ok { continue } return row, nil } }