Improve code comments in EstimateLiveDataSize (#7072)
Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/7072 Reviewed By: ajkr Differential Revision: D22391641 Pulled By: pdillinger fbshipit-source-id: 0ef355576454514263ab684eb1a5c06787f3242a
This commit is contained in:
parent
899e59ecb7
commit
4b107ceb7e
@ -3407,22 +3407,23 @@ void VersionStorageInfo::CalculateBaseBytes(const ImmutableCFOptions& ioptions,
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t VersionStorageInfo::EstimateLiveDataSize() const {
|
uint64_t VersionStorageInfo::EstimateLiveDataSize() const {
|
||||||
// Estimate the live data size by adding up the size of the last level for all
|
// Estimate the live data size by adding up the size of a maximal set of
|
||||||
// key ranges. Note: Estimate depends on the ordering of files in level 0
|
// sst files with no range overlap in same or higher level. The less
|
||||||
// because files in level 0 can be overlapping.
|
// compacted, the more optimistic (smaller) this estimate is. Also,
|
||||||
|
// for multiple sorted runs within a level, file order will matter.
|
||||||
uint64_t size = 0;
|
uint64_t size = 0;
|
||||||
|
|
||||||
auto ikey_lt = [this](InternalKey* x, InternalKey* y) {
|
auto ikey_lt = [this](InternalKey* x, InternalKey* y) {
|
||||||
return internal_comparator_->Compare(*x, *y) < 0;
|
return internal_comparator_->Compare(*x, *y) < 0;
|
||||||
};
|
};
|
||||||
// (Ordered) map of largest keys in non-overlapping files
|
// (Ordered) map of largest keys in files being included in size estimate
|
||||||
std::map<InternalKey*, FileMetaData*, decltype(ikey_lt)> ranges(ikey_lt);
|
std::map<InternalKey*, FileMetaData*, decltype(ikey_lt)> ranges(ikey_lt);
|
||||||
|
|
||||||
for (int l = num_levels_ - 1; l >= 0; l--) {
|
for (int l = num_levels_ - 1; l >= 0; l--) {
|
||||||
bool found_end = false;
|
bool found_end = false;
|
||||||
for (auto file : files_[l]) {
|
for (auto file : files_[l]) {
|
||||||
// Find the first file where the largest key is larger than the smallest
|
// Find the first file already included with largest key is larger than
|
||||||
// key of the current file. If this file does not overlap with the
|
// the smallest key of `file`. If that file does not overlap with the
|
||||||
// current file, none of the files in the map does. If there is
|
// current file, none of the files in the map does. If there is
|
||||||
// no potential overlap, we can safely insert the rest of this level
|
// no potential overlap, we can safely insert the rest of this level
|
||||||
// (if the level is not 0) into the map without checking again because
|
// (if the level is not 0) into the map without checking again because
|
||||||
|
Loading…
Reference in New Issue
Block a user