@frostpillar/frostpillar-btree 0.2.6 → 0.2.8

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.
@@ -2,24 +2,12 @@ import { InMemoryBTree, type BTreeEntry, type BTreeJSON, type BTreeStats, type E
2
2
  import type { KeyComparator } from '../btree/types.js';
3
3
  import type { ConcurrentInMemoryBTreeConfig } from './types.js';
4
4
  export declare class ConcurrentInMemoryBTree<TKey, TValue> {
5
- private readonly store;
5
+ private readonly coord;
6
6
  private readonly compareKeys;
7
- private readonly maxRetries;
8
- private readonly maxSyncMutationsPerBatch;
9
7
  private readonly duplicateKeys;
10
- private readonly configFingerprint;
11
- private readonly readMode;
12
- private readonly tree;
13
- private currentVersion;
14
- private operationQueue;
15
- private initSeen;
16
- private corrupted;
17
8
  constructor(config: ConcurrentInMemoryBTreeConfig<TKey, TValue>);
18
9
  sync(): Promise<void>;
19
- private syncUnlocked;
20
- private runExclusive;
21
- private readOp;
22
- private appendMutationAndApplyUnlocked;
10
+ syncThenRead<TResult>(fn: (tree: InMemoryBTree<TKey, TValue>) => TResult): Promise<TResult>;
23
11
  put(key: TKey, value: TValue): Promise<EntryId>;
24
12
  remove(key: TKey): Promise<BTreeEntry<TKey, TValue> | null>;
25
13
  removeById(entryId: EntryId): Promise<BTreeEntry<TKey, TValue> | null>;
@@ -53,6 +41,7 @@ export declare class ConcurrentInMemoryBTree<TKey, TValue> {
53
41
  keys(): Promise<TKey[]>;
54
42
  values(): Promise<TValue[]>;
55
43
  forEach(callback: (entry: BTreeEntry<TKey, TValue>) => void): Promise<void>;
44
+ forEachRange(startKey: TKey, endKey: TKey, callback: (entry: BTreeEntry<TKey, TValue>) => void, options?: RangeBounds): Promise<void>;
56
45
  [Symbol.asyncIterator](): AsyncIterableIterator<BTreeEntry<TKey, TValue>>;
57
46
  clone(): Promise<InMemoryBTree<TKey, TValue>>;
58
47
  toJSON(): Promise<BTreeJSON<TKey, TValue>>;
@@ -0,0 +1,21 @@
1
+ import { InMemoryBTree } from '../InMemoryBTree.js';
2
+ import type { BTreeMutation, ReadMode, SharedTreeStore } from './types.js';
3
+ import { type MutationResult } from './helpers.js';
4
+ export declare class Coordinator<TKey, TValue> {
5
+ readonly tree: InMemoryBTree<TKey, TValue>;
6
+ readonly store: SharedTreeStore<TKey, TValue>;
7
+ readonly maxRetries: number;
8
+ readonly maxSyncMutationsPerBatch: number;
9
+ readonly configFingerprint: string;
10
+ readonly readMode: ReadMode;
11
+ currentVersion: bigint;
12
+ operationQueue: Promise<void>;
13
+ initSeen: boolean;
14
+ corrupted: boolean;
15
+ constructor(tree: InMemoryBTree<TKey, TValue>, store: SharedTreeStore<TKey, TValue>, maxRetries: number, maxSyncMutationsPerBatch: number, configFingerprint: string, readMode: ReadMode);
16
+ syncUnlocked(): Promise<void>;
17
+ runExclusive<TResult>(operation: () => Promise<TResult>): Promise<TResult>;
18
+ readOp<TResult>(fn: (tree: InMemoryBTree<TKey, TValue>) => TResult): Promise<TResult>;
19
+ appendAndApply<TMutation extends BTreeMutation<TKey, TValue>>(evaluate: (tree: InMemoryBTree<TKey, TValue>) => TMutation | null): Promise<MutationResult<TKey, TValue, TMutation> | null>;
20
+ writeOp<TMutation extends BTreeMutation<TKey, TValue>>(evaluator: (tree: InMemoryBTree<TKey, TValue>) => TMutation | null): Promise<MutationResult<TKey, TValue, TMutation> | null>;
21
+ }
@@ -0,0 +1,2 @@
1
+ import type { SharedTreeLog } from './types.js';
2
+ export declare const validateSyncLog: <TKey, TValue>(log: SharedTreeLog<TKey, TValue>, maxSyncMutationsPerBatch: number) => void;