MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / AttachedLbugDatabase

Method AttachedLbugDatabase

src/main/attached_database.cpp:49–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49AttachedLbugDatabase::AttachedLbugDatabase(std::string dbPath, std::string dbName,
50 std::string dbType, ClientContext* clientContext)
51 : AttachedDatabase{std::move(dbName), std::move(dbType), nullptr /* catalog */} {
52 auto vfs = common::VirtualFileSystem::GetUnsafe(*clientContext);
53 if (DBConfig::isDBPathInMemory(dbPath)) {
54 throw common::RuntimeException("Cannot attach an in-memory Lbug database. Please give a "
55 "path to an on-disk Lbug database directory.");
56 }
57 auto path = vfs->expandPath(clientContext, dbPath);
58 // Note: S3 directory path may end with a '/'.
59 if (path.ends_with('/')) {
60 path = path.substr(0, path.size() - 1);
61 }
62 if (!vfs->fileOrPathExists(path, clientContext)) {
63 throw common::RuntimeException(
64 std::format("Cannot attach a remote Lbug database due to invalid path: {}.", path));
65 }
66 catalog = std::make_unique<catalog::Catalog>();
67 validateEmptyWAL(path, clientContext);
68 storageManager = std::make_unique<storage::StorageManager>(path, true /* isReadOnly */,
69 clientContext->getDBConfig()->enableChecksums, *storage::MemoryManager::Get(*clientContext),
70 clientContext->getDBConfig()->enableCompression,
71 clientContext->getDBConfig()->enableDefaultHashIndex, vfs);
72 transactionManager =
73 std::make_unique<transaction::TransactionManager>(storageManager->getWAL());
74
75 storageManager->initDataFileHandle(vfs, clientContext);
76 if (storageManager->getDataFH()->getNumPages() > 0) {
77 storage::Checkpointer::readCheckpoint(clientContext, catalog.get(), storageManager.get());
78 }
79}
80
81} // namespace main
82} // namespace lbug

Callers

nothing calls this directly

Calls 9

validateEmptyWALFunction · 0.85
getDBConfigMethod · 0.80
initDataFileHandleMethod · 0.80
expandPathMethod · 0.45
sizeMethod · 0.45
fileOrPathExistsMethod · 0.45
getNumPagesMethod · 0.45
getDataFHMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected