mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 17:02:25 +00:00
Better
This commit is contained in:
parent
7e026aec8b
commit
e2e4c8ee0f
@ -65,11 +65,25 @@ Metrics readAllMetricsFromStatFile(ReadBufferFromFile & buf)
|
||||
return metrics;
|
||||
}
|
||||
|
||||
uint64_t readMetricFromStatFile(ReadBufferFromFile & buf, const std::string & key)
|
||||
uint64_t readMetricFromStatFile(ReadBufferFromFile & buf, std::string_view key)
|
||||
{
|
||||
const auto all_metrics = readAllMetricsFromStatFile(buf);
|
||||
if (const auto it = all_metrics.find(key); it != all_metrics.end())
|
||||
return it->second;
|
||||
while (!buf.eof())
|
||||
{
|
||||
std::string current_key;
|
||||
readStringUntilWhitespace(current_key, buf);
|
||||
if (current_key != key)
|
||||
{
|
||||
std::string dummy;
|
||||
readStringUntilNewlineInto(dummy, buf);
|
||||
buf.ignore();
|
||||
continue;
|
||||
}
|
||||
|
||||
assertChar(' ', buf);
|
||||
uint64_t value = 0;
|
||||
readIntText(value, buf);
|
||||
return value;
|
||||
}
|
||||
LOG_ERROR(getLogger("CgroupsReader"), "Cannot find '{}' in '{}'", key, buf.getFileName());
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user