當前位置: 首頁>>代碼示例>>Golang>>正文


Golang format.Formatter類代碼示例

本文整理匯總了Golang中github.com/pingcap/tidb/util/format.Formatter的典型用法代碼示例。如果您正苦於以下問題:Golang Formatter類的具體用法?Golang Formatter怎麽用?Golang Formatter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Formatter類的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))
}
開發者ID:lovedboy,項目名稱:tidb,代碼行數:8,代碼來源:from.go

示例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]))
}
開發者ID:superwood,項目名稱:tidb,代碼行數:9,代碼來源:final.go

示例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")
}
開發者ID:ninefive,項目名稱:tidb,代碼行數:9,代碼來源:lock.go

示例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")
}
開發者ID:Brian110,項目名稱:tidb,代碼行數:10,代碼來源:delete.go

示例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)
}
開發者ID:nengwang,項目名稱:tidb,代碼行數:10,代碼來源:select.go

示例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()))
    }

}
開發者ID:studygolang,項目名稱:tidb,代碼行數:11,代碼來源:join.go

示例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)
}
開發者ID:Brian110,項目名稱:tidb,代碼行數:12,代碼來源:update.go

示例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")
}
開發者ID:szctop,項目名稱:tidb,代碼行數:14,代碼來源:delete.go

示例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))
}
開發者ID:studygolang,項目名稱:tidb,代碼行數:16,代碼來源:join.go

示例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))
}
開發者ID:H0bby,項目名稱:tidb,代碼行數:10,代碼來源:fields.go

示例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))
}
開發者ID:no2key,項目名稱:tidb,代碼行數:16,代碼來源:orderby.go

示例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()))
}
開發者ID:kevinhuo88888,項目名稱:tidb,代碼行數:16,代碼來源:index.go

示例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)
}
開發者ID:ninefive,項目名稱:tidb,代碼行數:5,代碼來源:limit.go

示例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))
}
開發者ID:szctop,項目名稱:tidb,代碼行數:19,代碼來源:groupby.go

示例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)
}
開發者ID:remotesyssupport,項目名稱:tidb,代碼行數:4,代碼來源:account_manage.go


注:本文中的github.com/pingcap/tidb/util/format.Formatter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。