Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core/StarBTreeDatabase.hpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-09-11 15:24:01 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-09-11 15:24:01 +1000
commit4c78b7365a07ce9bf8fe3fc3434584c87aff32f4 (patch)
treef1bbac6fcad89d154d010946849401eca1339816 /source/core/StarBTreeDatabase.hpp
parenta6b20df3f0ddac5c235d10373d7d5f0876af99f9 (diff)
Experimental BTree changes
Diffstat (limited to 'source/core/StarBTreeDatabase.hpp')
-rw-r--r--source/core/StarBTreeDatabase.hpp13
1 files changed, 8 insertions, 5 deletions
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<BlockIndex> m_availableBlocks;
- // Blocks to be freed on next commit.
- Deque<BlockIndex> m_pendingFree;
-
// Blocks that have been written in uncommitted portions of the tree.
Set<BlockIndex> m_uncommitted;
+
+ // Temporarily holds written data so that it can be rolled back.
+ mutable Map<BlockIndex, ByteArray> m_uncommittedWrites;
};
// Version of BTreeDatabase that hashes keys with SHA-256 to produce a unique