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))) } }
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))) } }
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() } } }
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() } } }
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() } } }