Tomislav Novak 187b29938c ForwardIterator: update prev_key_ only if prefix hasn't changed
Summary:
Since ForwardIterator is on a level below DBIter, the latter may call Next() on
it (e.g. in order to skip deletion markers). Since this also updates
`prev_key_`, it may prevent the Seek() optimization.

For example, assume that there's only one SST file and it contains the following
entries: 0101, 0201 (`ValueType::kTypeDeletion`, i.e. a tombstone record), 0201
(`kTypeValue`), 0202. Memtable is empty. `Seek(0102)` will result in `prev_key_`
being set to `0201` instead of `0102`, since `DBIter::Seek()` will call
`ForwardIterator::Next()` to skip record 0201. Therefore, when `Seek(0102)` is
called again, `NeedToSeekImmutable()` will return true.

This fix relies on `prefix_extractor_` to detect prefix changes. `prev_key_` is
only set to `current_->key()` as long as they have the same prefix.

I also made a small change to `NeedToSeekImmutable()` so it no longer returns
true when the db is empty (i.e. there's nothing but a memtable).

Test Plan:
   $ TEST_TMPDIR=/dev/shm/rocksdbtest ROCKSDB_TESTS=TailingIterator ./db_test

Reviewers: sdong, igor, ljin

Reviewed By: ljin

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D23823
2014-10-01 17:10:48 -07:00
..
2014-09-04 16:18:36 -07:00
2014-09-04 16:18:36 -07:00
2014-09-24 13:12:16 -07:00
2014-09-29 16:05:25 -07:00
2014-09-12 16:23:58 -07:00
2014-09-25 11:14:01 -07:00
2014-08-28 17:06:29 -07:00
2014-09-04 23:06:23 +08:00
2014-09-18 13:32:44 -07:00
2014-09-05 14:14:37 +08:00
2014-09-05 14:14:37 +08:00
2014-02-28 13:19:47 -08:00
2014-01-27 14:49:10 -08:00
2014-03-14 22:44:35 +00:00
2014-03-14 13:02:20 -07:00
2014-01-30 22:10:10 -08:00
2014-09-04 23:06:23 +08:00
2014-04-15 13:39:26 -07:00
2014-09-13 14:14:10 -07:00
2014-09-12 16:23:58 -07:00
2014-09-12 16:23:58 -07:00