Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapse range deletions #1614

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions db/range_del_aggregator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool RangeDelAggregator::ShouldDelete(const ParsedInternalKey& parsed) {
}
const auto& tombstone_map = GetTombstoneMap(parsed.sequence);
if (collapse_deletions_) {
auto iter = tombstone_map.upper_bound(parsed.user_key.ToString());
auto iter = tombstone_map.upper_bound(parsed.user_key);
if (iter == tombstone_map.begin()) {
return false;
}
Expand Down Expand Up @@ -179,7 +179,6 @@ Status RangeDelAggregator::AddTombstone(RangeTombstone tombstone) {
// raising the seqnum for the to-be-inserted element (we insert the max
// seqnum between the next new interval and the unterminated interval).
SequenceNumber untermed_seq = kMaxSequenceNumber;
SequenceNumber prev_seen_seq = 0;
while (tombstone_map_iter != tombstone_map.end() &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job getting rid of this variable. it make the state transition simpler.

new_range_dels_iter != new_range_dels.end()) {
const Slice *tombstone_map_iter_end = nullptr,
Expand Down Expand Up @@ -229,7 +228,9 @@ Status RangeDelAggregator::AddTombstone(RangeTombstone tombstone) {
// it's covered.
if (tombstone_map_iter->second.seq_ < new_range_dels_iter->seq_) {
untermed_seq = tombstone_map_iter->second.seq_;
if (prev_seen_seq == new_range_dels_iter->seq_) {
if (tombstone_map_iter != tombstone_map.begin() &&
std::prev(tombstone_map_iter)->second.seq_ ==
new_range_dels_iter->seq_) {
tombstone_map_iter = tombstone_map.erase(tombstone_map_iter);
--tombstone_map_iter;
} else {
Expand Down Expand Up @@ -262,7 +263,6 @@ Status RangeDelAggregator::AddTombstone(RangeTombstone tombstone) {

// advance whichever one ends earlier, or both if their right endpoints
// coincide
prev_seen_seq = tombstone_map_iter->second.seq_;
if (new_to_old_end_cmp < 0) {
++new_range_dels_iter;
} else if (new_to_old_end_cmp > 0) {
Expand Down