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

Method flushAll

src/storage/shadow_file.cpp:143–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143void ShadowFile::flushAll(main::ClientContext& context) const {
144 // Write header page to file.
145 ShadowFileHeader header;
146 header.numShadowPages = shadowPageRecords.size();
147 header.databaseID = StorageManager::Get(context)->getOrInitDatabaseID(context);
148 const auto headerBuffer = std::make_unique<uint8_t[]>(LBUG_PAGE_SIZE);
149 memcpy(headerBuffer.get(), &header, sizeof(ShadowFileHeader));
150 DASSERT(shadowingFH && !shadowingFH->isInMemoryMode());
151 shadowingFH->writePageToFile(headerBuffer.get(), 0);
152 // Flush shadow pages to file.
153 shadowingFH->flushAllDirtyPagesInFrames();
154 // Append shadow page records to the end of the file.
155 const auto writer = std::make_shared<BufferedFileWriter>(*shadowingFH->getFileInfo());
156 writer->setFileOffset(shadowingFH->getNumPages() * LBUG_PAGE_SIZE);
157 Serializer ser(writer);
158 DASSERT(shadowPageRecords.size() + 1 == shadowingFH->getNumPages());
159 ser.serializeVector(shadowPageRecords);
160 writer->flush();
161 // Sync the file to disk.
162 writer->sync();
163}
164
165void ShadowFile::clear(BufferManager& bm) {
166 DASSERT(shadowingFH);

Calls 11

getOrInitDatabaseIDMethod · 0.80
isInMemoryModeMethod · 0.80
writePageToFileMethod · 0.80
setFileOffsetMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45
getFileInfoMethod · 0.45
getNumPagesMethod · 0.45
flushMethod · 0.45
syncMethod · 0.45