serializable-bptree 7.0.0 → 7.0.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.
@@ -10,6 +10,16 @@ export declare abstract class BPTree<K, V> {
10
10
  protected readonly option: BPTreeConstructorOption;
11
11
  protected order: number;
12
12
  protected rootId: string;
13
+ /**
14
+ * Returns the ID of the root node.
15
+ * @returns The root node ID.
16
+ */
17
+ getRootId(): string;
18
+ /**
19
+ * Returns the order of the B+Tree.
20
+ * @returns The order of the tree.
21
+ */
22
+ getOrder(): number;
13
23
  protected _strategyDirty: boolean;
14
24
  protected readonly _nodeCreateBuffer: Map<string, BPTreeUnknownNode<K, V>>;
15
25
  protected readonly _nodeUpdateBuffer: Map<string, BPTreeUnknownNode<K, V>>;
@@ -139,10 +149,10 @@ export declare abstract class BPTree<K, V> {
139
149
  protected highestValue(v: V[]): V;
140
150
  protected lowestPrimaryValue(v: V[]): V;
141
151
  protected highestPrimaryValue(v: V[]): V;
142
- protected _insertAtLeaf(node: BPTreeLeafNode<K, V>, key: K, value: V): void;
143
- protected bufferForNodeCreate(node: BPTreeUnknownNode<K, V>): void;
144
- protected bufferForNodeUpdate(node: BPTreeUnknownNode<K, V>): void;
145
- protected bufferForNodeDelete(node: BPTreeUnknownNode<K, V>): void;
152
+ protected _insertAtLeaf(node: BPTreeLeafNode<K, V>, key: K, value: V): Deferred<void>;
153
+ protected bufferForNodeCreate(node: BPTreeUnknownNode<K, V>): Deferred<void>;
154
+ protected bufferForNodeUpdate(node: BPTreeUnknownNode<K, V>): Deferred<void>;
155
+ protected bufferForNodeDelete(node: BPTreeUnknownNode<K, V>): Deferred<void>;
146
156
  /**
147
157
  * Returns the user-defined data stored in the head of the tree.
148
158
  * This value can be set using the `setHeadData` method. If no data has been previously inserted, the default value is returned, and the default value is `{}`.
@@ -8,8 +8,9 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeAsyncBase<K, V>
8
8
  private readonly realBaseTree;
9
9
  private readonly realBaseStrategy;
10
10
  private txNodes;
11
- private dirtyIds;
12
- private createdInTx;
11
+ protected readonly dirtyIds: Set<string>;
12
+ protected readonly createdInTx: Set<string>;
13
+ protected readonly deletedIds: Set<string>;
13
14
  private initialRootId;
14
15
  private transactionRootId;
15
16
  constructor(baseTree: BPTreeAsyncBase<K, V>);
@@ -32,9 +33,11 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeAsyncBase<K, V>
32
33
  commit(): Promise<BPTreeTransactionResult>;
33
34
  /**
34
35
  * Rolls back the transaction by clearing all buffered changes.
35
- * Internal use only.
36
+ * If cleanup is `true`, it also clears the transaction nodes.
37
+ * @param cleanup Whether to clear the transaction nodes.
38
+ * @returns The IDs of nodes that were created in this transaction.
36
39
  */
37
- protected rollback(): Promise<void>;
40
+ rollback(cleanup?: boolean): Promise<string[]>;
38
41
  protected readLock<T>(fn: () => Promise<T>): Promise<T>;
39
42
  protected writeLock<T>(fn: () => Promise<T>): Promise<T>;
40
43
  protected commitHeadBuffer(): Promise<void>;
@@ -8,8 +8,9 @@ export declare class BPTreeSyncTransaction<K, V> extends BPTreeSyncBase<K, V> {
8
8
  private readonly realBaseTree;
9
9
  private readonly realBaseStrategy;
10
10
  private txNodes;
11
- private dirtyIds;
12
- private createdInTx;
11
+ protected readonly dirtyIds: Set<string>;
12
+ protected readonly createdInTx: Set<string>;
13
+ protected readonly deletedIds: Set<string>;
13
14
  private initialRootId;
14
15
  private transactionRootId;
15
16
  constructor(baseTree: BPTreeSyncBase<K, V>);
@@ -32,9 +33,11 @@ export declare class BPTreeSyncTransaction<K, V> extends BPTreeSyncBase<K, V> {
32
33
  commit(): BPTreeTransactionResult;
33
34
  /**
34
35
  * Rolls back the transaction by clearing all buffered changes.
35
- * Internal use only.
36
+ * If cleanup is `true`, it also clears the transaction nodes.
37
+ * @param cleanup Whether to clear the transaction nodes.
38
+ * @returns The IDs of nodes that were created in this transaction.
36
39
  */
37
- protected rollback(): void;
40
+ rollback(cleanup?: boolean): string[];
38
41
  protected commitHeadBuffer(): void;
39
42
  protected commitNodeCreateBuffer(): void;
40
43
  protected commitNodeUpdateBuffer(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serializable-bptree",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
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",