Golang C.DBIterSeek类(方法)实例源码

下面列出了Golang C.DBIterSeek 类(方法)源码代码实例,从而了解它的用法。

作者:mbertschle    项目:cockroac   
func (r *rocksDBIterator) Seek(key []byte) {
	if len(key) == 0 {
		// start=Key("") needs special treatment since we need
		// to access start[0] in an explicit seek.
		r.setState(C.DBIterSeekToFirst(r.iter))
	} else {
		r.setState(C.DBIterSeek(r.iter, goToCSlice(key)))
	}
}

作者:liugangnh    项目:cockroac   
func (r *rocksDBIterator) Seek(key MVCCKey) {
	if len(key.Key) == 0 {
		// start=Key("") needs special treatment since we need
		// to access start[0] in an explicit seek.
		r.setState(C.DBIterSeekToFirst(r.iter))
	} else {
		// We can avoid seeking if we're already at the key we seek.
		if r.valid && key.Equal(r.unsafeKey()) {
			return
		}
		r.setState(C.DBIterSeek(r.iter, goToCKey(key)))
	}
}

作者:liugangnh    项目:cockroac   
func (r *rocksDBIterator) SeekReverse(key MVCCKey) {
	if len(key.Key) == 0 {
		r.setState(C.DBIterSeekToLast(r.iter))
	} else {
		r.setState(C.DBIterSeek(r.iter, goToCKey(key)))
		// Maybe the key sorts after the last key in RocksDB.
		if !r.Valid() {
			r.setState(C.DBIterSeekToLast(r.iter))
		}
		if !r.Valid() {
			return
		}
		// Make sure the current key is <= the provided key.
		if key.Less(r.Key()) {
			r.Prev()
		}
	}
}

作者:ErikGrime    项目:cockroac   
func (r *rocksDBIterator) SeekReverse(key []byte) {
	if len(key) == 0 {
		C.DBIterSeekToLast(r.iter)
	} else {
		C.DBIterSeek(r.iter, goToCSlice(key))
		// Maybe the key has exceeded the last key in rocksdb
		if !r.Valid() {
			C.DBIterSeekToLast(r.iter)
		}
		if !r.Valid() {
			return
		}
		// Make sure the current key is <= the provided key.
		curKey := r.Key()
		if proto.EncodedKey(key).Less(curKey) {
			r.Prev()
		}
	}
}


问题


面经


文章

微信
公众号

扫码关注公众号