aiondb-buffer-pool

Buffer pool / page cache. Manages fixed-size 8 KiB pages in memory with clock-sweep eviction, dirty-page tracking, and a PageStore trait that decouples in-memory frames from the underlying page-backed file. Also bundles the on-disk B-Tree, variable-length B-Tree, heap, and free-space-map data structures that sit directly on top of the pool.

cargo

[dependencies]
aiondb-buffer-pool = { path = "../aiondb-buffer-pool" }

modules

modulepurpose
pagePage frame, PageId, PAGE_SIZE constant.
poolBufferPool, BufferPoolConfig, PageStore trait, in-memory and file backends.
evictionClockSweep eviction policy.
flusherbackground dirty-page flusher (BackgroundFlusher, FlusherConfig, FlusherHandle).
metricscounters and snapshot type.
diskFilePageStore page-file backend.
disk_btreefixed-key disk B-Tree (DiskBTree, config, stats).
disk_var_btreevariable-length-key disk B-Tree.
disk_heaptuple heap with vacuum support.
heap_pagelow-level heap page format (HeapPage, ItemId).
free_space_mapper-relation free-space map.

key types

typerole
BufferPoolthe in-memory page cache; striped page-load locks, clock-sweep, metrics.
BufferPoolConfignum_frames, max_dirty_pages, flusher poll interval, flush batch size, flag for the background flusher.
BufferPoolError, BufferPoolResult<T>error and result aliases.
PageGuard<'a>RAII pin handle returned by fetch_page / new_page.
Page, PageId, PAGE_SIZEthe page frame and its identifier.
PageStoretrait every backing store implements (read_page, write_page, allocate_page, reset_relation, sync).
MemoryPageStorein-memory PageStore, used for tests.
FilePageStorefile-backed PageStore for production.
ClockSweepthe eviction policy.
BackgroundFlusher, FlusherConfig, FlusherHandlebackground dirty-page flushing.
BufferPoolMetrics, BufferPoolMetricsSnapshothit/miss/eviction counters.
DiskBTree, DiskBTreeConfig, DiskBTreeStatsfixed-key B-Tree on top of the pool.
DiskVarBTree, DiskVarBTreeConfig, DiskVarBTreeStats, VarEntryvariable-key B-Tree.
DiskHeap, TupleLocation, VacuumStatsheap of tuples with vacuum.
HeapPage, HeapPageRef, ItemIdheap page layout.
FreeSpaceMapper-relation free-space tracker.

example

use std::sync::Arc;
use aiondb_buffer_pool::{BufferPool, MemoryPageStore, PageId};

let store = Arc::new(MemoryPageStore::new());
let pool = BufferPool::new(64, store);

let guard = pool.new_page(/* relation_id = */ 1).expect("allocate page");
let page_id: PageId = guard.page_id();
{
    let mut page = guard.write();
    page.data_mut()[..5].copy_from_slice(b"hello");
}
drop(guard);

pool.flush_page(page_id).expect("flush");
let _snapshot = pool.metrics();