Skip to content

Commit

Permalink
fix: resolve issue where SerializeStrategy's writeHead method did not…
Browse files Browse the repository at this point in the history
… work in certain situations
  • Loading branch information
izure1 committed Nov 26, 2024
1 parent 23928a4 commit 46494c9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 1 addition & 2 deletions src/BPTreeAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ export class BPTreeAsync<K, V> extends BPTree<K, V> {
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 (
Expand Down Expand Up @@ -370,7 +370,6 @@ export class BPTreeAsync<K, V> extends BPTree<K, V> {
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)
Expand Down
3 changes: 1 addition & 2 deletions src/BPTreeSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ export class BPTreeSync<K, V> extends BPTree<K, V> {
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 (
Expand Down Expand Up @@ -370,7 +370,6 @@ export class BPTreeSync<K, V> extends BPTree<K, V> {
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)
Expand Down
9 changes: 9 additions & 0 deletions src/base/BPTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,23 @@ export abstract class BPTree<K, V> {
}

protected bufferForNodeCreate(node: BPTreeUnknownNode<K, V>): void {
if (node.id === this.root.id) {
this._strategyDirty = true
}
this._nodeCreateBuffer.set(node.id, node)
}

protected bufferForNodeUpdate(node: BPTreeUnknownNode<K, V>): void {
if (node.id === this.root.id) {
this._strategyDirty = true
}
this._nodeUpdateBuffer.set(node.id, node)
}

protected bufferForNodeDelete(node: BPTreeUnknownNode<K, V>): void {
if (node.id === this.root.id) {
this._strategyDirty = true
}
this._nodeDeleteBuffer.set(node.id, node)
}

Expand Down

0 comments on commit 46494c9

Please sign in to comment.