serializable-bptree 8.1.2 → 8.1.3

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.
@@ -15,6 +15,8 @@ export declare abstract class BPTreeTransaction<K, V> {
15
15
  protected readonly option: BPTreeConstructorOption;
16
16
  protected order: number;
17
17
  protected rootId: string;
18
+ protected isInitialized: boolean;
19
+ protected isDestroyed: boolean;
18
20
  protected readonly verifierMap: Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>;
19
21
  protected readonly verifierStartNode: Record<keyof BPTreeCondition<V>, (value: V) => Deferred<BPTreeLeafNode<K, V>>>;
20
22
  protected readonly verifierEndNode: Record<keyof BPTreeCondition<V>, (value: V) => Deferred<BPTreeLeafNode<K, V> | null>>;
@@ -94,6 +96,11 @@ export declare abstract class BPTreeTransaction<K, V> {
94
96
  protected abstract insertableEndNode(value: V, direction: 1 | -1): Deferred<BPTreeLeafNode<K, V> | null>;
95
97
  protected abstract leftestNode(): Deferred<BPTreeLeafNode<K, V>>;
96
98
  protected abstract rightestNode(): Deferred<BPTreeLeafNode<K, V>>;
99
+ /**
100
+ * After creating a tree instance, it must be called.
101
+ * This method is used to initialize the stored tree and recover data.
102
+ * If it is not called, the tree will not function.
103
+ */
97
104
  /**
98
105
  * After creating a tree instance, it must be called.
99
106
  * This method is used to initialize the stored tree and recover data.
@@ -177,11 +184,13 @@ export declare abstract class BPTreeTransaction<K, V> {
177
184
  updated: TransactionEntry<string, BPTreeNode<K, V>>[];
178
185
  deleted: TransactionEntry<string, BPTreeNode<K, V>>[];
179
186
  };
187
+ protected _clearCache(): void;
180
188
  /**
181
189
  * Clears all cached nodes.
182
190
  * This method is useful for freeing up memory when the tree is no longer needed.
183
191
  */
184
192
  clear(): void;
193
+ protected _clearInternal(): void;
185
194
  protected _binarySearchValues(values: V[], target: V, usePrimary?: boolean, upperBound?: boolean): {
186
195
  index: number;
187
196
  found: boolean;
@@ -1,5 +1,6 @@
1
1
  import type { TransactionResult } from 'mvcc-api';
2
2
  import type { AsyncBPTreeMVCC, BPTreeCondition, BPTreeConstructorOption, BPTreeLeafNode, BPTreeNode, BPTreeNodeKey, BPTreeOrder, BPTreePair, BPTreeUnknownNode, SerializableData, SerializeStrategyHead } from '../types';
3
+ import { Ryoiki } from 'ryoiki';
3
4
  import { BPTreeTransaction } from '../base/BPTreeTransaction';
4
5
  import { SerializeStrategyAsync } from '../SerializeStrategyAsync';
5
6
  import { ValueComparator } from '../base/ValueComparator';
@@ -10,7 +11,9 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeTransaction<K, V
10
11
  protected readonly strategy: SerializeStrategyAsync<K, V>;
11
12
  protected readonly comparator: ValueComparator<V>;
12
13
  protected readonly option: BPTreeConstructorOption;
14
+ protected readonly lock: Ryoiki;
13
15
  constructor(rootTx: BPTreeAsyncTransaction<K, V> | null, mvccRoot: AsyncBPTreeMVCC<K, V>, mvcc: AsyncBPTreeMVCC<K, V>, strategy: SerializeStrategyAsync<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
16
+ protected writeLock<T>(id: number, fn: () => Promise<T>): Promise<T>;
14
17
  protected getNode(id: string): Promise<BPTreeUnknownNode<K, V>>;
15
18
  /**
16
19
  * Create a new node with a unique ID.
@@ -31,6 +34,7 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeTransaction<K, V
31
34
  protected rightestNode(): Promise<BPTreeLeafNode<K, V>>;
32
35
  protected getPairsGenerator(value: V, startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, comparator: (nodeValue: V, value: V) => boolean, direction: 1 | -1, earlyTerminate: boolean): AsyncGenerator<[K, V]>;
33
36
  init(): Promise<void>;
37
+ protected _initInternal(): Promise<void>;
34
38
  exists(key: K, value: V): Promise<boolean>;
35
39
  forceUpdate(id?: string): Promise<number>;
36
40
  get(key: K): Promise<V | undefined>;
@@ -31,6 +31,7 @@ export declare class BPTreeSyncTransaction<K, V> extends BPTreeTransaction<K, V>
31
31
  protected rightestNode(): BPTreeLeafNode<K, V>;
32
32
  protected getPairsGenerator(value: V, startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, comparator: (nodeValue: V, value: V) => boolean, direction: 1 | -1, earlyTerminate: boolean): Generator<[K, V]>;
33
33
  init(): void;
34
+ protected _initInternal(): void;
34
35
  exists(key: K, value: V): boolean;
35
36
  forceUpdate(id?: string): number;
36
37
  get(key: K): V | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serializable-bptree",
3
- "version": "8.1.2",
3
+ "version": "8.1.3",
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",
@@ -17,7 +17,8 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "test": "jest --runInBand",
20
- "build": "node build/index.js && tsc"
20
+ "build": "node build/index.js && tsc",
21
+ "benchmark": "npx tsx benchmark/index.ts"
21
22
  },
22
23
  "author": "izure <admin@izure.org>",
23
24
  "keywords": [
@@ -44,7 +45,7 @@
44
45
  },
45
46
  "dependencies": {
46
47
  "cache-entanglement": "^1.7.1",
47
- "mvcc-api": "^1.2.11",
48
+ "mvcc-api": "^1.3.1",
48
49
  "ryoiki": "^1.2.0"
49
50
  }
50
- }
51
+ }