コード例 #1
0
ファイル: rocksdb.go プロジェクト: liugangnhm/cockroach
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()
		}
	}
}
コード例 #2
0
ファイル: rocksdb.go プロジェクト: ErikGrimes/cockroach
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()
		}
	}
}
コード例 #3
0
func (r *rocksDBIterator) SeekReverse(key MVCCKey) {
	r.checkEngineOpen()
	if len(key.Key) == 0 {
		r.setState(C.DBIterSeekToLast(r.iter))
	} else {
		// We can avoid seeking if we're already at the key we seek.
		if r.valid && !r.reseek && key.Equal(r.unsafeKey()) {
			return
		}
		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.unsafeKey()) {
			r.Prev()
		}
	}
}