Skip to content

Commit

Permalink
Remove serializer from B-Tree balancer.
Browse files Browse the repository at this point in the history
The B-Tree serializers counts on the page rewrite to get the heft right.

Closes #476.
  • Loading branch information
flatheadmill committed Feb 11, 2015
1 parent 63f4c99 commit 934181a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion balancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Balancer.prototype.splitLeafAndUnlock = cadence(function (async, sheaf, address,

penultimate.page.splice(penultimate.index + 1, 0, {
key: split.items[offset].key,
heft: sheaf.serialize(split.items[offset].key, true).length,
heft: 0,
address: page.address
})

Expand Down
5 changes: 4 additions & 1 deletion logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@ Logger.prototype.writePage = function (page, file, writer, callback) {
this.writeHeader(queue, page)
}

var i = 0, I = page.items.length
// cut the items out because some might be recently promoted keys that have
// zero heft, we calculate heft here and now.
var cut = page.splice(0, page.items.length), i = 0, I = cut.length
while (i < I) {
for (; i < I && queue.buffers.length == 0; i++) {
page.splice(i, 0, cut[i])
this[writer](queue, page, page.items[i])
}
queue.buffers.forEach(function (buffer) {
Expand Down

0 comments on commit 934181a

Please sign in to comment.