本文整理汇总了Golang中github.com/pingcap/tidb/store/localstore/engine.Iterator.Release方法的典型用法代码示例。如果您正苦于以下问题:Golang Iterator.Release方法的具体用法?Golang Iterator.Release怎么用?Golang Iterator.Release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pingcap/tidb/store/localstore/engine.Iterator
的用法示例。
在下文中一共展示了Iterator.Release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Next
func (it *dbIter) Next(fn kv.FnKeyCmp) (kv.Iterator, error) {
encKey := codec.EncodeBytes(nil, it.startKey)
// max key
encEndKey := codec.EncodeBytes(nil, []byte{0xff, 0xff})
var retErr error
var engineIter engine.Iterator
for {
engineIter, retErr = it.s.db.Seek(encKey)
if retErr != nil {
return nil, errors.Trace(retErr)
}
// Check if overflow
if !engineIter.Next() {
it.valid = false
break
}
metaKey := engineIter.Key()
// Check if meet the end of table.
if bytes.Compare(metaKey, encEndKey) >= 0 {
it.valid = false
break
}
// Get real key from metaKey
key, _, err := MvccDecode(metaKey)
if err != nil {
// It's not a valid metaKey, maybe overflow (other data).
it.valid = false
break
}
// Get kv pair.
val, err := it.s.MvccGet(key, it.exceptedVersion)
if err != nil && !errors2.ErrorEqual(err, kv.ErrNotExist) {
// Get this version error
it.valid = false
retErr = err
break
}
if val != nil {
it.k = key
it.v = val
it.startKey = key.Next()
break
}
// Release the iterator, and update key
engineIter.Release()
// Current key's all versions are deleted, just go next key.
encKey = codec.EncodeBytes(nil, key.Next())
}
engineIter.Release()
return it, errors.Trace(retErr)
}