diff options
Diffstat (limited to 'rwtransaction.go')
-rw-r--r-- | rwtransaction.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/rwtransaction.go b/rwtransaction.go index ed44e3d..2e1685b 100644 --- a/rwtransaction.go +++ b/rwtransaction.go @@ -99,9 +99,8 @@ func (t *RWTransaction) Delete(name string, key []byte) error { func (t *RWTransaction) Commit() error { // TODO(benbjohnson): Use vectorized I/O to write out dirty pages. - // TODO: Rebalance. - - // Spill data onto dirty pages. + // Rebalance and spill data onto dirty pages. + t.rebalance() t.spill() // Spill buckets page. @@ -154,6 +153,13 @@ func (t *RWTransaction) allocate(count int) *page { return p } +// rebalance attempts to balance all nodes. +func (t *RWTransaction) rebalance() { + for _, n := range t.nodes { + n.rebalance() + } +} + // spill writes all the nodes to dirty pages. func (t *RWTransaction) spill() { // Keep track of the current root nodes. |