serializable-bptree 8.1.3 → 8.1.4

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.
@@ -1,11 +1,10 @@
1
1
  import type { TransactionEntry, TransactionResult } from 'mvcc-api';
2
2
  import type { BPTreeCondition, BPTreeConstructorOption, BPTreeUnknownNode, Deferred, BPTreeLeafNode, BPTreeNodeKey, BPTreePair, SerializableData, BPTreeNode, BPTreeMVCC } from '../types';
3
- import { LRUMap } from 'cache-entanglement';
4
3
  import { ValueComparator } from './ValueComparator';
5
4
  import { SerializeStrategy } from './SerializeStrategy';
6
5
  export declare abstract class BPTreeTransaction<K, V> {
7
6
  private readonly _cachedRegexp;
8
- protected readonly nodes: LRUMap<string, BPTreeUnknownNode<K, V>>;
7
+ protected readonly nodes: Map<string, BPTreeUnknownNode<K, V>>;
9
8
  protected readonly deletedNodeBuffer: Map<string, BPTreeUnknownNode<K, V>>;
10
9
  protected readonly rootTx: BPTreeTransaction<K, V>;
11
10
  protected readonly mvccRoot: BPTreeMVCC<K, V>;
@@ -74,6 +73,7 @@ export declare abstract class BPTreeTransaction<K, V> {
74
73
  * @returns Returns true if the value satisfies the condition.
75
74
  */
76
75
  verify(nodeValue: V, condition: BPTreeCondition<V>): boolean;
76
+ protected _cloneNode<T extends BPTreeUnknownNode<K, V>>(node: T): T;
77
77
  /**
78
78
  * Selects the best driver key from a condition object.
79
79
  * The driver key determines the starting point and traversal direction for queries.
@@ -83,11 +83,10 @@ export declare abstract class BPTreeTransaction<K, V> {
83
83
  */
84
84
  protected getDriverKey(condition: BPTreeCondition<V>): keyof BPTreeCondition<V> | null;
85
85
  protected constructor(rootTx: BPTreeTransaction<K, V> | null, mvccRoot: BPTreeMVCC<K, V>, mvcc: BPTreeMVCC<K, V>, strategy: SerializeStrategy<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
86
- private _createCachedRegexp;
87
86
  protected abstract _createNode(leaf: boolean, keys: string[] | K[][], values: V[], parent?: string | null, next?: string | null, prev?: string | null): Deferred<BPTreeUnknownNode<K, V>>;
88
- protected abstract _deleteEntry(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V): Deferred<void>;
87
+ protected abstract _deleteEntry(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>): Deferred<BPTreeUnknownNode<K, V>>;
89
88
  protected abstract _insertInParent(node: BPTreeUnknownNode<K, V>, value: V, pointer: BPTreeUnknownNode<K, V>): Deferred<void>;
90
- protected abstract _insertAtLeaf(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V): Deferred<void>;
89
+ protected abstract _insertAtLeaf(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V): Deferred<BPTreeUnknownNode<K, V>>;
91
90
  protected abstract getNode(id: string): Deferred<BPTreeUnknownNode<K, V>>;
92
91
  protected abstract insertableNode(value: V): Deferred<BPTreeLeafNode<K, V>>;
93
92
  protected abstract insertableNodeByPrimary(value: V): Deferred<BPTreeLeafNode<K, V>>;
@@ -149,14 +148,6 @@ export declare abstract class BPTreeTransaction<K, V> {
149
148
  * @param data User-defined data to be stored in the head of the tree.
150
149
  */
151
150
  abstract setHeadData(data: SerializableData): Deferred<void>;
152
- /**
153
- * This method deletes nodes cached in-memory and caches new nodes from the stored nodes.
154
- * Typically, there's no need to use this method, but it can be used to synchronize data in scenarios where the remote storage and the client are in a 1:n relationship.
155
- * If you do not specify an ID, all nodes will be updated.
156
- * @param id The ID of the node to update.
157
- * @returns The return value is the total number of nodes updated.
158
- */
159
- abstract forceUpdate(id?: string): Deferred<number>;
160
151
  /**
161
152
  * Returns the user-defined data stored in the head of the tree.
162
153
  */
@@ -169,7 +160,7 @@ export declare abstract class BPTreeTransaction<K, V> {
169
160
  /**
170
161
  * Rolls back the transaction and returns the result.
171
162
  */
172
- abstract rollback(): TransactionResult<string, BPTreeNode<K, V>>;
163
+ abstract rollback(): Deferred<TransactionResult<string, BPTreeNode<K, V>>>;
173
164
  protected ensureValues(v: V | V[]): V[];
174
165
  protected lowestValue(v: V[]): V;
175
166
  protected highestValue(v: V[]): V;
@@ -23,7 +23,7 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeTransaction<K, V
23
23
  protected _deleteNode(node: BPTreeUnknownNode<K, V>): Promise<void>;
24
24
  protected _readHead(): Promise<SerializeStrategyHead | null>;
25
25
  protected _writeHead(head: SerializeStrategyHead): Promise<void>;
26
- protected _insertAtLeaf(node: BPTreeLeafNode<K, V>, key: K, value: V): Promise<void>;
26
+ protected _insertAtLeaf(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V): Promise<BPTreeUnknownNode<K, V>>;
27
27
  protected _insertInParent(node: BPTreeUnknownNode<K, V>, value: V, pointer: BPTreeUnknownNode<K, V>): Promise<void>;
28
28
  protected insertableNode(value: V): Promise<BPTreeLeafNode<K, V>>;
29
29
  protected insertableNodeByPrimary(value: V): Promise<BPTreeLeafNode<K, V>>;
@@ -36,17 +36,16 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeTransaction<K, V
36
36
  init(): Promise<void>;
37
37
  protected _initInternal(): Promise<void>;
38
38
  exists(key: K, value: V): Promise<boolean>;
39
- forceUpdate(id?: string): Promise<number>;
40
39
  get(key: K): Promise<V | undefined>;
41
40
  keysStream(condition: BPTreeCondition<V>, filterValues?: Set<K>, limit?: number, order?: BPTreeOrder): AsyncGenerator<K>;
42
41
  whereStream(condition: BPTreeCondition<V>, limit?: number, order?: BPTreeOrder): AsyncGenerator<[K, V]>;
43
42
  keys(condition: BPTreeCondition<V>, filterValues?: Set<K>, order?: BPTreeOrder): Promise<Set<K>>;
44
43
  where(condition: BPTreeCondition<V>, order?: BPTreeOrder): Promise<BPTreePair<K, V>>;
45
44
  insert(key: K, value: V): Promise<void>;
46
- protected _deleteEntry(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>): Promise<void>;
45
+ protected _deleteEntry(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>): Promise<BPTreeUnknownNode<K, V>>;
47
46
  delete(key: K, value: V): Promise<void>;
48
47
  getHeadData(): Promise<SerializableData>;
49
48
  setHeadData(data: SerializableData): Promise<void>;
50
49
  commit(label?: string): Promise<TransactionResult<string, BPTreeNode<K, V>>>;
51
- rollback(): TransactionResult<string, BPTreeNode<K, V>>;
50
+ rollback(): Promise<TransactionResult<string, BPTreeNode<K, V>>>;
52
51
  }
@@ -20,7 +20,7 @@ export declare class BPTreeSyncTransaction<K, V> extends BPTreeTransaction<K, V>
20
20
  protected _deleteNode(node: BPTreeUnknownNode<K, V>): void;
21
21
  protected _readHead(): SerializeStrategyHead | null;
22
22
  protected _writeHead(head: SerializeStrategyHead): void;
23
- protected _insertAtLeaf(node: BPTreeLeafNode<K, V>, key: K, value: V): void;
23
+ protected _insertAtLeaf(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V): BPTreeUnknownNode<K, V>;
24
24
  protected _insertInParent(node: BPTreeUnknownNode<K, V>, value: V, pointer: BPTreeUnknownNode<K, V>): void;
25
25
  protected insertableNode(value: V): BPTreeLeafNode<K, V>;
26
26
  protected insertableNodeByPrimary(value: V): BPTreeLeafNode<K, V>;
@@ -33,14 +33,13 @@ export declare class BPTreeSyncTransaction<K, V> extends BPTreeTransaction<K, V>
33
33
  init(): void;
34
34
  protected _initInternal(): void;
35
35
  exists(key: K, value: V): boolean;
36
- forceUpdate(id?: string): number;
37
36
  get(key: K): V | undefined;
38
37
  keysStream(condition: BPTreeCondition<V>, filterValues?: Set<K>, limit?: number, order?: BPTreeOrder): Generator<K>;
39
38
  whereStream(condition: BPTreeCondition<V>, limit?: number, order?: BPTreeOrder): Generator<[K, V]>;
40
39
  keys(condition: BPTreeCondition<V>, filterValues?: Set<K>, order?: BPTreeOrder): Set<K>;
41
40
  where(condition: BPTreeCondition<V>, order?: BPTreeOrder): BPTreePair<K, V>;
42
41
  insert(key: K, value: V): void;
43
- protected _deleteEntry(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>): void;
42
+ protected _deleteEntry(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>): BPTreeUnknownNode<K, V>;
44
43
  delete(key: K, value: V): void;
45
44
  getHeadData(): SerializableData;
46
45
  setHeadData(data: SerializableData): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serializable-bptree",
3
- "version": "8.1.3",
3
+ "version": "8.1.4",
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,8 +44,7 @@
44
44
  "typescript": "^5.9.3"
45
45
  },
46
46
  "dependencies": {
47
- "cache-entanglement": "^1.7.1",
48
- "mvcc-api": "^1.3.1",
47
+ "mvcc-api": "^1.3.2",
49
48
  "ryoiki": "^1.2.0"
50
49
  }
51
- }
50
+ }