Skip to main content

Architecture

CatDb layers a typed table API over a WTree and a heap.

User API
ITable<TKey,TRecord>, XTable<TKey,TRecord>, XFile

Storage engine
StorageEngine, Locator, Scheme

Waterfall Tree
WTree, Branch, InternalNode, LeafNode, BranchCache

Heap
WalHeap, Heap, Space, Pointer, OptimizedFileStream

Data layer
IData, Data<T>, DataType, persist/compare/transform helpers

Key files

FileRole
CatDb/Database/StorageEngine.csPublic storage engine implementation.
CatDb/Database/ITable.csMain table contract.
CatDb/Database/XTable.csTyped table wrapper.
CatDb/Database/XTablePortable.csInternal portable table implementation.
CatDb/Database/XStream.csStream backed by a table of byte blocks.
CatDb/WaterfallTree/WTree.csCore WTree execution, lookup, commit, and cache eviction.
CatDb/WaterfallTree/WTree.Branch.Fall.csCascades buffered operations down the tree.
CatDb/WaterfallTree/WTree.InternalNode.csRoutes operations and searches to child branches.
CatDb/WaterfallTree/WTree.InternalNode.Maintenance.csNode split, merge, and branch rebuild logic.
CatDb/Storage/WalHeap.csCrash-safe heap wrapper.

Write path

table[key] = record
-> XTable.Replace
-> XTablePortable.Execute(operation)
-> WTree.Execute(operation collection)
-> root branch cache
-> Fall when thresholds are exceeded
-> leaf ordered set

The WTree batches operations in branch caches so random writes can be applied in larger ordered chunks.

Read path

table.TryGet(key)
-> table Flush
-> WTree.FindData(locator, key)
-> top-down branch traversal
-> leaf ordered set lookup

Range scans use the same ordered tree structure, seeking to a lower bound and then walking leaf data in order.

Concurrency model

  • Root operations serialize with the root branch monitor.
  • Branch locking uses Monitor/lock(this) and is reentrant per thread.
  • Traversal is top-down: root, child, grandchild.
  • Code must not acquire locks upward from a child to a parent.
  • Cache eviction runs synchronously during commit.

Data model

User keys and records become IData internally. DataType, DataPersist, DataComparer, and DataTransformer build comparison and serialization delegates from CLR types or schema descriptors.

The locator stores the schema and all generated helpers needed for one logical structure.