@ -33,19 +33,6 @@
namespace ROCKSDB_NAMESPACE {
#if 0
static void DumpInternalIter ( Iterator * iter ) {
for ( iter - > SeekToFirst ( ) ; iter - > Valid ( ) ; iter - > Next ( ) ) {
ParsedInternalKey k ;
if ( ! ParseInternalKey ( iter - > key ( ) , & k ) ) {
fprintf ( stderr , " Corrupt '%s' \n " , EscapeString ( iter - > key ( ) ) . c_str ( ) ) ;
} else {
fprintf ( stderr , " @ '%s' \n " , k . DebugString ( ) . c_str ( ) ) ;
}
}
}
# endif
DBIter : : DBIter ( Env * _env , const ReadOptions & read_options ,
const ImmutableCFOptions & cf_options ,
const MutableCFOptions & mutable_cf_options ,
@ -183,7 +170,7 @@ void DBIter::Next() {
// a delete marker or a sequence number higher than sequence_
// saved_key_ MUST have a proper user_key before calling this function
//
// The prefix parameter, if not null, indicates that we need to iterator
// The prefix parameter, if not null, indicates that we need to iterate
// within the prefix, and the iterator needs to be made invalid, if no
// more entry for the prefix can be found.
bool DBIter : : FindNextUserEntry ( bool skipping_saved_key , const Slice * prefix ) {
@ -204,13 +191,14 @@ bool DBIter::FindNextUserEntryInternal(bool skipping_saved_key,
// or equal to saved_key_. We could skip these entries either because
// sequence numbers were too high or because skipping_saved_key = true.
// What saved_key_ contains throughout this method:
// - if skipping_saved_key : saved_key_ contains the key that we need
// to skip,
// and we haven't seen any keys greater than that,
// - if num_skipped > 0 : saved_key_ contains the key that we have skipped
// num_skipped times, and we haven't seen any keys
// greater than that,
// - none of the above : saved_key_ can contain anything, it doesn't matter.
// - if skipping_saved_key : saved_key_ contains the key that we need
// to skip, and we haven't seen any keys greater
// than that,
// - if num_skipped > 0 : saved_key_ contains the key that we have skipped
// num_skipped times, and we haven't seen any keys
// greater than that,
// - none of the above : saved_key_ can contain anything, it doesn't
// matter.
uint64_t num_skipped = 0 ;
// For write unprepared, the target sequence number in reseek could be larger
// than the snapshot, and thus needs to be skipped again. This could result in
@ -292,9 +280,7 @@ bool DBIter::FindNextUserEntryInternal(bool skipping_saved_key,
if ( start_seqnum_ > 0 ) {
// we are taking incremental snapshot here
// incremental snapshots aren't supported on DB with range deletes
assert ( ! (
( ikey_ . type = = kTypeBlobIndex ) & & ( start_seqnum_ > 0 )
) ) ;
assert ( ikey_ . type ! = kTypeBlobIndex ) ;
if ( ikey_ . sequence > = start_seqnum_ ) {
saved_key_ . SetInternalKey ( ikey_ ) ;
valid_ = true ;
@ -372,7 +358,7 @@ bool DBIter::FindNextUserEntryInternal(bool skipping_saved_key,
// to seek to the target sequence number.
int cmp =
user_comparator_ . Compare ( ikey_ . user_key , saved_key_ . GetUserKey ( ) ) ;
if ( cmp = = 0 | | ( skipping_saved_key & & cmp < = 0 ) ) {
if ( cmp = = 0 | | ( skipping_saved_key & & cmp < 0 ) ) {
num_skipped + + ;
} else {
saved_key_ . SetUserKey (
@ -391,7 +377,7 @@ bool DBIter::FindNextUserEntryInternal(bool skipping_saved_key,
// reseek previously.
//
// TODO(lth): If we reseek to sequence number greater than ikey_.sequence,
// tha n it does not make sense to reseek as we would actually land further
// the n it does not make sense to reseek as we would actually land further
// away from the desired key. There is opportunity for optimization here.
if ( num_skipped > max_skip_ & & ! reseek_done ) {
is_key_seqnum_zero_ = false ;
@ -1130,18 +1116,16 @@ void DBIter::Seek(const Slice& target) {
// Now the inner iterator is placed to the target position. From there,
// we need to find out the next key that is visible to the user.
//
ClearSavedValue ( ) ;
if ( prefix_same_as_start_ ) {
// The case where the iterator needs to be invalidated if it has exausted
// keys within the same prefix of the seek key.
assert ( prefix_extractor_ ! = nullptr ) ;
Slice target_prefix ;
target_prefix = prefix_extractor_ - > Transform ( target ) ;
Slice target_prefix = prefix_extractor_ - > Transform ( target ) ;
FindNextUserEntry ( false /* not skipping saved_key */ ,
& target_prefix /* prefix */ ) ;
if ( valid_ ) {
// Remember the prefix of the seek key for the future Prev () call to
// Remember the prefix of the seek key for the future Next () call to
// check.
prefix_ . SetUserKey ( target_prefix ) ;
}
@ -1197,8 +1181,7 @@ void DBIter::SeekForPrev(const Slice& target) {
// The case where the iterator needs to be invalidated if it has exausted
// keys within the same prefix of the seek key.
assert ( prefix_extractor_ ! = nullptr ) ;
Slice target_prefix ;
target_prefix = prefix_extractor_ - > Transform ( target ) ;
Slice target_prefix = prefix_extractor_ - > Transform ( target ) ;
PrevInternal ( & target_prefix ) ;
if ( valid_ ) {
// Remember the prefix of the seek key for the future Prev() call to