本文整理汇总了Golang中github.com/pingcap/tidb/kv.Index类的典型用法代码示例。如果您正苦于以下问题:Golang Index类的具体用法?Golang Index怎么用?Golang Index使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Index类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Do
// Do implements plan.Plan Do interface.
func (r *selectIndexDefaultPlan) Do(ctx context.Context, f plan.RowIterFunc) (err error) {
var x kv.Index
switch ix := r.x.(type) {
case *column.IndexedCol:
x = ix.X
default:
panic("should never happen")
}
txn, err := ctx.GetTxn(false)
if err != nil {
return err
}
en, err := x.SeekFirst(txn)
if err != nil {
return types.EOFAsNil(err)
}
defer en.Close()
var id int64
for {
k, _, err := en.Next()
if err != nil {
return types.EOFAsNil(err)
}
id++
if more, err := f(id, k); !more || err != nil {
return err
}
}
}
开发者ID:szctop,项目名称:tidb,代码行数:33,代码来源:plans.go
示例2: ScanIndexData
// ScanIndexData scans the index handles and values in a limited number, according to the index information.
// It returns data and the next startVals until it doesn't have data, then returns data is nil and
// the next startVals is the values which can't get data. If startVals = nil and limit = -1,
// it returns the index data of the whole.
func ScanIndexData(txn kv.Transaction, kvIndex kv.Index, startVals []interface{}, limit int64) (
[]*RecordData, []interface{}, error) {
it, _, err := kvIndex.Seek(txn, startVals)
if err != nil {
return nil, nil, errors.Trace(err)
}
defer it.Close()
var idxRows []*RecordData
var curVals []interface{}
for limit != 0 {
val, h, err1 := it.Next()
if terror.ErrorEqual(err1, io.EOF) {
return idxRows, nextIndexVals(curVals), nil
} else if err1 != nil {
return nil, nil, errors.Trace(err1)
}
idxRows = append(idxRows, &RecordData{Handle: h, Values: val})
limit--
curVals = val
}
nextVals, _, err := it.Next()
if terror.ErrorEqual(err, io.EOF) {
return idxRows, nextIndexVals(curVals), nil
} else if err != nil {
return nil, nil, errors.Trace(err)
}
return idxRows, nextVals, nil
}
开发者ID:youprofit,项目名称:tidb,代码行数:35,代码来源:inspectkv.go
示例3: GetIndexRecordsCount
// GetIndexRecordsCount returns the total number of the index records from startVals.
// If startVals = nil, returns the total number of the index records.
func GetIndexRecordsCount(txn kv.Transaction, kvIndex kv.Index, startVals []interface{}) (int64, error) {
it, _, err := kvIndex.Seek(txn, startVals)
if err != nil {
return 0, errors.Trace(err)
}
defer it.Close()
var cnt int64
for {
_, _, err := it.Next()
if terror.ErrorEqual(err, io.EOF) {
break
} else if err != nil {
return 0, errors.Trace(err)
}
cnt++
}
return cnt, nil
}
开发者ID:youprofit,项目名称:tidb,代码行数:22,代码来源:inspectkv.go
注:本文中的github.com/pingcap/tidb/kv.Index类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论