本文整理汇总了Golang中github.com/pingcap/tidb/util/format.Formatter.Format方法的典型用法代码示例。如果您正苦于以下问题:Golang Formatter.Format方法的具体用法?Golang Formatter.Format怎么用?Golang Formatter.Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pingcap/tidb/util/format.Formatter
的用法示例。
在下文中一共展示了Formatter.Format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Explain
// Explain implements the plan.Plan Explain interface.
func (r *TableDefaultPlan) Explain(w format.Formatter) {
fmtStr := "┌Iterate all rows of table %q\n└Output field names %v\n"
if r.rangeScan {
fmtStr = "┌Range scan rows of table %q\n└Output field names %v\n"
}
w.Format(fmtStr, r.T.TableName(), field.RFQNames(r.Fields))
}
示例2: Explain
// Explain implements the plan.Plan Explain interface.
func (r *SelectFinalPlan) Explain(w format.Formatter) {
r.Src.Explain(w)
if r.HiddenFieldOffset == len(r.Src.GetFields()) {
// we have no hidden fields, can return.
return
}
w.Format("┌Evaluate\n└Output field names %v\n", field.RFQNames(r.ResultFields[0:r.HiddenFieldOffset]))
}
示例3: Explain
// Explain implements plan.Plan Explain interface.
func (r *SelectLockPlan) Explain(w format.Formatter) {
r.Src.Explain(w)
if r.Lock != coldef.SelectLockForUpdate {
// no need to lock, just return.
return
}
w.Format("┌Lock row keys for update\n")
}
示例4: Explain
// Explain implements the stmt.Statement Explain interface.
func (s *DeleteStmt) Explain(ctx context.Context, w format.Formatter) {
p, err := s.plan(ctx)
if err != nil {
log.Error(err)
return
}
p.Explain(w)
w.Format("└Delete row\n")
}
示例5: Explain
// Explain implements the stmt.Statement Explain interface.
func (s *SelectStmt) Explain(ctx context.Context, w format.Formatter) {
p, err := s.Plan(ctx)
if err != nil {
w.Format("ERROR: %v\n", err)
return
}
p.Explain(w)
}
示例6: explainNode
func (r *JoinPlan) explainNode(w format.Formatter, node plan.Plan) {
sel := !isTableOrIndex(node)
if sel {
w.Format("┌Iterate all rows of virtual table\n")
}
node.Explain(w)
if sel {
w.Format("└Output field names %v\n", field.RFQNames(node.GetFields()))
}
}
示例7: Explain
// Explain implements the stmt.Statement Explain interface.
func (s *UpdateStmt) Explain(ctx context.Context, w format.Formatter) {
p, err := s.plan(ctx)
if err != nil {
log.Error(err)
return
}
if p != nil {
p.Explain(w)
}
w.Format("└Update fields %v\n", s.List)
}
示例8: Explain
// Explain implements the stmt.Statement Explain interface.
func (s *DeleteStmt) Explain(ctx context.Context, w format.Formatter) {
p, err := s.indexPlan(ctx)
if err != nil {
log.Error(err)
return
}
if p != nil {
p.Explain(w)
} else {
w.Format("┌Iterate all rows of table: %s\n", s.TableIdent)
}
w.Format("└Delete row\n")
}
示例9: Explain
// Explain implements plan.Plan Explain interface.
func (r *JoinPlan) Explain(w format.Formatter) {
// TODO: show more useful join plan
if r.Right == nil {
// if right is nil, we don't do a join, just simple select table
r.Left.Explain(w)
return
}
w.Format("┌Compute %s Cartesian product of\n", r.Type)
r.explainNode(w, r.Left)
r.explainNode(w, r.Right)
w.Format("└Output field names %v\n", field.RFQNames(r.Fields))
}
示例10: Explain
// Explain implements the plan.Plan Explain interface.
func (r *SelectFieldsDefaultPlan) Explain(w format.Formatter) {
// TODO: check for non existing fields
r.Src.Explain(w)
w.Format("┌Evaluate")
for _, v := range r.Fields {
w.Format(" %s,", v)
}
w.Format("\n└Output field names %v\n", field.RFQNames(r.ResultFields))
}
示例11: Explain
// Explain implements plan.Plan Explain interface.
func (r *OrderByDefaultPlan) Explain(w format.Formatter) {
r.Src.Explain(w)
w.Format("┌Order by")
items := make([]string, len(r.By))
for i, v := range r.By {
order := "ASC"
if !r.Ascs[i] {
order = "DESC"
}
items[i] = fmt.Sprintf(" %s %s", v, order)
}
w.Format("%s", strings.Join(items, ","))
w.Format("\n└Output field names %v\n", field.RFQNames(r.ResultFields))
}
示例12: Explain
// Explain implements plan.Plan Explain interface.
func (r *indexPlan) Explain(w format.Formatter) {
w.Format("┌Iterate rows of table %q using index %q where %s in ", r.src.TableName(), r.idxName, r.col.Name.L)
for _, span := range r.spans {
open := "["
close := "]"
if span.lowExclude {
open = "("
}
if span.highExclude {
close = ")"
}
w.Format("%s%v,%v%s ", open, span.lowVal, span.highVal, close)
}
w.Format("\n└Output field names %v\n", field.RFQNames(r.GetFields()))
}
示例13: Explain
// Explain implements plan.Plan Explain interface.
func (r *LimitDefaultPlan) Explain(w format.Formatter) {
r.Src.Explain(w)
w.Format("┌Limit %d records\n└Output field names %v\n", r.Count, r.Fields)
}
示例14: Explain
// Explain implements plan.Plan Explain interface.
func (r *GroupByDefaultPlan) Explain(w format.Formatter) {
r.Src.Explain(w)
w.Format("┌Evaluate")
for _, v := range r.Fields {
w.Format(" %s as %s,", v.Expr, fmt.Sprintf("%q", v.Name))
}
switch {
case len(r.By) == 0: //TODO this case should not exist for this plan.Plan, should become TableDefaultPlan
w.Format("\n│Group by distinct rows")
default:
w.Format("\n│Group by")
for _, v := range r.By {
w.Format(" %s,", v)
}
}
w.Format("\n└Output field names %v\n", field.RFQNames(r.ResultFields))
}
示例15: Explain
// Explain implements the stmt.Statement Explain interface.
func (s *CreateUserStmt) Explain(ctx context.Context, w format.Formatter) {
w.Format("%s\n", s.Text)
}