Fix file database statistics.
GitOrigin-RevId: 4ad707a1e8cb17dffa1b6a7b6ed299dd772a563d
This commit is contained in:
parent
1ba4a5912d
commit
d94afc648d
@ -526,16 +526,30 @@ Result<string> TdDb::get_stats() {
|
||||
TRY_STATUS(run_kv_query("gr%"));
|
||||
|
||||
std::vector<int32> prev(1);
|
||||
size_t count = 0;
|
||||
int32 max_bad_to = 0;
|
||||
size_t bad_count = 0;
|
||||
file_db_->pmc().get_by_range("file0", "file:", [&](Slice key, Slice value) {
|
||||
if (value.substr(0, 2) != "@@") {
|
||||
return true;
|
||||
}
|
||||
count++;
|
||||
auto from = to_integer<td::int32>(key.substr(4));
|
||||
auto to = to_integer<td::int32>(value.substr(2));
|
||||
CHECK(from > to);
|
||||
if (from <= to) {
|
||||
LOG(DEBUG) << "Have forward reference from " << from << " to " << to;
|
||||
if (to > max_bad_to) {
|
||||
max_bad_to = to;
|
||||
}
|
||||
bad_count++;
|
||||
return true;
|
||||
}
|
||||
if (static_cast<size_t>(from) >= prev.size()) {
|
||||
prev.resize(from + 1);
|
||||
}
|
||||
if (static_cast<size_t>(to) >= prev.size()) {
|
||||
prev.resize(to + 1);
|
||||
}
|
||||
prev[from] = to;
|
||||
return true;
|
||||
});
|
||||
@ -545,7 +559,9 @@ Result<string> TdDb::get_stats() {
|
||||
}
|
||||
prev[i] = prev[prev[i]] + 1;
|
||||
}
|
||||
sb << "Max filedb depth:" << *std::max_element(prev.begin(), prev.end()) << "\n";
|
||||
sb << "Max file database depth out of " << prev.size() << '/' << count
|
||||
<< " elements: " << *std::max_element(prev.begin(), prev.end()) << "\n";
|
||||
sb << "Have " << bad_count << " forward references with maximum reference to " << max_bad_to;
|
||||
|
||||
return sb.as_cslice().str();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user