-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Truncate range tombstones by leveraging InternalKeys #4432
Closed
abhimadan
wants to merge
6
commits into
facebook:master
from
abhimadan:range-del-agg-trunc-fix-intkey
Closed
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f502dd6
Truncate RangeTombstones by leveraging InternalKeys
abhimadan 7923a12
Improve a comment, fix clang compile error
abhimadan ce5d472
Address PR comments, actually use compaction boundaries
abhimadan 7820f5e
Include tombstones that start at next SST's smallest key
abhimadan 45aa08e
Fix linter errors
abhimadan e8d49e0
Remove default initialization (disallows initializer list)
abhimadan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,55 @@ void Compaction::GetBoundaryKeys( | |
} | ||
} | ||
|
||
std::vector<CompactionInputFiles> Compaction::PopulateWithAtomicBoundaries( | ||
VersionStorageInfo* vstorage, std::vector<CompactionInputFiles> inputs) { | ||
const Comparator* ucmp = vstorage->InternalComparator()->user_comparator(); | ||
for (size_t i = 0; i < inputs.size(); i++) { | ||
if (inputs[i].level == 0 || inputs[i].files.empty()) { | ||
continue; | ||
} | ||
inputs[i].atomic_compaction_unit_boundaries.reserve(inputs[i].files.size()); | ||
AtomicCompactionUnitBoundary cur_boundary; | ||
uint64_t cur_end_key_footer = 0; | ||
size_t first_atomic_idx = 0; | ||
auto add_unit_boundary = [&](size_t to) { | ||
if (first_atomic_idx == to) return; | ||
for (size_t k = first_atomic_idx; k < to; k++) { | ||
inputs[i].atomic_compaction_unit_boundaries.push_back(cur_boundary); | ||
} | ||
first_atomic_idx = to; | ||
}; | ||
for (size_t j = 0; j < inputs[i].files.size(); j++) { | ||
const auto* f = inputs[i].files[j]; | ||
const Slice& start_user_key = f->smallest.user_key(); | ||
const Slice& end_user_key = f->largest.user_key(); | ||
if (first_atomic_idx == j) { | ||
// First file in an atomic compaction unit. | ||
cur_boundary.smallest = start_user_key; | ||
cur_boundary.largest = end_user_key; | ||
} else if (ucmp->Compare(cur_boundary.largest, start_user_key) == 0 && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think it's possible to reuse There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it is possible! Thanks for pointing that out. |
||
cur_end_key_footer != | ||
PackSequenceAndType(kMaxSequenceNumber, | ||
kTypeRangeDeletion)) { | ||
// SSTs overlap but the end key of the previous file was not | ||
// artificially extended by a range tombstone. Extend the current | ||
// boundary. | ||
cur_boundary.largest = end_user_key; | ||
} else { | ||
// Atomic compaction unit has ended. | ||
add_unit_boundary(j); | ||
cur_boundary.smallest = start_user_key; | ||
cur_boundary.largest = end_user_key; | ||
} | ||
cur_end_key_footer = ExtractInternalKeyFooter(f->largest.Encode()); | ||
} | ||
add_unit_boundary(inputs[i].files.size()); | ||
assert(inputs[i].files.size() == | ||
inputs[i].atomic_compaction_unit_boundaries.size()); | ||
} | ||
return inputs; | ||
} | ||
|
||
// helper function to determine if compaction is creating files at the | ||
// bottommost level | ||
bool Compaction::IsBottommostLevel( | ||
|
@@ -155,7 +204,7 @@ Compaction::Compaction(VersionStorageInfo* vstorage, | |
output_compression_(_compression), | ||
output_compression_opts_(_compression_opts), | ||
deletion_compaction_(_deletion_compaction), | ||
inputs_(std::move(_inputs)), | ||
inputs_(PopulateWithAtomicBoundaries(vstorage, std::move(_inputs))), | ||
grandparents_(std::move(_grandparents)), | ||
score_(_score), | ||
bottommost_level_(IsBottommostLevel(output_level_, vstorage, inputs_)), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can only happen when
j == 0
, right?