mirror of https://github.com/facebook/rocksdb.git
Reserve vector in advance to avoid resizing in GetLiveFilesMetaData (#12554)
Summary: As title Pull Request resolved: https://github.com/facebook/rocksdb/pull/12554 Test Plan: Existing CI Reviewed By: ajkr Differential Revision: D56252201 Pulled By: jaykorean fbshipit-source-id: 06211555a54ce5e6bf656b81109022494e6787ea
This commit is contained in:
parent
3bbacda9b1
commit
02ea0d6367
|
@ -7137,6 +7137,20 @@ Status VersionSet::GetMetadataForFile(uint64_t number, int* filelevel,
|
|||
}
|
||||
|
||||
void VersionSet::GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata) {
|
||||
if (!metadata) {
|
||||
return;
|
||||
}
|
||||
assert(metadata);
|
||||
size_t count = 0;
|
||||
for (auto cfd : *column_family_set_) {
|
||||
if (cfd->IsDropped() || !cfd->initialized()) {
|
||||
continue;
|
||||
}
|
||||
for (int level = 0; level < cfd->NumberLevels(); level++) {
|
||||
count += cfd->current()->storage_info()->LevelFiles(level).size();
|
||||
}
|
||||
}
|
||||
metadata->reserve(count);
|
||||
for (auto cfd : *column_family_set_) {
|
||||
if (cfd->IsDropped() || !cfd->initialized()) {
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue