serializable-bptree 8.4.1 → 8.4.2
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.
package/dist/cjs/index.cjs
CHANGED
|
@@ -1569,8 +1569,6 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
1569
1569
|
// src/base/BPTreeTransaction.ts
|
|
1570
1570
|
var BPTreeTransaction = class _BPTreeTransaction {
|
|
1571
1571
|
_cachedRegexp = /* @__PURE__ */ new Map();
|
|
1572
|
-
nodes = /* @__PURE__ */ new Map();
|
|
1573
|
-
deletedNodeBuffer = /* @__PURE__ */ new Map();
|
|
1574
1572
|
rootTx;
|
|
1575
1573
|
mvccRoot;
|
|
1576
1574
|
mvcc;
|
|
@@ -2051,6 +2049,12 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
2051
2049
|
_clearCache() {
|
|
2052
2050
|
this._cachedRegexp.clear();
|
|
2053
2051
|
}
|
|
2052
|
+
_resetForReload() {
|
|
2053
|
+
this._cachedRegexp.clear();
|
|
2054
|
+
this.isInitialized = false;
|
|
2055
|
+
this.isDestroyed = false;
|
|
2056
|
+
this.mvccRoot.diskCache.clear();
|
|
2057
|
+
}
|
|
2054
2058
|
/**
|
|
2055
2059
|
* Clears all cached nodes.
|
|
2056
2060
|
* This method is useful for freeing up memory when the tree is no longer needed.
|
|
@@ -2381,6 +2385,16 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2381
2385
|
throw e;
|
|
2382
2386
|
}
|
|
2383
2387
|
}
|
|
2388
|
+
reload() {
|
|
2389
|
+
if (this.rootTx !== this) {
|
|
2390
|
+
throw new Error("Cannot call reload on a nested transaction");
|
|
2391
|
+
}
|
|
2392
|
+
this._reloadInternal();
|
|
2393
|
+
}
|
|
2394
|
+
_reloadInternal() {
|
|
2395
|
+
this._resetForReload();
|
|
2396
|
+
this._initInternal();
|
|
2397
|
+
}
|
|
2384
2398
|
exists(key, value) {
|
|
2385
2399
|
const node = this.locateLeaf(value);
|
|
2386
2400
|
const { index, found } = this._binarySearchValues(node.values, value);
|
|
@@ -3587,6 +3601,16 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3587
3601
|
throw e;
|
|
3588
3602
|
}
|
|
3589
3603
|
}
|
|
3604
|
+
async reload() {
|
|
3605
|
+
if (this.rootTx !== this) {
|
|
3606
|
+
throw new Error("Cannot call reload on a nested transaction");
|
|
3607
|
+
}
|
|
3608
|
+
return await this._reloadInternal();
|
|
3609
|
+
}
|
|
3610
|
+
async _reloadInternal() {
|
|
3611
|
+
this._resetForReload();
|
|
3612
|
+
await this._initInternal();
|
|
3613
|
+
}
|
|
3590
3614
|
async exists(key, value) {
|
|
3591
3615
|
const node = await this.locateLeaf(value);
|
|
3592
3616
|
const { index, found } = this._binarySearchValues(node.values, value);
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1533,8 +1533,6 @@ var AsyncMVCCTransaction = class _AsyncMVCCTransaction extends MVCCTransaction {
|
|
|
1533
1533
|
// src/base/BPTreeTransaction.ts
|
|
1534
1534
|
var BPTreeTransaction = class _BPTreeTransaction {
|
|
1535
1535
|
_cachedRegexp = /* @__PURE__ */ new Map();
|
|
1536
|
-
nodes = /* @__PURE__ */ new Map();
|
|
1537
|
-
deletedNodeBuffer = /* @__PURE__ */ new Map();
|
|
1538
1536
|
rootTx;
|
|
1539
1537
|
mvccRoot;
|
|
1540
1538
|
mvcc;
|
|
@@ -2015,6 +2013,12 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
2015
2013
|
_clearCache() {
|
|
2016
2014
|
this._cachedRegexp.clear();
|
|
2017
2015
|
}
|
|
2016
|
+
_resetForReload() {
|
|
2017
|
+
this._cachedRegexp.clear();
|
|
2018
|
+
this.isInitialized = false;
|
|
2019
|
+
this.isDestroyed = false;
|
|
2020
|
+
this.mvccRoot.diskCache.clear();
|
|
2021
|
+
}
|
|
2018
2022
|
/**
|
|
2019
2023
|
* Clears all cached nodes.
|
|
2020
2024
|
* This method is useful for freeing up memory when the tree is no longer needed.
|
|
@@ -2345,6 +2349,16 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2345
2349
|
throw e;
|
|
2346
2350
|
}
|
|
2347
2351
|
}
|
|
2352
|
+
reload() {
|
|
2353
|
+
if (this.rootTx !== this) {
|
|
2354
|
+
throw new Error("Cannot call reload on a nested transaction");
|
|
2355
|
+
}
|
|
2356
|
+
this._reloadInternal();
|
|
2357
|
+
}
|
|
2358
|
+
_reloadInternal() {
|
|
2359
|
+
this._resetForReload();
|
|
2360
|
+
this._initInternal();
|
|
2361
|
+
}
|
|
2348
2362
|
exists(key, value) {
|
|
2349
2363
|
const node = this.locateLeaf(value);
|
|
2350
2364
|
const { index, found } = this._binarySearchValues(node.values, value);
|
|
@@ -3551,6 +3565,16 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3551
3565
|
throw e;
|
|
3552
3566
|
}
|
|
3553
3567
|
}
|
|
3568
|
+
async reload() {
|
|
3569
|
+
if (this.rootTx !== this) {
|
|
3570
|
+
throw new Error("Cannot call reload on a nested transaction");
|
|
3571
|
+
}
|
|
3572
|
+
return await this._reloadInternal();
|
|
3573
|
+
}
|
|
3574
|
+
async _reloadInternal() {
|
|
3575
|
+
this._resetForReload();
|
|
3576
|
+
await this._initInternal();
|
|
3577
|
+
}
|
|
3554
3578
|
async exists(key, value) {
|
|
3555
3579
|
const node = await this.locateLeaf(value);
|
|
3556
3580
|
const { index, found } = this._binarySearchValues(node.values, value);
|
|
@@ -4,8 +4,6 @@ import { ValueComparator } from './ValueComparator';
|
|
|
4
4
|
import { SerializeStrategy } from './SerializeStrategy';
|
|
5
5
|
export declare abstract class BPTreeTransaction<K, V> {
|
|
6
6
|
private readonly _cachedRegexp;
|
|
7
|
-
protected readonly nodes: Map<string, BPTreeUnknownNode<K, V>>;
|
|
8
|
-
protected readonly deletedNodeBuffer: Map<string, BPTreeUnknownNode<K, V>>;
|
|
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.
|
|
@@ -34,6 +34,8 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeTransaction<K, V
|
|
|
34
34
|
protected getPairsGenerator(startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, direction: 1 | -1): AsyncGenerator<[K, V]>;
|
|
35
35
|
init(): Promise<void>;
|
|
36
36
|
protected _initInternal(): Promise<void>;
|
|
37
|
+
reload(): Promise<void>;
|
|
38
|
+
protected _reloadInternal(): Promise<void>;
|
|
37
39
|
exists(key: K, value: V): Promise<boolean>;
|
|
38
40
|
get(key: K): Promise<V | undefined>;
|
|
39
41
|
keysStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): AsyncGenerator<K>;
|
|
@@ -31,6 +31,8 @@ export declare class BPTreeSyncTransaction<K, V> extends BPTreeTransaction<K, V>
|
|
|
31
31
|
protected getPairsGenerator(startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, direction: 1 | -1): Generator<[K, V]>;
|
|
32
32
|
init(): void;
|
|
33
33
|
protected _initInternal(): void;
|
|
34
|
+
reload(): void;
|
|
35
|
+
protected _reloadInternal(): void;
|
|
34
36
|
exists(key: K, value: V): boolean;
|
|
35
37
|
get(key: K): V | undefined;
|
|
36
38
|
keysStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Generator<K>;
|