Fix naming in InternalKey

Summary:
- Switched all instances of SetMinPossibleForUserKey and SetMaxPossibleForUserKey in accordance to InternalKeyComparator's comparison logic
Closes https://github.com/facebook/rocksdb/pull/2868

Differential Revision: D5804152

Pulled By: axxufb

fbshipit-source-id: 80be35e04f2e8abc35cc64abe1fecb03af24e183
main
Amy Xu 7 years ago committed by Facebook Github Bot
parent 82860bd55c
commit 5785b1fcb8
  1. 4
      db/db_impl.cc
  2. 4
      db/db_impl_compaction_flush.cc
  3. 4
      db/db_impl_experimental.cc
  4. 8
      db/dbformat.h
  5. 4
      db/version_set.cc
  6. 2
      tools/sst_dump_tool.cc
  7. 2
      utilities/debug.cc

@ -2055,13 +2055,13 @@ Status DBImpl::DeleteFilesInRange(ColumnFamilyHandle* column_family,
if (begin == nullptr) { if (begin == nullptr) {
begin_key = nullptr; begin_key = nullptr;
} else { } else {
begin_storage.SetMaxPossibleForUserKey(*begin); begin_storage.SetMinPossibleForUserKey(*begin);
begin_key = &begin_storage; begin_key = &begin_storage;
} }
if (end == nullptr) { if (end == nullptr) {
end_key = nullptr; end_key = nullptr;
} else { } else {
end_storage.SetMinPossibleForUserKey(*end); end_storage.SetMaxPossibleForUserKey(*end);
end_key = &end_storage; end_key = &end_storage;
} }

@ -826,7 +826,7 @@ Status DBImpl::RunManualCompaction(ColumnFamilyData* cfd, int input_level,
cfd->ioptions()->compaction_style == kCompactionStyleFIFO) { cfd->ioptions()->compaction_style == kCompactionStyleFIFO) {
manual.begin = nullptr; manual.begin = nullptr;
} else { } else {
begin_storage.SetMaxPossibleForUserKey(*begin); begin_storage.SetMinPossibleForUserKey(*begin);
manual.begin = &begin_storage; manual.begin = &begin_storage;
} }
if (end == nullptr || if (end == nullptr ||
@ -834,7 +834,7 @@ Status DBImpl::RunManualCompaction(ColumnFamilyData* cfd, int input_level,
cfd->ioptions()->compaction_style == kCompactionStyleFIFO) { cfd->ioptions()->compaction_style == kCompactionStyleFIFO) {
manual.end = nullptr; manual.end = nullptr;
} else { } else {
end_storage.SetMinPossibleForUserKey(*end); end_storage.SetMaxPossibleForUserKey(*end);
manual.end = &end_storage; manual.end = &end_storage;
} }

@ -30,10 +30,10 @@ Status DBImpl::SuggestCompactRange(ColumnFamilyHandle* column_family,
auto cfd = cfh->cfd(); auto cfd = cfh->cfd();
InternalKey start_key, end_key; InternalKey start_key, end_key;
if (begin != nullptr) { if (begin != nullptr) {
start_key.SetMaxPossibleForUserKey(*begin); start_key.SetMinPossibleForUserKey(*begin);
} }
if (end != nullptr) { if (end != nullptr) {
end_key.SetMinPossibleForUserKey(*end); end_key.SetMaxPossibleForUserKey(*end);
} }
{ {
InstrumentedMutexLock l(&mutex_); InstrumentedMutexLock l(&mutex_);

@ -181,15 +181,15 @@ class InternalKey {
// sets the internal key to be bigger or equal to all internal keys with this // sets the internal key to be bigger or equal to all internal keys with this
// user key // user key
void SetMaxPossibleForUserKey(const Slice& _user_key) { void SetMaxPossibleForUserKey(const Slice& _user_key) {
AppendInternalKey(&rep_, ParsedInternalKey(_user_key, kMaxSequenceNumber, AppendInternalKey(
kValueTypeForSeek)); &rep_, ParsedInternalKey(_user_key, 0, static_cast<ValueType>(0)));
} }
// sets the internal key to be smaller or equal to all internal keys with this // sets the internal key to be smaller or equal to all internal keys with this
// user key // user key
void SetMinPossibleForUserKey(const Slice& _user_key) { void SetMinPossibleForUserKey(const Slice& _user_key) {
AppendInternalKey( AppendInternalKey(&rep_, ParsedInternalKey(_user_key, kMaxSequenceNumber,
&rep_, ParsedInternalKey(_user_key, 0, static_cast<ValueType>(0))); kValueTypeForSeek));
} }
bool Valid() const { bool Valid() const {

@ -408,9 +408,9 @@ bool SomeFileOverlapsRange(
// Binary search over file list // Binary search over file list
uint32_t index = 0; uint32_t index = 0;
if (smallest_user_key != nullptr) { 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; InternalKey small;
small.SetMaxPossibleForUserKey(*smallest_user_key); small.SetMinPossibleForUserKey(*smallest_user_key);
index = FindFile(icmp, file_level, small.Encode()); index = FindFile(icmp, file_level, small.Encode());
} }

@ -296,7 +296,7 @@ Status SstFileReader::ReadSequential(bool print_kv, uint64_t read_num,
uint64_t i = 0; uint64_t i = 0;
if (has_from) { if (has_from) {
InternalKey ikey; InternalKey ikey;
ikey.SetMaxPossibleForUserKey(from_key); ikey.SetMinPossibleForUserKey(from_key);
iter->Seek(ikey.Encode()); iter->Seek(ikey.Encode());
} else { } else {
iter->SeekToFirst(); iter->SeekToFirst();

@ -24,7 +24,7 @@ Status GetAllKeyVersions(DB* db, Slice begin_key, Slice end_key,
if (!begin_key.empty()) { if (!begin_key.empty()) {
InternalKey ikey; InternalKey ikey;
ikey.SetMaxPossibleForUserKey(begin_key); ikey.SetMinPossibleForUserKey(begin_key);
iter->Seek(ikey.Encode()); iter->Seek(ikey.Encode());
} else { } else {
iter->SeekToFirst(); iter->SeekToFirst();

Loading…
Cancel
Save