Provides minisql storage buffer pool facilities for this project.
Package: minisql.storage.buffer_pool
Reachable from entry: yes
minisql/common/limits.mlaslimits→ src/minisql/common/limits.mlminisql/storage/page.mlaspage→ src/minisql/storage/page.mlminisql/storage/paged_file.mlaspaged_file→ src/minisql/storage/paged_file.mlstd/ds/hashmap.mlashashmap→../MiniLangCompilerML/std/ds/hashmap.ml— external dependencystd/threading.mlasthreading→../MiniLangCompilerML/std/threading.ml— external dependency
const BUFFER_POOL_EXHAUSTED = 9009Defines the buffer pool exhausted constant used by the minisql storage buffer pool module.
- minisql.storage.buffer_pool.BufferFrame — struct
- minisql.storage.buffer_pool.BufferPool — struct
- minisql.storage.buffer_pool.BufferPoolStats — struct
function cachedRowCount(cache, tablePath)Returns a previously verified autocommit row count or void on a cache miss.
| Parameter | Type | Default | Description |
|---|---|---|---|
cache |
dynamic |
— | cache value consumed by this operation. |
tablePath |
dynamic |
— | Path associated with table. |
function chooseReadVictim(cache)Chooses an empty frame or an unreferenced CLOCK victim while the cache guard is held. Read frames are never pinned or dirty, so two passes always suffice.
| Parameter | Type | Default | Description |
|---|---|---|---|
cache |
dynamic |
— | cache value consumed by this operation. |
function chooseVictim(pool)Performs the choose victim operation for this module. Inputs: pool. Returns the produced value or propagates a structured error from validation or delegated operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
pool |
dynamic |
— | pool value consumed by this operation. |
function clearReadCache(cache)Invalidates all cached base pages after a successful database mutation.
| Parameter | Type | Default | Description |
|---|---|---|---|
cache |
dynamic |
— | cache value consumed by this operation. |
function close(pool)Closes close owned by the minisql storage buffer pool module. Inputs: pool. Returns the operation result and propagates validation, storage, or platform errors unchanged.
| Parameter | Type | Default | Description |
|---|---|---|---|
pool |
dynamic |
— | pool value consumed by this operation. |
const CLOSED_HANDLE = 9008Defines the closed handle constant used by the minisql storage buffer pool module.
function closeReadCache(cache)Closes a read cache after the owning database execution gate is empty.
| Parameter | Type | Default | Description |
|---|---|---|---|
cache |
dynamic |
— | cache value consumed by this operation. |
function componentName()Performs the componentName operation for the minisql storage buffer pool module. Takes no caller-supplied inputs. Returns the produced value or propagates a structured error from validation or delegated operations.
function create(capacity)Creates create for the minisql storage buffer pool module. Inputs: capacity. Returns the produced value or propagates a structured error from validation or delegated operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
capacity |
dynamic |
— | capacity value consumed by this operation. |
function createForBytes(maxBytes, pageSize)Creates the for bytes. Inputs: maxBytes, pageSize. Returns the produced value or propagates a structured error from validation or delegated operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
maxBytes |
dynamic |
— | maxBytes value consumed by this operation. |
pageSize |
dynamic |
— | pageSize value consumed by this operation. |
function createReadCache(maxBytes, pageSize)Creates the concurrent read cache for a configured memory budget.
| Parameter | Type | Default | Description |
|---|---|---|---|
maxBytes |
dynamic |
— | maxBytes value consumed by this operation. |
pageSize |
dynamic |
— | pageSize value consumed by this operation. |
function data(guard)Performs the data operation for this module. Inputs: guard. Returns the produced value or propagates a structured error from validation or delegated operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
guard |
dynamic |
— | guard value consumed by this operation. |
function emptyFrame()Performs the empty frame operation for this module. Takes no caller-supplied inputs. Returns the produced value or propagates a structured error from validation or delegated operations.
function fail(code, operation, message)Performs the fail operation for the minisql storage buffer pool module. Inputs: code, operation, message. Returns the produced value or propagates a structured error from validation or delegated operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
code |
dynamic |
— | code value consumed by this operation. |
operation |
dynamic |
— | operation value consumed by this operation. |
message |
dynamic |
— | Human-readable message associated with the operation. |
function findFrame(pool, pagedFile, pageNumber)Finds the frame. Inputs: pool, pagedFile, pageNumber. Returns the produced value or propagates a structured error from validation or delegated operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
pool |
dynamic |
— | pool value consumed by this operation. |
pagedFile |
dynamic |
— | pagedFile value consumed by this operation. |
pageNumber |
dynamic |
— | pageNumber value consumed by this operation. |
function flushAll(pool)Flushes the all. Inputs: pool. Returns the operation result and propagates validation, storage, or platform errors unchanged.
| Parameter | Type | Default | Description |
|---|---|---|---|
pool |
dynamic |
— | pool value consumed by this operation. |
function flushFrame(pool, frameIndex)Flushes the frame. Inputs: pool, frameIndex. Returns the operation result and propagates validation, storage, or platform errors unchanged.
| Parameter | Type | Default | Description |
|---|---|---|---|
pool |
dynamic |
— | pool value consumed by this operation. |
frameIndex |
dynamic |
— | Zero-based index of frame. |
function frameMatchesFile(frame, pagedFile)Performs the frame matches file operation for this module. Inputs: frame, pagedFile. Returns the produced value or propagates a structured error from validation or delegated operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
frame |
dynamic |
— | frame value consumed by this operation. |
pagedFile |
dynamic |
— | pagedFile value consumed by this operation. |
const INVALID_ARGUMENT = 9001Fixed-capacity buffer pool with explicit pin/unpin guards and CLOCK eviction.
function invalidateFile(pool, pagedFile)Performs the invalidate file operation for this module. Inputs: pool, pagedFile. Returns the produced value or propagates a structured error from validation or delegated operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
pool |
dynamic |
— | pool value consumed by this operation. |
pagedFile |
dynamic |
— | pagedFile value consumed by this operation. |
function isImplemented()Returns whether implemented satisfies the condition required by the minisql storage buffer pool module. Takes no caller-supplied inputs. Returns a boolean result; invalid input or delegated failures are reported as structured errors.
function markDirty(guard)Marks the dirty. Inputs: guard. Returns the produced value or propagates a structured error from validation or delegated operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
guard |
dynamic |
— | guard value consumed by this operation. |
function pageCapacity(maxBytes, pageSize)Converts a byte budget to pages using the database's validated page size.
| Parameter | Type | Default | Description |
|---|---|---|---|
maxBytes |
dynamic |
— | maxBytes value consumed by this operation. |
pageSize |
dynamic |
— | pageSize value consumed by this operation. |
function pin(pool, pagedFile, pageNumber)Performs the pin operation for this module. Inputs: pool, pagedFile, pageNumber. Returns the produced value or propagates a structured error from validation or delegated operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
pool |
dynamic |
— | pool value consumed by this operation. |
pagedFile |
dynamic |
— | pagedFile value consumed by this operation. |
pageNumber |
dynamic |
— | pageNumber value consumed by this operation. |
const PINNED_PAGE = 9010Defines the pinned page constant used by the minisql storage buffer pool module.
function readCached(cache, pagedFile, pageNumber)Reads through the concurrent cache. Disk I/O occurs without holding the cache guard; a second lookup collapses races when two readers miss together.
| Parameter | Type | Default | Description |
|---|---|---|---|
cache |
dynamic |
— | cache value consumed by this operation. |
pagedFile |
dynamic |
— | pagedFile value consumed by this operation. |
pageNumber |
dynamic |
— | pageNumber value consumed by this operation. |
function readCacheKey(pagedFile, pageNumber)Builds an unambiguous cache key; page paths cannot contain a NUL character.
| Parameter | Type | Default | Description |
|---|---|---|---|
pagedFile |
dynamic |
— | pagedFile value consumed by this operation. |
pageNumber |
dynamic |
— | pageNumber value consumed by this operation. |
function readCacheStats(cache)Returns a synchronized diagnostic snapshot.
| Parameter | Type | Default | Description |
|---|---|---|---|
cache |
dynamic |
— | cache value consumed by this operation. |
- minisql.storage.buffer_pool.ReadPageCache — struct
- minisql.storage.buffer_pool.ReadPageCacheStats — struct
function release(guard)Performs the release operation for the minisql storage buffer pool module. Inputs: guard. Returns the operation result and propagates validation, storage, or platform errors unchanged.
| Parameter | Type | Default | Description |
|---|---|---|---|
guard |
dynamic |
— | guard value consumed by this operation. |
function rememberRowCount(cache, tablePath, rowCount)Publishes a verified autocommit row count. Concurrent readers may race to publish the same value because writers are excluded by the execution gate.
| Parameter | Type | Default | Description |
|---|---|---|---|
cache |
dynamic |
— | cache value consumed by this operation. |
tablePath |
dynamic |
— | Path associated with table. |
rowCount |
dynamic |
— | Number of row to process. |
function stats(pool)Performs the stats operation for this module. Inputs: pool. Returns the produced value or propagates a structured error from validation or delegated operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
pool |
dynamic |
— | pool value consumed by this operation. |
function targetMilestone()Performs the targetMilestone operation for the minisql storage buffer pool module. Takes no caller-supplied inputs. Returns the produced value or propagates a structured error from validation or delegated operations.
function validateGuard(guard, operation)Validates the guard. Inputs: guard, operation. Returns success after all invariants hold; violations are reported as structured errors.
| Parameter | Type | Default | Description |
|---|---|---|---|
guard |
dynamic |
— | guard value consumed by this operation. |
operation |
dynamic |
— | operation value consumed by this operation. |
function validatePool(pool, operation)Validates the pool. Inputs: pool, operation. Returns success after all invariants hold; violations are reported as structured errors.
| Parameter | Type | Default | Description |
|---|---|---|---|
pool |
dynamic |
— | pool value consumed by this operation. |
operation |
dynamic |
— | operation value consumed by this operation. |
function validateReadCache(cache, operation)Validates a read cache before synchronization or I/O.
| Parameter | Type | Default | Description |
|---|---|---|---|
cache |
dynamic |
— | cache value consumed by this operation. |
operation |
dynamic |
— | operation value consumed by this operation. |