serializable-bptree 8.4.1 → 9.0.0

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.
@@ -0,0 +1,34 @@
1
+ import type { BPTreeCondition, BPTreeConstructorOption, BPTreePair, BPTreeSearchOption, SerializableData } from './types';
2
+ import { SerializeStrategyAsync } from './SerializeStrategyAsync';
3
+ import { ValueComparator } from './base/ValueComparator';
4
+ import { BPTreeTransaction } from './base/BPTreeTransaction';
5
+ export declare class BPTreePureAsync<K, V> {
6
+ protected readonly strategy: SerializeStrategyAsync<K, V>;
7
+ protected readonly comparator: ValueComparator<V>;
8
+ protected readonly option: BPTreeConstructorOption;
9
+ private readonly _cachedRegexp;
10
+ private _ctx;
11
+ private _ops;
12
+ private readonly _verifierMap;
13
+ private readonly _searchConfigs;
14
+ constructor(strategy: SerializeStrategyAsync<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
15
+ private _ensureValues;
16
+ private _createOps;
17
+ init(): Promise<void>;
18
+ getRootId(): string;
19
+ getOrder(): number;
20
+ verify(nodeValue: V, condition: BPTreeCondition<V>): boolean;
21
+ get(key: K): Promise<V | undefined>;
22
+ exists(key: K, value: V): Promise<boolean>;
23
+ keysStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): AsyncGenerator<K>;
24
+ whereStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): AsyncGenerator<[K, V]>;
25
+ keys(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Promise<Set<K>>;
26
+ where(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Promise<BPTreePair<K, V>>;
27
+ insert(key: K, value: V): Promise<void>;
28
+ delete(key: K, value?: V): Promise<void>;
29
+ batchInsert(entries: [K, V][]): Promise<void>;
30
+ bulkLoad(entries: [K, V][]): Promise<void>;
31
+ getHeadData(): Promise<SerializableData>;
32
+ setHeadData(data: SerializableData): Promise<void>;
33
+ static ChooseDriver: typeof BPTreeTransaction.ChooseDriver;
34
+ }
@@ -0,0 +1,43 @@
1
+ import type { BPTreeCondition, BPTreeConstructorOption, BPTreePair, BPTreeSearchOption, SerializableData } from './types';
2
+ import { SerializeStrategySync } from './SerializeStrategySync';
3
+ import { ValueComparator } from './base/ValueComparator';
4
+ import { BPTreeTransaction } from './base/BPTreeTransaction';
5
+ export declare class BPTreePureSync<K, V> {
6
+ protected readonly strategy: SerializeStrategySync<K, V>;
7
+ protected readonly comparator: ValueComparator<V>;
8
+ protected readonly option: BPTreeConstructorOption;
9
+ private readonly _cachedRegexp;
10
+ private _ctx;
11
+ private _ops;
12
+ private readonly _verifierMap;
13
+ private readonly _searchConfigs;
14
+ constructor(strategy: SerializeStrategySync<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
15
+ private _ensureValues;
16
+ private _createOps;
17
+ init(): void;
18
+ /**
19
+ * Returns the ID of the root node.
20
+ */
21
+ getRootId(): string;
22
+ /**
23
+ * Returns the order of the B+Tree.
24
+ */
25
+ getOrder(): number;
26
+ /**
27
+ * Verified if the value satisfies the condition.
28
+ */
29
+ verify(nodeValue: V, condition: BPTreeCondition<V>): boolean;
30
+ get(key: K): V | undefined;
31
+ exists(key: K, value: V): boolean;
32
+ keysStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Generator<K>;
33
+ whereStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Generator<[K, V]>;
34
+ keys(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Set<K>;
35
+ where(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): BPTreePair<K, V>;
36
+ insert(key: K, value: V): void;
37
+ delete(key: K, value?: V): void;
38
+ batchInsert(entries: [K, V][]): void;
39
+ bulkLoad(entries: [K, V][]): void;
40
+ getHeadData(): SerializableData;
41
+ setHeadData(data: SerializableData): void;
42
+ static ChooseDriver: typeof BPTreeTransaction.ChooseDriver;
43
+ }
@@ -0,0 +1,33 @@
1
+ import type { BPTreeCondition, BPTreeLeafNode, BPTreeNodeKey, BPTreeUnknownNode, BPTreeSearchOption, SerializableData, SerializeStrategyHead } from '../types';
2
+ import type { BPTreeNodeOpsAsync, BPTreeAlgoContext } from './BPTreeNodeOps';
3
+ import { ValueComparator } from './ValueComparator';
4
+ import { cloneNode, binarySearchValues, insertValueIntoLeaf, createVerifierMap, resolveStartEndConfigs, verify } from './BPTreeAlgorithmSync';
5
+ export { cloneNode, binarySearchValues, insertValueIntoLeaf, createVerifierMap, resolveStartEndConfigs, verify };
6
+ type AsyncSearchConfigEntry<K, V> = {
7
+ start: (rootId: string, ops: BPTreeNodeOpsAsync<K, V>, v: V[]) => Promise<BPTreeLeafNode<K, V> | null>;
8
+ end: (rootId: string, ops: BPTreeNodeOpsAsync<K, V>, v: V[]) => Promise<BPTreeLeafNode<K, V> | null>;
9
+ direction: 1 | -1;
10
+ earlyTerminate: boolean;
11
+ };
12
+ export declare function createSearchConfigsAsync<K, V>(comparator: ValueComparator<V>, ensureValues: (v: V | V[]) => V[]): Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', AsyncSearchConfigEntry<K, V>>>;
13
+ export declare function locateLeafAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): Promise<BPTreeLeafNode<K, V>>;
14
+ export declare function findLowerBoundLeafAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): Promise<BPTreeLeafNode<K, V>>;
15
+ export declare function findUpperBoundLeafAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): Promise<BPTreeLeafNode<K, V>>;
16
+ export declare function findOuterBoundaryLeafAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, value: V, direction: 1 | -1, comparator: ValueComparator<V>): Promise<BPTreeLeafNode<K, V> | null>;
17
+ export declare function leftestNodeAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string): Promise<BPTreeLeafNode<K, V>>;
18
+ export declare function rightestNodeAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string): Promise<BPTreeLeafNode<K, V>>;
19
+ export declare function getPairsGeneratorAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, direction: 1 | -1): AsyncGenerator<[K, V]>;
20
+ export declare function insertAtLeafAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V, comparator: ValueComparator<V>): Promise<BPTreeUnknownNode<K, V>>;
21
+ export declare function insertInParentAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, node: BPTreeUnknownNode<K, V>, value: V, newSiblingNode: BPTreeUnknownNode<K, V>): Promise<void>;
22
+ export declare function insertOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, key: K, value: V, comparator: ValueComparator<V>): Promise<void>;
23
+ export declare function deleteEntryAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, comparator: ValueComparator<V>): Promise<BPTreeUnknownNode<K, V>>;
24
+ export declare function deleteOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, key: K, comparator: ValueComparator<V>, value?: V): Promise<void>;
25
+ export declare function batchInsertOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, entries: [K, V][], comparator: ValueComparator<V>): Promise<void>;
26
+ export declare function bulkLoadOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, entries: [K, V][], comparator: ValueComparator<V>): Promise<void>;
27
+ export declare function existsOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, key: K, value: V, comparator: ValueComparator<V>): Promise<boolean>;
28
+ export declare function getOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, key: K): Promise<V | undefined>;
29
+ export declare function whereStreamOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, condition: BPTreeCondition<V>, comparator: ValueComparator<V>, verifierMap: Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>, searchConfigs: Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', AsyncSearchConfigEntry<K, V>>>, ensureValues: (v: V | V[]) => V[], options?: BPTreeSearchOption<K>): AsyncGenerator<[K, V]>;
30
+ export declare function keysStreamOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, condition: BPTreeCondition<V>, comparator: ValueComparator<V>, verifierMap: Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>, searchConfigs: Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', AsyncSearchConfigEntry<K, V>>>, ensureValues: (v: V | V[]) => V[], options?: BPTreeSearchOption<K>): AsyncGenerator<K>;
31
+ export declare function initOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, strategyOrder: number, strategyHead: {
32
+ data: SerializableData;
33
+ }, setStrategyHead: (head: SerializeStrategyHead) => void): Promise<void>;
@@ -0,0 +1,47 @@
1
+ import type { BPTreeCondition, BPTreeLeafNode, BPTreeNodeKey, BPTreeUnknownNode, BPTreeSearchOption, SerializableData, SerializeStrategyHead } from '../types';
2
+ import type { BPTreeNodeOps, BPTreeAlgoContext } from './BPTreeNodeOps';
3
+ import { ValueComparator } from './ValueComparator';
4
+ export declare function cloneNode<K, V, T extends BPTreeUnknownNode<K, V>>(node: T): T;
5
+ export declare function binarySearchValues<V>(values: V[], target: V, comparator: ValueComparator<V>, usePrimary?: boolean, upperBound?: boolean): {
6
+ index: number;
7
+ found: boolean;
8
+ };
9
+ export declare function insertValueIntoLeaf<K, V>(leaf: BPTreeLeafNode<K, V>, key: K, value: V, comparator: ValueComparator<V>): boolean;
10
+ export declare function createVerifierMap<V>(comparator: ValueComparator<V>, cachedRegexp: Map<string, RegExp>, ensureValues: (v: V | V[]) => V[]): Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>;
11
+ type SearchConfigEntry<K, V> = {
12
+ start: (rootId: string, ops: BPTreeNodeOps<K, V>, v: V[]) => BPTreeLeafNode<K, V> | null;
13
+ end: (rootId: string, ops: BPTreeNodeOps<K, V>, v: V[]) => BPTreeLeafNode<K, V> | null;
14
+ direction: 1 | -1;
15
+ earlyTerminate: boolean;
16
+ };
17
+ export declare function createSearchConfigs<K, V>(comparator: ValueComparator<V>, ensureValues: (v: V | V[]) => V[]): Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', SearchConfigEntry<K, V>>>;
18
+ export declare function resolveStartEndConfigs<V>(condition: BPTreeCondition<V>, order: 'asc' | 'desc', comparator: ValueComparator<V>, ensureValues: (v: V | V[]) => V[]): {
19
+ startKey: keyof BPTreeCondition<V> | null;
20
+ endKey: keyof BPTreeCondition<V> | null;
21
+ startValues: V[];
22
+ endValues: V[];
23
+ direction: 1 | -1;
24
+ };
25
+ export declare function verify<V>(nodeValue: V, condition: BPTreeCondition<V>, verifierMap: Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>): boolean;
26
+ export declare function locateLeaf<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): BPTreeLeafNode<K, V>;
27
+ export declare function findLowerBoundLeaf<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): BPTreeLeafNode<K, V>;
28
+ export declare function findUpperBoundLeaf<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): BPTreeLeafNode<K, V>;
29
+ export declare function findOuterBoundaryLeaf<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, value: V, direction: 1 | -1, comparator: ValueComparator<V>): BPTreeLeafNode<K, V> | null;
30
+ export declare function leftestNode<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string): BPTreeLeafNode<K, V>;
31
+ export declare function rightestNode<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string): BPTreeLeafNode<K, V>;
32
+ export declare function getPairsGenerator<K, V>(ops: BPTreeNodeOps<K, V>, startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, direction: 1 | -1): Generator<[K, V]>;
33
+ export declare function insertAtLeaf<K, V>(ops: BPTreeNodeOps<K, V>, node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V, comparator: ValueComparator<V>): BPTreeUnknownNode<K, V>;
34
+ export declare function insertInParent<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, node: BPTreeUnknownNode<K, V>, value: V, newSiblingNode: BPTreeUnknownNode<K, V>): void;
35
+ export declare function insertOp<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, key: K, value: V, comparator: ValueComparator<V>): void;
36
+ export declare function deleteEntry<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, comparator: ValueComparator<V>): BPTreeUnknownNode<K, V>;
37
+ export declare function deleteOp<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, key: K, comparator: ValueComparator<V>, value?: V): void;
38
+ export declare function batchInsertOp<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, entries: [K, V][], comparator: ValueComparator<V>): void;
39
+ export declare function bulkLoadOp<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, entries: [K, V][], comparator: ValueComparator<V>): void;
40
+ export declare function existsOp<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, key: K, value: V, comparator: ValueComparator<V>): boolean;
41
+ export declare function getOp<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, key: K): V | undefined;
42
+ export declare function whereStreamOp<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, condition: BPTreeCondition<V>, comparator: ValueComparator<V>, verifierMap: Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>, searchConfigs: Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', SearchConfigEntry<K, V>>>, ensureValues: (v: V | V[]) => V[], options?: BPTreeSearchOption<K>): Generator<[K, V]>;
43
+ export declare function keysStreamOp<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, condition: BPTreeCondition<V>, comparator: ValueComparator<V>, verifierMap: Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>, searchConfigs: Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', SearchConfigEntry<K, V>>>, ensureValues: (v: V | V[]) => V[], options?: BPTreeSearchOption<K>): Generator<K>;
44
+ export declare function initOp<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, strategyOrder: number, strategyHead: {
45
+ data: SerializableData;
46
+ }, setStrategyHead: (head: SerializeStrategyHead) => void): void;
47
+ export {};
@@ -0,0 +1,34 @@
1
+ import type { BPTreeUnknownNode, SerializableData, SerializeStrategyHead } from '../types';
2
+ /**
3
+ * Abstraction for B+Tree node access operations.
4
+ * Both MVCC-based (BPTreeSyncTransaction) and strategy-direct (BPTreePure)
5
+ * implementations provide this interface to the shared algorithm functions.
6
+ */
7
+ export interface BPTreeNodeOps<K, V> {
8
+ getNode(id: string): BPTreeUnknownNode<K, V>;
9
+ createNode(leaf: boolean, keys: string[] | K[][], values: V[], parent?: string | null, next?: string | null, prev?: string | null): BPTreeUnknownNode<K, V>;
10
+ updateNode(node: BPTreeUnknownNode<K, V>): void;
11
+ deleteNode(node: BPTreeUnknownNode<K, V>): void;
12
+ readHead(): SerializeStrategyHead | null;
13
+ writeHead(head: SerializeStrategyHead): void;
14
+ }
15
+ /**
16
+ * Mutable algorithm context passed to B+Tree algorithm functions.
17
+ * `rootId` is mutable because tree mutations (insert, delete) may change the root.
18
+ */
19
+ export interface BPTreeAlgoContext<K, V> {
20
+ rootId: string;
21
+ order: number;
22
+ readonly headData: () => SerializableData;
23
+ }
24
+ /**
25
+ * Async version of BPTreeNodeOps for async B+Tree operations.
26
+ */
27
+ export interface BPTreeNodeOpsAsync<K, V> {
28
+ getNode(id: string): Promise<BPTreeUnknownNode<K, V>>;
29
+ createNode(leaf: boolean, keys: string[] | K[][], values: V[], parent?: string | null, next?: string | null, prev?: string | null): Promise<BPTreeUnknownNode<K, V>>;
30
+ updateNode(node: BPTreeUnknownNode<K, V>): Promise<void>;
31
+ deleteNode(node: BPTreeUnknownNode<K, V>): Promise<void>;
32
+ readHead(): Promise<SerializeStrategyHead | null>;
33
+ writeHead(head: SerializeStrategyHead): Promise<void>;
34
+ }
@@ -3,9 +3,7 @@ import type { BPTreeCondition, BPTreeConstructorOption, BPTreeUnknownNode, Defer
3
3
  import { ValueComparator } from './ValueComparator';
4
4
  import { SerializeStrategy } from './SerializeStrategy';
5
5
  export declare abstract class BPTreeTransaction<K, V> {
6
- private readonly _cachedRegexp;
7
- protected readonly nodes: Map<string, BPTreeUnknownNode<K, V>>;
8
- protected readonly deletedNodeBuffer: Map<string, BPTreeUnknownNode<K, V>>;
6
+ protected readonly _cachedRegexp: Map<string, RegExp>;
9
7
  protected readonly rootTx: BPTreeTransaction<K, V>;
10
8
  protected readonly mvccRoot: BPTreeMVCC<K, V>;
11
9
  protected readonly mvcc: BPTreeMVCC<K, V>;
@@ -122,6 +120,12 @@ export declare abstract class BPTreeTransaction<K, V> {
122
120
  * If it is not called, the tree will not function.
123
121
  */
124
122
  abstract init(): Deferred<void>;
123
+ /**
124
+ * Clears all in-memory caches and re-initializes the tree from storage.
125
+ * This is equivalent to calling `clear()` followed by `init()`, but reuses the same instance.
126
+ * Useful when the underlying storage has been modified externally and the tree needs to reflect current state.
127
+ */
128
+ abstract reload(): Deferred<void>;
125
129
  /**
126
130
  * Retrieves the value associated with the given key.
127
131
  * @param key The key to search for.
@@ -233,6 +237,7 @@ export declare abstract class BPTreeTransaction<K, V> {
233
237
  deleted: TransactionEntry<string, BPTreeNode<K, V>>[];
234
238
  };
235
239
  protected _clearCache(): void;
240
+ protected _resetForReload(): void;
236
241
  /**
237
242
  * Clears all cached nodes.
238
243
  * This method is useful for freeing up memory when the tree is no longer needed.
@@ -4,5 +4,7 @@ export { BPTreeSync } from './BPTreeSync';
4
4
  export { BPTreeSyncTransaction } from './transaction/BPTreeSyncTransaction';
5
5
  export { BPTreeAsync } from './BPTreeAsync';
6
6
  export { BPTreeAsyncTransaction } from './transaction/BPTreeAsyncTransaction';
7
+ export { BPTreePureSync } from './BPTreePureSync';
8
+ export { BPTreePureAsync } from './BPTreePureAsync';
7
9
  export { SerializeStrategySync, InMemoryStoreStrategySync } from './SerializeStrategySync';
8
10
  export { SerializeStrategyAsync, InMemoryStoreStrategyAsync } from './SerializeStrategyAsync';
@@ -1,6 +1,7 @@
1
1
  import type { TransactionResult } from 'mvcc-api';
2
- import type { AsyncBPTreeMVCC, BPTreeCondition, BPTreeConstructorOption, BPTreeLeafNode, BPTreeNode, BPTreeNodeKey, BPTreePair, BPTreeUnknownNode, SerializableData, SerializeStrategyHead, BPTreeSearchOption } from '../types';
2
+ import type { AsyncBPTreeMVCC, BPTreeCondition, BPTreeConstructorOption, BPTreeNode, BPTreeNodeKey, BPTreePair, BPTreeUnknownNode, SerializableData, SerializeStrategyHead, BPTreeSearchOption, BPTreeLeafNode } from '../types';
3
3
  import { Ryoiki } from 'ryoiki';
4
+ import { getPairsGeneratorAsync } from '../base/BPTreeAlgorithmAsync';
4
5
  import { BPTreeTransaction } from '../base/BPTreeTransaction';
5
6
  import { SerializeStrategyAsync } from '../SerializeStrategyAsync';
6
7
  import { ValueComparator } from '../base/ValueComparator';
@@ -12,12 +13,14 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeTransaction<K, V
12
13
  protected readonly comparator: ValueComparator<V>;
13
14
  protected readonly option: BPTreeConstructorOption;
14
15
  protected readonly lock: Ryoiki;
16
+ private _ops;
17
+ private _ctx;
18
+ private _verifierMapCached;
19
+ private _searchConfigsCached;
15
20
  constructor(rootTx: BPTreeAsyncTransaction<K, V> | null, mvccRoot: AsyncBPTreeMVCC<K, V>, mvcc: AsyncBPTreeMVCC<K, V>, strategy: SerializeStrategyAsync<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
21
+ private _initAlgoContext;
16
22
  protected writeLock<T>(id: number, fn: () => Promise<T>): Promise<T>;
17
23
  protected getNode(id: string): Promise<BPTreeUnknownNode<K, V>>;
18
- /**
19
- * Create a new node with a unique ID.
20
- */
21
24
  protected _createNode(leaf: boolean, keys: string[] | K[][], values: V[], parent?: string | null, next?: string | null, prev?: string | null): Promise<BPTreeUnknownNode<K, V>>;
22
25
  protected _updateNode(node: BPTreeUnknownNode<K, V>): Promise<void>;
23
26
  protected _deleteNode(node: BPTreeUnknownNode<K, V>): Promise<void>;
@@ -31,9 +34,11 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeTransaction<K, V
31
34
  protected findOuterBoundaryLeaf(value: V, direction: 1 | -1): Promise<BPTreeLeafNode<K, V> | null>;
32
35
  protected leftestNode(): Promise<BPTreeLeafNode<K, V>>;
33
36
  protected rightestNode(): Promise<BPTreeLeafNode<K, V>>;
34
- protected getPairsGenerator(startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, direction: 1 | -1): AsyncGenerator<[K, V]>;
37
+ protected getPairsGenerator(startNode: Parameters<typeof getPairsGeneratorAsync<K, V>>[1], endNode: Parameters<typeof getPairsGeneratorAsync<K, V>>[2], direction: 1 | -1): AsyncGenerator<[BPTreeNodeKey<K>, V], void, unknown>;
35
38
  init(): Promise<void>;
36
39
  protected _initInternal(): Promise<void>;
40
+ reload(): Promise<void>;
41
+ protected _reloadInternal(): Promise<void>;
37
42
  exists(key: K, value: V): Promise<boolean>;
38
43
  get(key: K): Promise<V | undefined>;
39
44
  keysStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): AsyncGenerator<K>;
@@ -1,5 +1,6 @@
1
1
  import type { TransactionResult } from 'mvcc-api';
2
- import type { BPTreeCondition, BPTreeConstructorOption, BPTreeLeafNode, BPTreeNode, BPTreeNodeKey, BPTreePair, BPTreeUnknownNode, SerializableData, SerializeStrategyHead, SyncBPTreeMVCC, BPTreeSearchOption } from '../types';
2
+ import type { BPTreeCondition, BPTreeConstructorOption, BPTreeNode, BPTreeNodeKey, BPTreePair, BPTreeUnknownNode, SerializableData, SerializeStrategyHead, SyncBPTreeMVCC, BPTreeSearchOption, BPTreeLeafNode } from '../types';
3
+ import { getPairsGenerator } from '../base/BPTreeAlgorithmSync';
3
4
  import { BPTreeTransaction } from '../base/BPTreeTransaction';
4
5
  import { SerializeStrategySync } from '../SerializeStrategySync';
5
6
  import { ValueComparator } from '../base/ValueComparator';
@@ -10,11 +11,13 @@ export declare class BPTreeSyncTransaction<K, V> extends BPTreeTransaction<K, V>
10
11
  protected readonly strategy: SerializeStrategySync<K, V>;
11
12
  protected readonly comparator: ValueComparator<V>;
12
13
  protected readonly option: BPTreeConstructorOption;
14
+ private _ops;
15
+ private _ctx;
16
+ private _verifierMapCached;
17
+ private _searchConfigsCached;
13
18
  constructor(rootTx: BPTreeSyncTransaction<K, V>, mvccRoot: SyncBPTreeMVCC<K, V>, mvcc: SyncBPTreeMVCC<K, V>, strategy: SerializeStrategySync<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
19
+ private _initAlgoContext;
14
20
  protected getNode(id: string): BPTreeUnknownNode<K, V>;
15
- /**
16
- * Create a new node with a unique ID.
17
- */
18
21
  protected _createNode(leaf: boolean, keys: string[] | K[][], values: V[], parent?: string | null, next?: string | null, prev?: string | null): BPTreeUnknownNode<K, V>;
19
22
  protected _updateNode(node: BPTreeUnknownNode<K, V>): void;
20
23
  protected _deleteNode(node: BPTreeUnknownNode<K, V>): void;
@@ -28,9 +31,11 @@ export declare class BPTreeSyncTransaction<K, V> extends BPTreeTransaction<K, V>
28
31
  protected findOuterBoundaryLeaf(value: V, direction: 1 | -1): BPTreeLeafNode<K, V> | null;
29
32
  protected leftestNode(): BPTreeLeafNode<K, V>;
30
33
  protected rightestNode(): BPTreeLeafNode<K, V>;
31
- protected getPairsGenerator(startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, direction: 1 | -1): Generator<[K, V]>;
34
+ protected getPairsGenerator(startNode: Parameters<typeof getPairsGenerator<K, V>>[1], endNode: Parameters<typeof getPairsGenerator<K, V>>[2], direction: 1 | -1): Generator<[BPTreeNodeKey<K>, V], void, unknown>;
32
35
  init(): void;
33
36
  protected _initInternal(): void;
37
+ reload(): void;
38
+ protected _reloadInternal(): void;
34
39
  exists(key: K, value: V): boolean;
35
40
  get(key: K): V | undefined;
36
41
  keysStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Generator<K>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serializable-bptree",
3
- "version": "8.4.1",
3
+ "version": "9.0.0",
4
4
  "description": "Store the B+tree flexibly, not only in-memory.",
5
5
  "types": "./dist/types/index.d.ts",
6
6
  "main": "./dist/cjs/index.cjs",
@@ -44,7 +44,7 @@
44
44
  "typescript": "^5.9.3"
45
45
  },
46
46
  "dependencies": {
47
- "mvcc-api": "^1.3.6",
47
+ "mvcc-api": "^1.3.7",
48
48
  "ryoiki": "^1.2.0"
49
49
  }
50
50
  }