/** * In-memory key index for O(1) lookups. * * Maps keys to their location in the data file. This index is * rebuilt from the WAL on startup and updated after each write. */ import type { Wal } from './wal'; import type { RecordLocation, WalEntry, OpType } from './types'; export interface BuildFromWalResult { index: KeyIndex; maxSequence: bigint; } export declare class KeyIndex { private readonly entries; private constructor(); /** * Create an empty index. */ static create(): KeyIndex; /** * Build the index from a WAL by replaying all entries. * Also reads keys from the data file since WAL only stores hashes. * Returns both the index and the maximum sequence number seen. */ static buildFromWal(wal: Wal, dataPath: string): Promise; /** * Apply a WAL entry to update the index. */ applyEntry(key: string, entry: WalEntry): void; /** * Apply a location update directly (used after writes). */ apply(key: string, location: RecordLocation, op: OpType): void; /** * Get the location of a key. */ get(key: string): RecordLocation | undefined; /** * Check if a key exists. */ has(key: string): boolean; /** * Delete a key from the index. */ delete(key: string): boolean; /** * Get all keys in the index. */ keys(): IterableIterator; /** * Iterate over all entries as [key, location] pairs. */ locations(): IterableIterator<[string, RecordLocation]>; /** * Get the number of entries in the index. */ count(): number; } //# sourceMappingURL=key-index.d.ts.map