Skip to content

Commit

Permalink
update IterKey that can get user key and internal key explicitly
Browse files Browse the repository at this point in the history
Summary:
to void future bug that caused by the mix of userkey/internalkey
Closes facebook#2084

Differential Revision: D4825889

Pulled By: lightmark

fbshipit-source-id: 28411db
  • Loading branch information
lightmark authored and facebook-github-bot committed Apr 4, 2017
1 parent e2c6c06 commit 90cfd46
Show file tree
Hide file tree
Showing 15 changed files with 176 additions and 139 deletions.
10 changes: 5 additions & 5 deletions db/compaction_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void CompactionIterator::Next() {
assert(valid_key);
// Keep current_key_ in sync.
current_key_.UpdateInternalKey(ikey_.sequence, ikey_.type);
key_ = current_key_.GetKey();
key_ = current_key_.GetInternalKey();
ikey_.user_key = current_key_.GetUserKey();
valid_ = true;
} else {
Expand Down Expand Up @@ -151,7 +151,7 @@ void CompactionIterator::NextFromInput() {
status_ = Status::Corruption("Corrupted internal key not expected.");
break;
}
key_ = current_key_.SetKey(key_);
key_ = current_key_.SetInternalKey(key_);
has_current_user_key_ = false;
current_user_key_sequence_ = kMaxSequenceNumber;
current_user_key_snapshot_ = 0;
Expand Down Expand Up @@ -181,7 +181,7 @@ void CompactionIterator::NextFromInput() {
!cmp_->Equal(ikey_.user_key, current_user_key_)) {
// First occurrence of this user key
// Copy key for output
key_ = current_key_.SetKey(key_, &ikey_);
key_ = current_key_.SetInternalKey(key_, &ikey_);
current_user_key_ = ikey_.user_key;
has_current_user_key_ = true;
has_outputted_key_ = false;
Expand Down Expand Up @@ -241,7 +241,7 @@ void CompactionIterator::NextFromInput() {
// Need to have the compaction filter process multiple versions
// if we have versions on both sides of a snapshot
current_key_.UpdateInternalKey(ikey_.sequence, ikey_.type);
key_ = current_key_.GetKey();
key_ = current_key_.GetInternalKey();
ikey_.user_key = current_key_.GetUserKey();
}

Expand Down Expand Up @@ -453,7 +453,7 @@ void CompactionIterator::NextFromInput() {
assert(valid_key);
// Keep current_key_ in sync.
current_key_.UpdateInternalKey(ikey_.sequence, ikey_.type);
key_ = current_key_.GetKey();
key_ = current_key_.GetInternalKey();
ikey_.user_key = current_key_.GetUserKey();
valid_ = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion db/compaction_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) {
if (start != nullptr) {
IterKey start_iter;
start_iter.SetInternalKey(*start, kMaxSequenceNumber, kValueTypeForSeek);
input->Seek(start_iter.GetKey());
input->Seek(start_iter.GetInternalKey());
} else {
input->SeekToFirst();
}
Expand Down
Loading

0 comments on commit 90cfd46

Please sign in to comment.