MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetProperty

Method GetProperty

src/leveldb/db/db_impl.cc:1383–1443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1381}
1382
1383bool DBImpl::GetProperty(const Slice& property, std::string* value) {
1384 value->clear();
1385
1386 MutexLock l(&mutex_);
1387 Slice in = property;
1388 Slice prefix("leveldb.");
1389 if (!in.starts_with(prefix)) return false;
1390 in.remove_prefix(prefix.size());
1391
1392 if (in.starts_with("num-files-at-level")) {
1393 in.remove_prefix(strlen("num-files-at-level"));
1394 uint64_t level;
1395 bool ok = ConsumeDecimalNumber(&in, &level) && in.empty();
1396 if (!ok || level >= config::kNumLevels) {
1397 return false;
1398 } else {
1399 char buf[100];
1400 snprintf(buf, sizeof(buf), "%d",
1401 versions_->NumLevelFiles(static_cast<int>(level)));
1402 *value = buf;
1403 return true;
1404 }
1405 } else if (in == "stats") {
1406 char buf[200];
1407 snprintf(buf, sizeof(buf),
1408 " Compactions\n"
1409 "Level Files Size(MB) Time(sec) Read(MB) Write(MB)\n"
1410 "--------------------------------------------------\n");
1411 value->append(buf);
1412 for (int level = 0; level < config::kNumLevels; level++) {
1413 int files = versions_->NumLevelFiles(level);
1414 if (stats_[level].micros > 0 || files > 0) {
1415 snprintf(buf, sizeof(buf), "%3d %8d %8.0f %9.0f %8.0f %9.0f\n", level,
1416 files, versions_->NumLevelBytes(level) / 1048576.0,
1417 stats_[level].micros / 1e6,
1418 stats_[level].bytes_read / 1048576.0,
1419 stats_[level].bytes_written / 1048576.0);
1420 value->append(buf);
1421 }
1422 }
1423 return true;
1424 } else if (in == "sstables") {
1425 *value = versions_->current()->DebugString();
1426 return true;
1427 } else if (in == "approximate-memory-usage") {
1428 size_t total_usage = options_.block_cache->TotalCharge();
1429 if (mem_) {
1430 total_usage += mem_->ApproximateMemoryUsage();
1431 }
1432 if (imm_) {
1433 total_usage += imm_->ApproximateMemoryUsage();
1434 }
1435 char buf[50];
1436 snprintf(buf, sizeof(buf), "%llu",
1437 static_cast<unsigned long long>(total_usage));
1438 value->append(buf);
1439 return true;
1440 }

Callers 5

DynamicMemoryUsageMethod · 0.45
TESTFunction · 0.45
PrintStatsMethod · 0.45
PropertyMethod · 0.45
leveldb_property_valueFunction · 0.45

Calls 10

ConsumeDecimalNumberFunction · 0.85
NumLevelFilesMethod · 0.80
NumLevelBytesMethod · 0.80
currentMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
DebugStringMethod · 0.45
TotalChargeMethod · 0.45

Tested by 2

TESTFunction · 0.36
PropertyMethod · 0.36