MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / dumpNodes

Function dumpNodes

programs/keeper-utils/KeeperUtils.cpp:458–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

456}
457
458void dumpNodes(const DB::KeeperMemoryStorage & storage, const std::string & output_file, const std::string & output_format, bool parallel_output, bool with_acl)
459{
460 SharedContextHolder shared_context;
461 ContextMutablePtr global_context;
462
463 using PrintFunction = std::function<void(const std::string & key, const DB::KeeperMemoryStorage::Node & value)>;
464
465 const auto print_nodes = [&](const PrintFunction print_function)
466 {
467 std::queue<std::string> keys;
468 keys.push("/");
469 while (!keys.empty())
470 {
471 auto key = keys.front();
472 keys.pop();
473 auto value = storage.container.getValue(key);
474 print_function(key, value);
475 for (const auto & child : value.getChildren())
476 {
477 if (key == "/")
478 keys.push(fmt::format("/{}", child));
479 else
480 keys.push(fmt::format("{}/{}", key, child));
481 }
482 }
483 };
484
485 PrintFunction print_function;
486 if (!output_file.empty())
487 {
488 LOG_INFO(getLogger("keeper-utils"), "Writing nodes to {}", output_file);
489
490 shared_context = DB::Context::createShared();
491 global_context = DB::Context::createGlobal(shared_context.get());
492 global_context->makeGlobalContext();
493 DB::registerFormats();
494
495 ColumnsWithTypeAndName columns
496 {
497 {std::make_shared<DataTypeString>(), "path"},
498 {std::make_shared<DataTypeInt64>(), "czxid"},
499 {std::make_shared<DataTypeInt64>(), "mzxid"},
500 {std::make_shared<DataTypeDateTime>(), "ctime"},
501 {std::make_shared<DataTypeDateTime>(), "mtime"},
502 {std::make_shared<DataTypeInt32>(), "version"},
503 {std::make_shared<DataTypeInt32>(), "cversion"},
504 {std::make_shared<DataTypeInt32>(), "aversion"},
505 {std::make_shared<DataTypeInt64>(), "ephemeralOwner"},
506 {std::make_shared<DataTypeInt32>(), "dataLength"},
507 {std::make_shared<DataTypeInt32>(), "numChildren"},
508 {std::make_shared<DataTypeInt64>(), "pzxid"},
509 {std::make_shared<DataTypeString>(), "data"},
510 };
511
512 if (with_acl)
513 columns.emplace_back(std::make_shared<DataTypeString>(), "acl");
514
515 Block data(columns);

Callers 1

dumpStateMachineFunction · 0.85

Calls 15

registerFormatsFunction · 0.85
formatBlockFunction · 0.85
makeGlobalContextMethod · 0.80
ctimeMethod · 0.80
ephemeralOwnerMethod · 0.80
formatFunction · 0.50
getLoggerFunction · 0.50
to_stringFunction · 0.50
pushMethod · 0.45
emptyMethod · 0.45
frontMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected