@ahmadmoussawi/webdb 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +386 -2
- package/dist/constants.d.ts +18 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/js/buffer_pool.c.d.ts +142 -0
- package/dist/core/js/buffer_pool.c.d.ts.map +1 -0
- package/dist/core/js/catalog.c.d.ts +186 -0
- package/dist/core/js/catalog.c.d.ts.map +1 -0
- package/dist/core/js/codecs.c.d.ts +32 -0
- package/dist/core/js/codecs.c.d.ts.map +1 -0
- package/dist/core/js/index.d.ts +7 -0
- package/dist/core/js/index.d.ts.map +1 -0
- package/dist/core/js/page.c.d.ts +229 -0
- package/dist/core/js/page.c.d.ts.map +1 -0
- package/dist/core/js/page_table.c.d.ts +48 -0
- package/dist/core/js/page_table.c.d.ts.map +1 -0
- package/dist/core/js/vm.c.d.ts +11 -0
- package/dist/core/js/vm.c.d.ts.map +1 -0
- package/dist/core/js/vm.helpers.c.d.ts +124 -0
- package/dist/core/js/vm.helpers.c.d.ts.map +1 -0
- package/dist/core/types.d.ts +26 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/wasm/embedded_wasm.d.ts +7 -0
- package/dist/core/wasm/embedded_wasm.d.ts.map +1 -0
- package/dist/core/wasm/wasm_core.d.ts +75 -0
- package/dist/core/wasm/wasm_core.d.ts.map +1 -0
- package/dist/host/api/index.d.ts +3 -0
- package/dist/host/api/index.d.ts.map +1 -0
- package/dist/host/api/query_builder.d.ts +216 -0
- package/dist/host/api/query_builder.d.ts.map +1 -0
- package/dist/host/api/webdb.d.ts +172 -0
- package/dist/host/api/webdb.d.ts.map +1 -0
- package/dist/host/compiler/compiler.d.ts +151 -0
- package/dist/host/compiler/compiler.d.ts.map +1 -0
- package/dist/host/compiler/expr_parser.d.ts +87 -0
- package/dist/host/compiler/expr_parser.d.ts.map +1 -0
- package/dist/host/compiler/index.d.ts +4 -0
- package/dist/host/compiler/index.d.ts.map +1 -0
- package/dist/host/compiler/planner/cost.d.ts +23 -0
- package/dist/host/compiler/planner/cost.d.ts.map +1 -0
- package/dist/host/compiler/planner/custom_order.d.ts +16 -0
- package/dist/host/compiler/planner/custom_order.d.ts.map +1 -0
- package/dist/host/compiler/planner/heuristic.d.ts +11 -0
- package/dist/host/compiler/planner/heuristic.d.ts.map +1 -0
- package/dist/host/compiler/planner/index.d.ts +34 -0
- package/dist/host/compiler/planner/index.d.ts.map +1 -0
- package/dist/host/compiler/planner/noop.d.ts +11 -0
- package/dist/host/compiler/planner/noop.d.ts.map +1 -0
- package/dist/host/compiler/planner/types.d.ts +100 -0
- package/dist/host/compiler/planner/types.d.ts.map +1 -0
- package/dist/host/compiler/planner/where_optimizer.d.ts +30 -0
- package/dist/host/compiler/planner/where_optimizer.d.ts.map +1 -0
- package/dist/host/compiler/planner.d.ts +2 -0
- package/dist/host/compiler/planner.d.ts.map +1 -0
- package/dist/host/driver/buffer_pool_driver.d.ts +94 -0
- package/dist/host/driver/buffer_pool_driver.d.ts.map +1 -0
- package/dist/host/driver/crash_recovery.d.ts +24 -0
- package/dist/host/driver/crash_recovery.d.ts.map +1 -0
- package/dist/host/driver/index.d.ts +4 -0
- package/dist/host/driver/index.d.ts.map +1 -0
- package/dist/host/driver/transaction_coordinator.d.ts +166 -0
- package/dist/host/driver/transaction_coordinator.d.ts.map +1 -0
- package/dist/host/storage/crc32.d.ts +24 -0
- package/dist/host/storage/crc32.d.ts.map +1 -0
- package/dist/host/storage/idb.d.ts +27 -0
- package/dist/host/storage/idb.d.ts.map +1 -0
- package/dist/host/storage/index.d.ts +8 -0
- package/dist/host/storage/index.d.ts.map +1 -0
- package/dist/host/storage/io.d.ts +60 -0
- package/dist/host/storage/io.d.ts.map +1 -0
- package/dist/host/storage/memory.d.ts +28 -0
- package/dist/host/storage/memory.d.ts.map +1 -0
- package/dist/host/storage/opfs.d.ts +31 -0
- package/dist/host/storage/opfs.d.ts.map +1 -0
- package/dist/host/storage/vfs.d.ts +36 -0
- package/dist/host/storage/vfs.d.ts.map +1 -0
- package/dist/host/storage/wal_codec.d.ts +56 -0
- package/dist/host/storage/wal_codec.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/layouts/index.d.ts +5 -0
- package/dist/layouts/index.d.ts.map +1 -0
- package/dist/layouts/page_format.d.ts +163 -0
- package/dist/layouts/page_format.d.ts.map +1 -0
- package/dist/layouts/pool_format.d.ts +126 -0
- package/dist/layouts/pool_format.d.ts.map +1 -0
- package/dist/layouts/syspage_format.d.ts +499 -0
- package/dist/layouts/syspage_format.d.ts.map +1 -0
- package/dist/layouts/wal_format.d.ts +197 -0
- package/dist/layouts/wal_format.d.ts.map +1 -0
- package/dist/shared/c_runtime.d.ts +47 -0
- package/dist/shared/c_runtime.d.ts.map +1 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/page_provider.d.ts +12 -0
- package/dist/shared/page_provider.d.ts.map +1 -0
- package/dist/shared/vm_context.d.ts +73 -0
- package/dist/shared/vm_context.d.ts.map +1 -0
- package/dist/types/index.d.ts +338 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/webdb.js +13059 -0
- package/dist/webdb.js.map +1 -0
- package/dist/webdb.umd.cjs +5 -0
- package/dist/webdb.umd.cjs.map +1 -0
- package/package.json +82 -4
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { TableMeta, IndexDescriptor, JoinType } from '../../../types/index.js';
|
|
2
|
+
import { QueryPlan, JoinPlan, QueryFilter, ComparisonOp, SortKey } from '../compiler.js';
|
|
3
|
+
import { ParsedSelectExpr } from '../expr_parser.js';
|
|
4
|
+
export interface WhereMetrics {
|
|
5
|
+
originalCount: number;
|
|
6
|
+
optimizedCount: number;
|
|
7
|
+
isAlwaysFalse: boolean;
|
|
8
|
+
isAlwaysTrue: boolean;
|
|
9
|
+
contradictionReason?: string;
|
|
10
|
+
eliminatedFiltersCount: number;
|
|
11
|
+
reordered: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface PlanCostMetrics {
|
|
14
|
+
totalCost: number;
|
|
15
|
+
estimatedRows: number;
|
|
16
|
+
joinOrder: string[];
|
|
17
|
+
singleTableFilters: Map<number, QueryFilter[]>;
|
|
18
|
+
crossFilters: QueryFilter[];
|
|
19
|
+
tableScanTypes: ('TableScan' | 'IndexScan')[];
|
|
20
|
+
tableIndexNames: (string | undefined)[];
|
|
21
|
+
isOrderSatisfied?: boolean;
|
|
22
|
+
sortCostAvoided?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface OptimizedPlanResult {
|
|
25
|
+
plan: QueryPlan;
|
|
26
|
+
orderedTables: TableMeta[];
|
|
27
|
+
metrics: PlanCostMetrics | null;
|
|
28
|
+
isAlwaysFalse?: boolean;
|
|
29
|
+
isAlwaysTrue?: boolean;
|
|
30
|
+
whereMetrics?: WhereMetrics;
|
|
31
|
+
isOrderSatisfied?: boolean;
|
|
32
|
+
sortCostAvoided?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface QueryPlanner {
|
|
35
|
+
readonly name: string;
|
|
36
|
+
optimize(plan: QueryPlan): OptimizedPlanResult;
|
|
37
|
+
}
|
|
38
|
+
export interface JoinEdge {
|
|
39
|
+
tableA: number;
|
|
40
|
+
tableB: number;
|
|
41
|
+
colA: string;
|
|
42
|
+
colB: string;
|
|
43
|
+
op: ComparisonOp;
|
|
44
|
+
type: JoinType;
|
|
45
|
+
declaredRightTable: number;
|
|
46
|
+
}
|
|
47
|
+
export declare const COST_INDEX_SEEK = 0.5;
|
|
48
|
+
export declare const COST_INDEX_NEXT = 0.05;
|
|
49
|
+
export declare const COST_ROW_EVAL = 0.02;
|
|
50
|
+
/**
|
|
51
|
+
* Extracts all column names referenced in a filter (both direct colName and expr).
|
|
52
|
+
*/
|
|
53
|
+
export declare function extractFilterColumnNames(filter: QueryFilter): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Determines which table indices (in `tables`) are referenced by a filter.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getFilterReferencedTables(filter: QueryFilter, tables: TableMeta[]): Set<number>;
|
|
58
|
+
/**
|
|
59
|
+
* Estimates filter selectivity based on operation, column index presence, and table row count.
|
|
60
|
+
*/
|
|
61
|
+
export declare function estimateFilterSelectivity(filter: QueryFilter, table: TableMeta): number;
|
|
62
|
+
/**
|
|
63
|
+
* Computes single-table base cardinality and scan cost for a table when used as driving table.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getSingleTableBaseCost(table: TableMeta, filters: QueryFilter[], orderBy?: SortKey[], limit?: number): {
|
|
66
|
+
cost: number;
|
|
67
|
+
rows: number;
|
|
68
|
+
scanType: 'TableScan' | 'IndexScan';
|
|
69
|
+
indexName?: string;
|
|
70
|
+
isOrderSatisfied?: boolean;
|
|
71
|
+
sortCostAvoided?: number;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Checks if targetTable has an index on the given column.
|
|
75
|
+
*/
|
|
76
|
+
export declare function findIndexOnColumn(table: TableMeta, colName: string): {
|
|
77
|
+
index: IndexDescriptor;
|
|
78
|
+
isUnique: boolean;
|
|
79
|
+
} | null;
|
|
80
|
+
/**
|
|
81
|
+
* Builds join edges and left-join dependency constraints from query join clauses.
|
|
82
|
+
*/
|
|
83
|
+
export declare function buildJoinEdges(plan: QueryPlan, originalTables: TableMeta[]): {
|
|
84
|
+
edges: JoinEdge[];
|
|
85
|
+
dependencies: Set<number>[];
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Preserves output column projection order in case of table reordering.
|
|
89
|
+
*/
|
|
90
|
+
export declare function materializeOutputSelectExprs(plan: QueryPlan, originalTables: TableMeta[]): ParsedSelectExpr[] | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Reconstructs JoinPlan[] for the ordered tables based on resolved join edges.
|
|
93
|
+
*/
|
|
94
|
+
export declare function reconstructJoinPlans(winningOrder: number[], originalTables: TableMeta[], edges: JoinEdge[], originalJoinedPlans?: JoinPlan[]): JoinPlan[];
|
|
95
|
+
/**
|
|
96
|
+
* Checks whether all ORDER BY keys belong to candidateTable and are ASC,
|
|
97
|
+
* which enables nested-loop join order preservation if candidateTable is the driving table.
|
|
98
|
+
*/
|
|
99
|
+
export declare function doesTableSatisfyJoinOrderKeys(candidateTable: TableMeta, candidateTableIdx: number, allTables: TableMeta[], orderBy?: SortKey[], selectExprs?: ParsedSelectExpr[]): boolean;
|
|
100
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/host/compiler/planner/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,eAAe,EAEf,QAAQ,EACT,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,OAAO,EAIR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;IAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,cAAc,EAAE,CAAC,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,EACzB,SAAS,EAAE,SAAS,EAAE,EACtB,OAAO,CAAC,EAAE,OAAO,EAAE,EACnB,WAAW,CAAC,EAAE,gBAAgB,EAAE,GAC/B,OAAO,CAkBT"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TableMeta } from '../../../types/index.js';
|
|
2
|
+
import { QueryFilter } from '../compiler.js';
|
|
3
|
+
import { WhereMetrics } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Assigns an estimated relative CPU/evaluation cost to a filter for optimal short-circuit reordering.
|
|
6
|
+
* Lower numbers = cheaper to evaluate -> placed first in execution.
|
|
7
|
+
*/
|
|
8
|
+
export declare function estimateWhereCost(filter: QueryFilter, tables?: TableMeta[]): number;
|
|
9
|
+
/**
|
|
10
|
+
* Optimizes an array of query filters by:
|
|
11
|
+
* 1. Detecting contradictions (short-circuiting).
|
|
12
|
+
* 2. Pruning redundant duplicates and subsumed range bounds.
|
|
13
|
+
* 3. Reordering filters by evaluation cost.
|
|
14
|
+
*/
|
|
15
|
+
export declare function optimizeWherePredicates(filters: QueryFilter[], tables?: TableMeta[]): {
|
|
16
|
+
filters: QueryFilter[];
|
|
17
|
+
isAlwaysFalse: boolean;
|
|
18
|
+
isAlwaysTrue: boolean;
|
|
19
|
+
metrics: WhereMetrics;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Infers transitive equality predicates across inner/left joins.
|
|
23
|
+
*/
|
|
24
|
+
export declare function inferTransitivePredicates(filters: QueryFilter[], joinedPlans: {
|
|
25
|
+
leftCol: string;
|
|
26
|
+
op: string;
|
|
27
|
+
rightCol: string;
|
|
28
|
+
type: string;
|
|
29
|
+
}[]): QueryFilter[];
|
|
30
|
+
//# sourceMappingURL=where_optimizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"where_optimizer.d.ts","sourceRoot":"","sources":["../../../../src/host/compiler/planner/where_optimizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,GAAG,MAAM,CAsDnF;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,WAAW,EAAE,EACtB,MAAM,CAAC,EAAE,SAAS,EAAE,GACnB;IACD,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,YAAY,CAAC;CACvB,CAqGA;AAkMD;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,WAAW,EAAE,EACtB,WAAW,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,GAC7E,WAAW,EAAE,CA6Df"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../../../src/host/compiler/planner.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { computeBufferPoolOffsets } from '../../constants.ts';
|
|
2
|
+
import { IVfsAdapter } from '../storage/vfs.ts';
|
|
3
|
+
import { Io } from '../storage/io.ts';
|
|
4
|
+
import { VmStatus, VmContext } from '../../types/index.ts';
|
|
5
|
+
export type BufferPoolOffsets = ReturnType<typeof computeBufferPoolOffsets>;
|
|
6
|
+
export declare function createWasmMemory(slotCount?: number, maxQueryMemory?: number): WebAssembly.Memory;
|
|
7
|
+
export interface BufferPoolDriverOptions {
|
|
8
|
+
vfs?: IVfsAdapter;
|
|
9
|
+
io?: Io;
|
|
10
|
+
memory?: WebAssembly.Memory;
|
|
11
|
+
pool?: {
|
|
12
|
+
wasmMemory: WebAssembly.Memory;
|
|
13
|
+
slotCount?: number;
|
|
14
|
+
maxQueryMemory?: number;
|
|
15
|
+
};
|
|
16
|
+
slotCount?: number;
|
|
17
|
+
maxQueryMemory?: number;
|
|
18
|
+
useDefaultLayoutOffsets?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Async Buffer Pool Driver Loop.
|
|
22
|
+
*
|
|
23
|
+
* Implemented 100% in TypeScript on the Host Layer.
|
|
24
|
+
* Interacts with the C Engine purely through shared WebAssembly.Memory and layout offsets.
|
|
25
|
+
* Does NOT import or invoke any C-layer classes.
|
|
26
|
+
*/
|
|
27
|
+
export declare class BufferPoolDriver {
|
|
28
|
+
readonly io: Io;
|
|
29
|
+
readonly wasmMemory: WebAssembly.Memory;
|
|
30
|
+
readonly buffer: ArrayBuffer;
|
|
31
|
+
readonly view: DataView;
|
|
32
|
+
readonly uint8: Uint8Array;
|
|
33
|
+
readonly slotCount: number;
|
|
34
|
+
readonly maxQueryMemory: number;
|
|
35
|
+
readonly offsets: BufferPoolOffsets;
|
|
36
|
+
readonly slotsEndOffset: number;
|
|
37
|
+
readonly slotToPageOffset: number;
|
|
38
|
+
readonly pageToSlotOffset: number;
|
|
39
|
+
readonly pageToSlotBuckets: number;
|
|
40
|
+
readonly dirtyMaskOffset: number;
|
|
41
|
+
readonly vmContextOffset: number;
|
|
42
|
+
readonly resultBufferOffset: number;
|
|
43
|
+
readonly bytecodeOffset: number;
|
|
44
|
+
readonly pageScratchpadOffset: number;
|
|
45
|
+
readonly transientArenaOffset: number;
|
|
46
|
+
readonly pin_counts: Uint32Array;
|
|
47
|
+
readonly slot_dirty_generations: Uint32Array;
|
|
48
|
+
readonly ref_bits: Uint8Array;
|
|
49
|
+
private clock_hand;
|
|
50
|
+
private arena_offset;
|
|
51
|
+
private in_flight_acquires;
|
|
52
|
+
private allocation_lock;
|
|
53
|
+
constructor(options: BufferPoolDriverOptions);
|
|
54
|
+
private validate_slot_idx;
|
|
55
|
+
private validate_page_id;
|
|
56
|
+
private with_allocation_lock;
|
|
57
|
+
setTransactionCoordinator(coordinator: any): void;
|
|
58
|
+
getSlotOffset(slotIdx: number): number;
|
|
59
|
+
getPageBytesInSlot(slotIdx: number): Uint8Array;
|
|
60
|
+
getSlotDataView(slotIdx: number): DataView;
|
|
61
|
+
getResidentSlot(pageId: number): number;
|
|
62
|
+
getAssignedPage(slotIdx: number): number;
|
|
63
|
+
assignSlot(slotIdx: number, pageId: number): void;
|
|
64
|
+
unassignSlot(slotIdx: number): void;
|
|
65
|
+
markDirty(slotIdx: number): void;
|
|
66
|
+
clearDirty(slotIdx: number): void;
|
|
67
|
+
isDirty(slotIdx: number): boolean;
|
|
68
|
+
pinSlot(slotIdx: number): void;
|
|
69
|
+
unpinSlot(slotIdx: number): void;
|
|
70
|
+
pinPage(pageId: number): void;
|
|
71
|
+
unpinPage(pageId: number): void;
|
|
72
|
+
forceUnpinSlot(slotIdx: number): void;
|
|
73
|
+
forceUnpinPage(pageId: number): void;
|
|
74
|
+
isSlotPinned(slotIdx: number): boolean;
|
|
75
|
+
getPinCount(slotIdx: number): number;
|
|
76
|
+
getRefBit(slotIdx: number): number;
|
|
77
|
+
setRefBit(slotIdx: number, val: number): void;
|
|
78
|
+
allocArena(size: number): number;
|
|
79
|
+
resetArena(): void;
|
|
80
|
+
getArenaOffset(): number;
|
|
81
|
+
acquirePage(page_id: number, pin?: boolean): Promise<number>;
|
|
82
|
+
acquireAndPinPage(page_id: number): Promise<number>;
|
|
83
|
+
flushSlot(slot_idx: number): Promise<void>;
|
|
84
|
+
flushPage(page_id: number): Promise<void>;
|
|
85
|
+
flushAllDirty(): Promise<void>;
|
|
86
|
+
allocatePage(pin?: boolean): Promise<number>;
|
|
87
|
+
allocateAndPinPage(): Promise<number>;
|
|
88
|
+
freePage(page_id: number, force?: boolean): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Drives the VDBE VM step loop, handling STATUS_PAGE_FAULT until completion.
|
|
91
|
+
*/
|
|
92
|
+
stepVm(ctx: VmContext, bytecode: Uint8Array): Promise<VmStatus>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=buffer_pool_driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer_pool_driver.d.ts","sourceRoot":"","sources":["../../../src/host/driver/buffer_pool_driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,wBAAwB,EACzB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEtC,OAAO,EAGL,QAAQ,EACR,SAAS,EACV,MAAM,sBAAsB,CAAC;AAuB9B,wBAAgB,gBAAgB,CAC9B,SAAS,GAAE,MAA2B,EACtC,cAAc,GAAE,MAAiC,GAChD,WAAW,CAAC,MAAM,CAWpB;AAMD,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,EAAE,CAAC,EAAE,EAAE,CAAC;IACR,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE;QACL,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC;QAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,QAAQ,CAAC,EAAE,EAA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MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7C,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB1C,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAS9B,YAAY,CAAC,GAAG,GAAE,OAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAgEzD,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAuEtE;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC;CAUtE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IVfsAdapter } from '../storage/vfs.js';
|
|
2
|
+
export interface RecoveryResult {
|
|
3
|
+
frameCount: number;
|
|
4
|
+
committedTxCount: number;
|
|
5
|
+
abortedTxCount: number;
|
|
6
|
+
replayedPageCount: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Executes startup crash recovery against the VFS Write-Ahead Log.
|
|
10
|
+
*
|
|
11
|
+
* Algorithm (Phase 4 Specification - Section 6):
|
|
12
|
+
* 1. Checks if WAL has frames. If empty, startup completes immediately.
|
|
13
|
+
* 2. Validates 32-byte WAL file header. Throws CorruptWalHeaderError on corruption.
|
|
14
|
+
* 3. Reads frames sequentially. Detects truncated tails and stops cleanly at first
|
|
15
|
+
* corrupt or torn frame (CRC32 mismatch or magic mismatch).
|
|
16
|
+
* 4. Groups frames by tx_id and identifies which transactions reached durable FRAME_TX_COMMIT.
|
|
17
|
+
* 5. Discards uncommitted transaction groups.
|
|
18
|
+
* 6. Deduplicates committed frames (latest page version per page_id) and applies them
|
|
19
|
+
* to the main database file via vfs.writePages(...).
|
|
20
|
+
* 7. Flushes the main storage durably via vfs.flush().
|
|
21
|
+
* 8. Truncates the WAL to 0 via vfs.truncateWal(0).
|
|
22
|
+
*/
|
|
23
|
+
export declare function recoverFromWal(vfs: IVfsAdapter): Promise<RecoveryResult>;
|
|
24
|
+
//# sourceMappingURL=crash_recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crash_recovery.d.ts","sourceRoot":"","sources":["../../../src/host/driver/crash_recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAYhD,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAgI9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/host/driver/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { IVfsAdapter } from '../storage/vfs.js';
|
|
2
|
+
import { Io } from '../storage/io.js';
|
|
3
|
+
import { BufferPoolDriver } from './buffer_pool_driver.js';
|
|
4
|
+
export interface TransactionLease {
|
|
5
|
+
readonly leaseId: number;
|
|
6
|
+
readonly txId: number;
|
|
7
|
+
readonly createdAt: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Enforces the Exclusive Transaction Lease across asynchronous JavaScript microtask boundaries
|
|
11
|
+
* and across concurrent browser tabs via the Web Locks API (navigator.locks).
|
|
12
|
+
* While an exclusive lease is held by an active transaction, all external queries, mutations,
|
|
13
|
+
* and checkpoint requests are strictly enqueued in FIFO order.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ExclusiveLeaseQueue {
|
|
16
|
+
private activeLease;
|
|
17
|
+
private inFlightNonTxCount;
|
|
18
|
+
private queue;
|
|
19
|
+
private leaseWaiters;
|
|
20
|
+
private nextLeaseId;
|
|
21
|
+
private nextTxId;
|
|
22
|
+
private crossTabLockName?;
|
|
23
|
+
private onSyncCrossTab?;
|
|
24
|
+
private releaseWebLock;
|
|
25
|
+
constructor(crossTabLockName?: string, onSyncCrossTab?: () => Promise<void>);
|
|
26
|
+
hasWebLocks(): boolean;
|
|
27
|
+
private acquireWebLock;
|
|
28
|
+
private releaseCurrentWebLock;
|
|
29
|
+
get isLeased(): boolean;
|
|
30
|
+
get currentLease(): TransactionLease | null;
|
|
31
|
+
/**
|
|
32
|
+
* Enqueues or dispatches a task through the FIFO coordinator.
|
|
33
|
+
* If task belongs to the active lease, it executes immediately without queuing.
|
|
34
|
+
*/
|
|
35
|
+
enqueue<T>(task: () => Promise<T>, leaseId?: number): Promise<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Acquires the Exclusive Transaction Lease.
|
|
38
|
+
* Blocks until all in-flight non-transactional operations finish and acquires the cross-tab Web Lock.
|
|
39
|
+
*/
|
|
40
|
+
acquireExclusiveLease(): Promise<TransactionLease>;
|
|
41
|
+
/**
|
|
42
|
+
* Releases the Exclusive Transaction Lease, releases the cross-tab Web Lock, and drains pending operations.
|
|
43
|
+
*/
|
|
44
|
+
releaseExclusiveLease(leaseId: number): void;
|
|
45
|
+
private drain;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* TransactionCoordinator orchestrates:
|
|
49
|
+
* 1. Exclusive Transaction Lease & FIFO async dispatch.
|
|
50
|
+
* 2. Write-Ahead Log (WAL) frame generation & durability flush on COMMIT.
|
|
51
|
+
* 3. Cache spilling of uncommitted pages under memory pressure (FRAME_TX_UNCOMMITTED).
|
|
52
|
+
* 4. Zero-mutation rollback on abort (memory restoration & WAL truncation).
|
|
53
|
+
* 5. Deduplicated Monotonic Checkpointing to synchronize main storage.
|
|
54
|
+
*/
|
|
55
|
+
export declare class TransactionCoordinator {
|
|
56
|
+
private vfs;
|
|
57
|
+
private pool;
|
|
58
|
+
private io;
|
|
59
|
+
private queue;
|
|
60
|
+
private activeLease;
|
|
61
|
+
private snapshotFrameCount;
|
|
62
|
+
private snapshotWalFrameSeq;
|
|
63
|
+
private slotSnapshots;
|
|
64
|
+
private pinCountsSnapshot;
|
|
65
|
+
private spilledPages;
|
|
66
|
+
private committedWalPages;
|
|
67
|
+
private walFrameSeq;
|
|
68
|
+
private txCommitCount;
|
|
69
|
+
private checkpointSeq;
|
|
70
|
+
private instanceSalt;
|
|
71
|
+
private expectedWalFrameCount;
|
|
72
|
+
private lastDiskChangeCounter;
|
|
73
|
+
private lastDiskSchemaVersion;
|
|
74
|
+
private onCrossTabInvalidated?;
|
|
75
|
+
private idleTimer;
|
|
76
|
+
private isClosed;
|
|
77
|
+
constructor(vfs: IVfsAdapter, pool: BufferPoolDriver, io: Io, crossTabLockName?: string);
|
|
78
|
+
setOnCrossTabInvalidated(cb: () => Promise<void>): void;
|
|
79
|
+
recordDiskPage1State(): void;
|
|
80
|
+
private reloadFromDisk;
|
|
81
|
+
syncCrossTabState(force?: boolean): Promise<void>;
|
|
82
|
+
get leaseQueue(): ExclusiveLeaseQueue;
|
|
83
|
+
isInTransaction(): boolean;
|
|
84
|
+
getActiveLeaseId(): number | null;
|
|
85
|
+
getActiveTxId(): number | null;
|
|
86
|
+
hasSpilledPage(pageId: number): boolean;
|
|
87
|
+
getSpilledPage(pageId: number): Uint8Array | null;
|
|
88
|
+
onDirectPageWrite(pageId: number, data: Uint8Array): void;
|
|
89
|
+
/**
|
|
90
|
+
* Spills an uncommitted dirty slot to the WAL under cache eviction pressure.
|
|
91
|
+
* Frame type is set to FRAME_TX_UNCOMMITTED (0x0003).
|
|
92
|
+
*/
|
|
93
|
+
spillUncommittedSlot(slotIdx: number, pageId: number): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Captures a point-in-time snapshot of the buffer pool, spilled pages, and WAL frame count.
|
|
96
|
+
* Used both at transaction BEGIN and for nested savepoints.
|
|
97
|
+
*/
|
|
98
|
+
captureSavepoint(): Promise<{
|
|
99
|
+
frameCount: number;
|
|
100
|
+
slotSnapshots: Map<number, {
|
|
101
|
+
pageId: number;
|
|
102
|
+
dirty: boolean;
|
|
103
|
+
data: Uint8Array;
|
|
104
|
+
}>;
|
|
105
|
+
pinCounts: Uint32Array;
|
|
106
|
+
spilledPages: Map<number, Uint8Array>;
|
|
107
|
+
walFrameSeq: number;
|
|
108
|
+
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Restores buffer pool slots, pin counts, spilled pages, and truncates WAL back to a savepoint.
|
|
111
|
+
*/
|
|
112
|
+
restoreSavepoint(savepoint: {
|
|
113
|
+
frameCount: number;
|
|
114
|
+
slotSnapshots: Map<number, {
|
|
115
|
+
pageId: number;
|
|
116
|
+
dirty: boolean;
|
|
117
|
+
data: Uint8Array;
|
|
118
|
+
}>;
|
|
119
|
+
pinCounts: Uint32Array;
|
|
120
|
+
spilledPages: Map<number, Uint8Array>;
|
|
121
|
+
walFrameSeq: number;
|
|
122
|
+
}): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Begins an explicit transaction:
|
|
125
|
+
* 1. Acquires exclusive lease on the async queue (and cross-tab Web Lock).
|
|
126
|
+
* 2. Synchronizes cross-tab storage state if another tab modified .db / .wal.
|
|
127
|
+
* 3. Snapshots resident buffer pool slots and current WAL frame count.
|
|
128
|
+
* 4. Pauses idle checkpoint timer.
|
|
129
|
+
*/
|
|
130
|
+
begin(): Promise<TransactionLease>;
|
|
131
|
+
/**
|
|
132
|
+
* Commits an active transaction:
|
|
133
|
+
* 1. Collects all dirty slots in memory and appends them as FRAME_PAGE_DATA frames to the WAL.
|
|
134
|
+
* 2. Appends a FRAME_TX_COMMIT marker frame.
|
|
135
|
+
* 3. Calls vfs.flushWal() to establish durable commit point.
|
|
136
|
+
* 4. Releases the exclusive lease.
|
|
137
|
+
*/
|
|
138
|
+
commit(leaseId: number): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Rolls back an active transaction:
|
|
141
|
+
* 1. Restores buffer pool slots to their snapshot state at BEGIN.
|
|
142
|
+
* 2. Clears spilled uncommitted page cache.
|
|
143
|
+
* 3. Truncates WAL back to the initial snapshot frame count.
|
|
144
|
+
* 4. Releases the exclusive lease.
|
|
145
|
+
*/
|
|
146
|
+
rollback(leaseId: number): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Deduplicated Monotonic Checkpoint (Section 4.3):
|
|
149
|
+
* 1. Scans committed WAL frames chronologically -> wal_index.
|
|
150
|
+
* 2. Inspects resident dirty slots in memory -> memory_override.
|
|
151
|
+
* 3. Merges union of unique page_ids and writes to main storage via vfs.writePages().
|
|
152
|
+
* 4. Calls vfs.flush() to durably sync main disk.
|
|
153
|
+
* 5. Strictly AFTER vfs.flush() succeeds, truncates WAL to 0.
|
|
154
|
+
*/
|
|
155
|
+
checkpoint(): Promise<{
|
|
156
|
+
pagesWritten: number;
|
|
157
|
+
}>;
|
|
158
|
+
executeCheckpoint(): Promise<{
|
|
159
|
+
pagesWritten: number;
|
|
160
|
+
}>;
|
|
161
|
+
resetWalAfterImport(): Promise<void>;
|
|
162
|
+
private scheduleIdleTimer;
|
|
163
|
+
private pauseIdleTimer;
|
|
164
|
+
close(): Promise<void>;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=transaction_coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction_coordinator.d.ts","sourceRoot":"","sources":["../../../src/host/driver/transaction_coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAA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AA;KAAE,CAAC;IA+GtD,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB1C,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,cAAc;IAOhB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAM7B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CRC32 IEEE 802.3 standard implementation (polynomial 0xEDB88320).
|
|
3
|
+
* Used for page-level integrity checks, WAL frame verification, and torn-write detection.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Computes CRC32 checksum across a Uint8Array slice.
|
|
7
|
+
*/
|
|
8
|
+
export declare function crc32(data: Uint8Array, start?: number, length?: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Computes the CRC32 checksum of a 4KB page.
|
|
11
|
+
* In WebDB slotted pages, bytes 12..15 store the checksum itself, so they are treated as 0 during computation.
|
|
12
|
+
*/
|
|
13
|
+
export declare function computePageChecksum(pageBytes: Uint8Array): number;
|
|
14
|
+
/**
|
|
15
|
+
* Computes the CRC32 checksum of Page 1.
|
|
16
|
+
* Bytes 28..31 store Page 1's checksum, so they are treated as 0 during computation.
|
|
17
|
+
*/
|
|
18
|
+
export declare function computePage1Checksum(pageBytes: Uint8Array): number;
|
|
19
|
+
/**
|
|
20
|
+
* Computes CRC32 checksum of a WAL Frame.
|
|
21
|
+
* Checksum is calculated across header bytes 0..23 concatenated with 4096 page payload bytes (bytes 32..4127).
|
|
22
|
+
*/
|
|
23
|
+
export declare function computeWalFrameChecksum(frameBytes: Uint8Array): number;
|
|
24
|
+
//# sourceMappingURL=crc32.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crc32.d.ts","sourceRoot":"","sources":["../../../src/host/storage/crc32.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,GAAE,MAAU,EAAE,MAAM,GAAE,MAAgC,GAAG,MAAM,CAO3G;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM,CAQjE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM,CAQlE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAUtE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IVfsAdapter } from './vfs.js';
|
|
2
|
+
export declare class IndexedDbVfsAdapter implements IVfsAdapter {
|
|
3
|
+
readonly name: "idb";
|
|
4
|
+
readonly isSynchronous = false;
|
|
5
|
+
private dbName;
|
|
6
|
+
private dbPromise;
|
|
7
|
+
constructor(dbName: string);
|
|
8
|
+
private getDb;
|
|
9
|
+
readPage(pageId: number): Promise<Uint8Array | null>;
|
|
10
|
+
writePage(pageId: number, data: Uint8Array): Promise<void>;
|
|
11
|
+
writePages(pages: Array<{
|
|
12
|
+
pageId: number;
|
|
13
|
+
data: Uint8Array;
|
|
14
|
+
}>): Promise<void>;
|
|
15
|
+
flush(): Promise<void>;
|
|
16
|
+
truncate(pageCount: number): Promise<void>;
|
|
17
|
+
readWalHeader(): Promise<Uint8Array | null>;
|
|
18
|
+
writeWalHeader(header: Uint8Array): Promise<void>;
|
|
19
|
+
readWalFrame(frameIndex: number): Promise<Uint8Array | null>;
|
|
20
|
+
readWalFrames(startFrameIndex: number, maxFrames?: number): Promise<Uint8Array[]>;
|
|
21
|
+
appendWalFrames(frames: Uint8Array[]): Promise<void>;
|
|
22
|
+
flushWal(): Promise<void>;
|
|
23
|
+
truncateWal(frameIndex: number): Promise<void>;
|
|
24
|
+
getWalFrameCount(): Promise<number>;
|
|
25
|
+
close(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=idb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idb.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AAO,CAAC,IAAI,CAAC;IAqB9C,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAYnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/host/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { IVfsAdapter } from './vfs.ts';
|
|
2
|
+
export interface IoOptions {
|
|
3
|
+
vfs: IVfsAdapter;
|
|
4
|
+
memory: WebAssembly.Memory | ArrayBuffer;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Pure Block I/O layer for WebDB.
|
|
8
|
+
*
|
|
9
|
+
* Responsibilities:
|
|
10
|
+
* - Reads/writes raw 4KB page blocks between IVfsAdapter and shared linear memory.
|
|
11
|
+
* - Computes and verifies CRC32 checksums.
|
|
12
|
+
* - Coalesces in-flight reads and flushes.
|
|
13
|
+
* - Resolves PAGE_FAULT requests issued by the C Engine state machine.
|
|
14
|
+
*
|
|
15
|
+
* DOES NOT:
|
|
16
|
+
* - Perform eviction candidate selection or Clock sweeps (handled in C Core).
|
|
17
|
+
* - Maintain page-to-slot tables, pin counts, or reference bits (handled in C Core).
|
|
18
|
+
* - Hold any reference to C-layer classes.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Io {
|
|
21
|
+
readonly vfs: IVfsAdapter;
|
|
22
|
+
readonly buffer: ArrayBuffer;
|
|
23
|
+
readonly uint8: Uint8Array;
|
|
24
|
+
readonly view: DataView;
|
|
25
|
+
private in_flight_flushes;
|
|
26
|
+
private in_flight_reads;
|
|
27
|
+
private coordinator;
|
|
28
|
+
setTransactionCoordinator(coordinator: any): void;
|
|
29
|
+
isInTransaction(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Computes and writes the page-level CRC32 checksum into the slot header in linear memory.
|
|
32
|
+
*/
|
|
33
|
+
stampSlotChecksum(slotIdx: number, pageId: number): void;
|
|
34
|
+
constructor(options: IoOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Reads a page from VFS directly into slotIdx in linear memory.
|
|
37
|
+
* Validates CRC32 checksum. If page does not exist in storage, zeroes the slot.
|
|
38
|
+
*/
|
|
39
|
+
readSlot(slotIdx: number, pageId: number): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Writes a page from slotIdx in linear memory to VFS.
|
|
42
|
+
* Computes CRC32 checksum and writes into slot header before saving snapshot.
|
|
43
|
+
*/
|
|
44
|
+
writeSlot(slotIdx: number, pageId: number): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Spills a slot to the WAL if an active transaction is open, otherwise writes it to VFS.
|
|
47
|
+
*/
|
|
48
|
+
spillOrWriteSlot(slotIdx: number, pageId: number): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Resolves a PAGE_FAULT yielded by the C Engine state machine.
|
|
51
|
+
* If flushPageId > 0, writes the victim dirty block to VFS.
|
|
52
|
+
* Reads faultPageId from VFS directly into targetSlot memory.
|
|
53
|
+
*/
|
|
54
|
+
resolvePageFault(targetSlot: number, faultPageId: number, flushPageId: number): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Durably flushes pending VFS adapter writes.
|
|
57
|
+
*/
|
|
58
|
+
flush(): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../../src/host/storage/io.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,MAAM,WAAW,SAAS;I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
|
+
readonly name: "memory";
|
|
4
|
+
readonly isSynchronous = true;
|
|
5
|
+
private pages;
|
|
6
|
+
private walHeader;
|
|
7
|
+
private walFrames;
|
|
8
|
+
readPage(pageId: number): Promise<Uint8Array | null>;
|
|
9
|
+
writePage(pageId: number, data: Uint8Array): Promise<void>;
|
|
10
|
+
writePages(pages: Array<{
|
|
11
|
+
pageId: number;
|
|
12
|
+
data: Uint8Array;
|
|
13
|
+
}>): Promise<void>;
|
|
14
|
+
flush(): Promise<void>;
|
|
15
|
+
truncate(pageCount: number): Promise<void>;
|
|
16
|
+
snapshot(): Map<number, Uint8Array>;
|
|
17
|
+
restoreSnapshot(snap: Map<number, Uint8Array>): void;
|
|
18
|
+
readWalHeader(): Promise<Uint8Array | null>;
|
|
19
|
+
writeWalHeader(header: Uint8Array): Promise<void>;
|
|
20
|
+
readWalFrame(frameIndex: number): Promise<Uint8Array | null>;
|
|
21
|
+
readWalFrames(startFrameIndex: number, maxFrames?: number): Promise<Uint8Array[]>;
|
|
22
|
+
appendWalFrames(frames: Uint8Array[]): Promise<void>;
|
|
23
|
+
flushWal(): Promise<void>;
|
|
24
|
+
truncateWal(frameIndex: number): Promise<void>;
|
|
25
|
+
getWalFrameCount(): Promise<number>;
|
|
26
|
+
close(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/host/storage/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,qBAAa,gBAAiB,YAAW,WAAW;IAClD,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;IAClC,QAAQ,CAAC,aAAa,QAAQ;IAE9B,OAAO,CAAC,KAAK,CAAiC;IAC9C,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,SAAS,CAAoB;IAE/B,QAAQ,CAAC,M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