diff --git a/db/db_impl.cc b/db/db_impl.cc index d1a343a76..e7bda3cf8 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -2055,13 +2055,13 @@ Status DBImpl::DeleteFilesInRange(ColumnFamilyHandle* column_family, if (begin == nullptr) { begin_key = nullptr; } else { - begin_storage.SetMaxPossibleForUserKey(*begin); + begin_storage.SetMinPossibleForUserKey(*begin); begin_key = &begin_storage; } if (end == nullptr) { end_key = nullptr; } else { - end_storage.SetMinPossibleForUserKey(*end); + end_storage.SetMaxPossibleForUserKey(*end); end_key = &end_storage; } diff --git a/db/db_impl_compaction_flush.cc b/db/db_impl_compaction_flush.cc index 3e686fe70..18e2e88da 100644 --- a/db/db_impl_compaction_flush.cc +++ b/db/db_impl_compaction_flush.cc @@ -826,7 +826,7 @@ Status DBImpl::RunManualCompaction(ColumnFamilyData* cfd, int input_level, cfd->ioptions()->compaction_style == kCompactionStyleFIFO) { manual.begin = nullptr; } else { - begin_storage.SetMaxPossibleForUserKey(*begin); + begin_storage.SetMinPossibleForUserKey(*begin); manual.begin = &begin_storage; } if (end == nullptr || @@ -834,7 +834,7 @@ Status DBImpl::RunManualCompaction(ColumnFamilyData* cfd, int input_level, cfd->ioptions()->compaction_style == kCompactionStyleFIFO) { manual.end = nullptr; } else { - end_storage.SetMinPossibleForUserKey(*end); + end_storage.SetMaxPossibleForUserKey(*end); manual.end = &end_storage; } diff --git a/db/db_impl_experimental.cc b/db/db_impl_experimental.cc index 0d010758e..ac1aa4fda 100644 --- a/db/db_impl_experimental.cc +++ b/db/db_impl_experimental.cc @@ -30,10 +30,10 @@ Status DBImpl::SuggestCompactRange(ColumnFamilyHandle* column_family, auto cfd = cfh->cfd(); InternalKey start_key, end_key; if (begin != nullptr) { - start_key.SetMaxPossibleForUserKey(*begin); + start_key.SetMinPossibleForUserKey(*begin); } if (end != nullptr) { - end_key.SetMinPossibleForUserKey(*end); + end_key.SetMaxPossibleForUserKey(*end); } { InstrumentedMutexLock l(&mutex_); diff --git a/db/dbformat.h b/db/dbformat.h index 04d1f87f0..187069cd0 100644 --- a/db/dbformat.h +++ b/db/dbformat.h @@ -181,15 +181,15 @@ class InternalKey { // sets the internal key to be bigger or equal to all internal keys with this // user key void SetMaxPossibleForUserKey(const Slice& _user_key) { - AppendInternalKey(&rep_, ParsedInternalKey(_user_key, kMaxSequenceNumber, - kValueTypeForSeek)); + AppendInternalKey( + &rep_, ParsedInternalKey(_user_key, 0, static_cast(0))); } // sets the internal key to be smaller or equal to all internal keys with this // user key void SetMinPossibleForUserKey(const Slice& _user_key) { - AppendInternalKey( - &rep_, ParsedInternalKey(_user_key, 0, static_cast(0))); + AppendInternalKey(&rep_, ParsedInternalKey(_user_key, kMaxSequenceNumber, + kValueTypeForSeek)); } bool Valid() const { diff --git a/db/version_set.cc b/db/version_set.cc index 823818210..870edb6e7 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -408,9 +408,9 @@ bool SomeFileOverlapsRange( // Binary search over file list uint32_t index = 0; if (smallest_user_key != nullptr) { - // Find the earliest possible internal key for smallest_user_key + // Find the leftmost possible internal key for smallest_user_key InternalKey small; - small.SetMaxPossibleForUserKey(*smallest_user_key); + small.SetMinPossibleForUserKey(*smallest_user_key); index = FindFile(icmp, file_level, small.Encode()); } diff --git a/tools/sst_dump_tool.cc b/tools/sst_dump_tool.cc index 4dca284cc..db78268b4 100644 --- a/tools/sst_dump_tool.cc +++ b/tools/sst_dump_tool.cc @@ -296,7 +296,7 @@ Status SstFileReader::ReadSequential(bool print_kv, uint64_t read_num, uint64_t i = 0; if (has_from) { InternalKey ikey; - ikey.SetMaxPossibleForUserKey(from_key); + ikey.SetMinPossibleForUserKey(from_key); iter->Seek(ikey.Encode()); } else { iter->SeekToFirst(); diff --git a/utilities/debug.cc b/utilities/debug.cc index ce0b9580c..f9a69f476 100644 --- a/utilities/debug.cc +++ b/utilities/debug.cc @@ -24,7 +24,7 @@ Status GetAllKeyVersions(DB* db, Slice begin_key, Slice end_key, if (!begin_key.empty()) { InternalKey ikey; - ikey.SetMaxPossibleForUserKey(begin_key); + ikey.SetMinPossibleForUserKey(begin_key); iter->Seek(ikey.Encode()); } else { iter->SeekToFirst();