Skip to content

Commit

Permalink
Right address is now null for last leaf page.
Browse files Browse the repository at this point in the history
Closes #473.
  • Loading branch information
flatheadmill committed Feb 18, 2015
1 parent 66e238b commit d3f25e8
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions balancer.js
Expand Up @@ -21,7 +21,7 @@ Balancer.prototype._node = cadence(function (async, locker, page) {
var node = {
key: entry.key,
address: page.address,
rightAddress: page.right._address,
rightAddress: page.right.address,
length: page.items.length - page.ghosts
}
this.ordered[node.address] = node
Expand Down Expand Up @@ -290,7 +290,7 @@ Balancer.prototype.splitLeafAndUnlock = cadence(function (async, address, key, g
}

right = {
_address: page.address,
address: page.address,
key: page.items[0].key
}
}, function () {
Expand Down
6 changes: 3 additions & 3 deletions cursor.js
Expand Up @@ -24,13 +24,13 @@ Cursor.prototype.get = function (index) {
Cursor.prototype.next = cadence(function (async) {
var next

if (this._page.right._address === null) {
if (this._page.right.address === null) {
// return [ async, false ] <- return immediately!
return [ false ]
}

async(function () {
this._locker.lock(this._page.right._address, this.exclusive, async())
this._locker.lock(this._page.right.address, this.exclusive, async())
}, function (next) {
this._locker.unlock(this._page)

Expand All @@ -51,7 +51,7 @@ Cursor.prototype.indexOf = function (key, index) {
var unambiguous
unambiguous = -1 < index // <- todo: ?
|| ~ index < this._page.items.length
|| page.right._address === null
|| page.right.address === null
if (!unambiguous && this._sheaf.comparator(key, page.right.key) >= 0) {
return [ ~(this._page.items.length + 1) ]
}
Expand Down
2 changes: 1 addition & 1 deletion logger.js
Expand Up @@ -36,7 +36,7 @@ Logger.prototype.writeDelete = function (queue, page, index, callback) {
}

Logger.prototype.writeHeader = function (queue, page) {
var header = [ ++page.entries, 0, page.right._address || 0, page.ghosts || 0 ]
var header = [ ++page.entries, 0, page.right.address || 0, page.ghosts || 0 ]
return this.writeEntry(queue, header, page.right.key, this.serializers.key)
}

Expand Down
2 changes: 1 addition & 1 deletion page.js
Expand Up @@ -12,7 +12,7 @@ function Page (sheaf, address, modulus) {
this.queue = sequester.createQueue()
this.cartridge = null
if (modulus === 1) {
this.right = { _address: null, key: null }
this.right = { address: null, key: null }
this.ghosts = 0
}
}
Expand Down
2 changes: 1 addition & 1 deletion player.js
Expand Up @@ -68,7 +68,7 @@ Player.prototype._play = function (sheaf, slice, start, page) {
if (header[1] === 0) {
if (page.position === 0) {
page.right = {
_address: header[2] || null,
address: header[2] || null,
key: entry.body || null
}
if (header[3] === 0 && page.ghosts) {
Expand Down
2 changes: 1 addition & 1 deletion t/basics/backward.t.js
Expand Up @@ -13,7 +13,7 @@ function prove (async, assert) {
strata.mutator(strata.leftOf('c'), async())
}, function (cursor) {
assert(cursor.exclusive, 'exclusive')
right = cursor.right._address
right = cursor.right.address
assert(cursor.get(0).record, 'a', 'go left')
cursor.unlock(async())
}, function () {
Expand Down
2 changes: 1 addition & 1 deletion t/ghost/exorcise.t.js
Expand Up @@ -33,7 +33,7 @@ function prove (async, assert) {
strata.iterator('a', async())
}, function (cursor) {
async(function () {
assert(cursor.right, { key: 'd', _address: 5 }, 'referring leaf updated')
assert(cursor.right, { key: 'd', address: 5 }, 'referring leaf updated')
cursor.next(async())
}, function () {
assert(cursor.get(0).key, 'd', 'key deleted')
Expand Down

0 comments on commit d3f25e8

Please sign in to comment.