本文整理匯總了Golang中github.com/pingcap/tidb/optimizer/plan.IndexScan類的典型用法代碼示例。如果您正苦於以下問題:Golang IndexScan類的具體用法?Golang IndexScan怎麽用?Golang IndexScan使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IndexScan類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: buildIndexScan
func (b *executorBuilder) buildIndexScan(v *plan.IndexScan) Executor {
tbl, _ := b.is.TableByID(v.Table.ID)
var idx *column.IndexedCol
for _, val := range tbl.Indices() {
if val.IndexInfo.Name.L == v.Index.Name.L {
idx = val
break
}
}
e := &IndexScanExec{
tbl: tbl,
idx: idx,
fields: v.Fields(),
ctx: b.ctx,
Desc: v.Desc,
valueTypes: make([]*types.FieldType, len(idx.Columns)),
}
for i, ic := range idx.Columns {
col := tbl.Cols()[ic.Offset]
e.valueTypes[i] = &col.FieldType
}
e.Ranges = make([]*IndexRangeExec, len(v.Ranges))
for i, val := range v.Ranges {
e.Ranges[i] = b.buildIndexRange(e, val)
}
return e
}
示例2: buildIndexScan
func (b *executorBuilder) buildIndexScan(v *plan.IndexScan) Executor {
txn, err := b.ctx.GetTxn(false)
if err != nil {
b.err = err
return nil
}
tbl, _ := b.is.TableByID(v.Table.ID)
client := txn.GetClient()
var memDB bool
switch v.Fields()[0].DBName.L {
case "information_schema", "performance_schema":
memDB = true
}
if !memDB && client.SupportRequestType(kv.ReqTypeIndex, 0) && txn.IsReadOnly() {
log.Debug("xapi select index")
e := &XSelectIndexExec{
table: tbl,
ctx: b.ctx,
indexPlan: v,
}
where := conditionsToPBExpression(v.FilterConditions...)
if xapi.SupportExpression(client, where) {
e.where = where
return e
}
return b.buildFilter(e, v.FilterConditions)
}
var idx *column.IndexedCol
for _, val := range tbl.Indices() {
if val.IndexInfo.Name.L == v.Index.Name.L {
idx = val
break
}
}
e := &IndexScanExec{
tbl: tbl,
idx: idx,
fields: v.Fields(),
ctx: b.ctx,
Desc: v.Desc,
valueTypes: make([]*types.FieldType, len(idx.Columns)),
}
for i, ic := range idx.Columns {
col := tbl.Cols()[ic.Offset]
e.valueTypes[i] = &col.FieldType
}
e.Ranges = make([]*IndexRangeExec, len(v.Ranges))
for i, val := range v.Ranges {
e.Ranges[i] = b.buildIndexRange(e, val)
}
return b.buildFilter(e, v.FilterConditions)
}