From 4c78b7365a07ce9bf8fe3fc3434584c87aff32f4 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:24:01 +1000 Subject: Experimental BTree changes --- source/core/StarBTreeDatabase.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source/core/StarBTreeDatabase.hpp') diff --git a/source/core/StarBTreeDatabase.hpp b/source/core/StarBTreeDatabase.hpp index f1b88a1..b3a530f 100644 --- a/source/core/StarBTreeDatabase.hpp +++ b/source/core/StarBTreeDatabase.hpp @@ -230,7 +230,7 @@ private: void updateBlock(BlockIndex blockIndex, ByteArray const& block); void rawReadBlock(BlockIndex blockIndex, size_t blockOffset, char* block, size_t size) const; - void rawWriteBlock(BlockIndex blockIndex, size_t blockOffset, char const* block, size_t size) const; + void rawWriteBlock(BlockIndex blockIndex, size_t blockOffset, char const* block, size_t size); void updateHeadFreeIndexBlock(BlockIndex newHead); @@ -251,6 +251,9 @@ private: void writeRoot(); void readRoot(); void doCommit(); + void commitWrites(); + bool tryFlatten(); + bool flattenVisitor(BTreeImpl::Index& index, BlockIndex& count); void checkIfOpen(char const* methodName, bool shouldBeOpen) const; void checkBlockIndex(size_t blockIndex) const; @@ -285,14 +288,14 @@ private: bool m_dirty; // Blocks that can be freely allocated and written to without violating - // atomic consistency + // atomic consistency. Set m_availableBlocks; - // Blocks to be freed on next commit. - Deque m_pendingFree; - // Blocks that have been written in uncommitted portions of the tree. Set m_uncommitted; + + // Temporarily holds written data so that it can be rolled back. + mutable Map m_uncommittedWrites; }; // Version of BTreeDatabase that hashes keys with SHA-256 to produce a unique -- cgit v1.2.3