refactor: simplify and add memory indexing

This commit is contained in:
2026-01-05 04:42:46 +01:00
parent 74d45cbe92
commit ed15a0eb27
37 changed files with 854 additions and 1328 deletions

20
src/index/unique.ts Normal file
View File

@@ -0,0 +1,20 @@
import type { PrimaryKey } from "./primary.ts";
export class UniqueIndex {
readonly #index = new Map<string, PrimaryKey>();
insert(value: any, pk: PrimaryKey) {
if (this.#index.has(value)) {
throw new Error(`Unique constraint violation: ${value}`);
}
this.#index.set(value, pk);
}
lookup(value: any): PrimaryKey | undefined {
return this.#index.get(value);
}
delete(value: any) {
this.#index.delete(value);
}
}