diff --git a/deno.json b/deno.json index 5167da7..68666fd 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@izure/serializable-bptree", - "version": "5.0.3", + "version": "5.0.4", "description": "Store the B+tree flexibly, not only in-memory.", "author": "izure1 ", "license": "MIT", diff --git a/package.json b/package.json index de27986..768cadc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serializable-bptree", - "version": "5.0.3", + "version": "5.0.4", "description": "Store the B+tree flexibly, not only in-memory.", "types": "./dist/types/index.d.ts", "main": "./dist/cjs/index.cjs", diff --git a/src/BPTreeAsync.ts b/src/BPTreeAsync.ts index cf5a247..7954719 100644 --- a/src/BPTreeAsync.ts +++ b/src/BPTreeAsync.ts @@ -164,11 +164,11 @@ export class BPTreeAsync extends BPTree { this.root = await this.getNode(keys[0]) this.root.parent = null this.strategy.head.root = this.root.id - this._strategyDirty = true this.bufferForNodeUpdate(this.root) return } else if (this.root === node) { + this.bufferForNodeUpdate(this.root) return } else if ( @@ -370,7 +370,6 @@ export class BPTreeAsync extends BPTree { const root = await this._createNode(false, [node.id, pointer.id], [value]) this.root = root this.strategy.head.root = root.id - this._strategyDirty = true node.parent = root.id pointer.parent = root.id this.bufferForNodeCreate(root) diff --git a/src/BPTreeSync.ts b/src/BPTreeSync.ts index 531011e..7ebd25d 100644 --- a/src/BPTreeSync.ts +++ b/src/BPTreeSync.ts @@ -164,11 +164,11 @@ export class BPTreeSync extends BPTree { this.root = this.getNode(keys[0]) this.root.parent = null this.strategy.head.root = this.root.id - this._strategyDirty = true this.bufferForNodeUpdate(this.root) return } else if (this.root === node) { + this.bufferForNodeUpdate(this.root) return } else if ( @@ -370,7 +370,6 @@ export class BPTreeSync extends BPTree { const root = this._createNode(false, [node.id, pointer.id], [value]) this.root = root this.strategy.head.root = root.id - this._strategyDirty = true node.parent = root.id pointer.parent = root.id this.bufferForNodeCreate(root) diff --git a/src/base/BPTree.ts b/src/base/BPTree.ts index 02fd821..14aa3ce 100644 --- a/src/base/BPTree.ts +++ b/src/base/BPTree.ts @@ -254,14 +254,23 @@ export abstract class BPTree { } protected bufferForNodeCreate(node: BPTreeUnknownNode): void { + if (node.id === this.root.id) { + this._strategyDirty = true + } this._nodeCreateBuffer.set(node.id, node) } protected bufferForNodeUpdate(node: BPTreeUnknownNode): void { + if (node.id === this.root.id) { + this._strategyDirty = true + } this._nodeUpdateBuffer.set(node.id, node) } protected bufferForNodeDelete(node: BPTreeUnknownNode): void { + if (node.id === this.root.id) { + this._strategyDirty = true + } this._nodeDeleteBuffer.set(node.id, node) }