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

Method initMembers

src/main/database.cpp:103–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void Database::initMembers(std::string_view dbPath, construct_bm_func_t initBmFunc) {
104 // To expand a path with home directory(~), we have to pass in a dummy clientContext which
105 // handles the home directory expansion.
106 const auto dbPathStr = std::string(dbPath);
107 auto clientContext = ClientContext(this);
108 databasePath = StorageUtils::expandPath(&clientContext, dbPathStr);
109 clientContext.addDBDirToFileSearchPath(databasePath);
110
111 if (std::filesystem::is_directory(databasePath)) {
112 throw RuntimeException("Database path cannot be a directory: " + databasePath);
113 }
114 vfs = std::make_unique<VirtualFileSystem>(databasePath);
115 validatePathInReadOnly();
116
117 bufferManager = initBmFunc(*this);
118 memoryManager = std::make_unique<MemoryManager>(bufferManager.get(), vfs.get());
119#if defined(__APPLE__)
120 queryProcessor =
121 std::make_unique<processor::QueryProcessor>(dbConfig->maxNumThreads, dbConfig->threadQos);
122#else
123 queryProcessor = std::make_unique<processor::QueryProcessor>(dbConfig->maxNumThreads);
124#endif
125
126 catalog = std::make_unique<Catalog>();
127 storageManager = std::make_unique<StorageManager>(databasePath, dbConfig->readOnly,
128 dbConfig->enableChecksums, *memoryManager, dbConfig->enableCompression,
129 dbConfig->enableDefaultHashIndex, vfs.get());
130 transactionManager = std::make_unique<TransactionManager>(storageManager->getWAL());
131 databaseManager = std::make_unique<DatabaseManager>();
132
133 extensionManager = std::make_unique<extension::ExtensionManager>();
134 dbLifeCycleManager = std::make_shared<DatabaseLifeCycleManager>();
135 if (clientContext.isInMemory()) {
136 storageManager->initDataFileHandle(vfs.get(), &clientContext);
137 extensionManager->autoLoadLinkedExtensions(&clientContext);
138 return;
139 }
140 StorageManager::recover(clientContext, dbConfig->throwOnWalReplayFailure,
141 dbConfig->enableChecksums);
142
143 // Load graphs from system catalog
144 databaseManager->loadGraphsFromCatalog(memoryManager.get(), &clientContext);
145}
146
147Database::~Database() {
148 if (!dbConfig->readOnly && dbConfig->forceCheckpointOnClose) {

Callers

nothing calls this directly

Calls 7

isInMemoryMethod · 0.80
initDataFileHandleMethod · 0.80
loadGraphsFromCatalogMethod · 0.80
ClientContextClass · 0.50
getMethod · 0.45

Tested by

no test coverage detected