From 1baa6d576a5f13a55d81c83a167efe0953c0d143 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Sun, 26 Jan 2014 15:29:06 -0700 Subject: Initialize transaction/rwtransaction. --- rwtransaction.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'rwtransaction.go') diff --git a/rwtransaction.go b/rwtransaction.go index 2c0837f..b0123f5 100644 --- a/rwtransaction.go +++ b/rwtransaction.go @@ -5,8 +5,15 @@ package bolt type RWTransaction struct { Transaction - dirtyPages map[int]*page - freelist []pgno + dirtyPages map[pgid]*page + freelist []pgid +} + +// init initializes the transaction and associates it with a database. +func (t *RWTransaction) init(db *DB, meta *meta) { + t.dirtyPages = make(map[pgid]*page) + t.freelist = make([]pgid) + t.Transaction.init(db, meta) } // TODO: Allocate scratch meta page. @@ -232,3 +239,12 @@ func (t *RWTransaction) allocate(count int) (*page, error) { // TODO: If no free pages are available, resize the mmap to allocate more. return nil, nil } + + +func (t *RWTransaction) insert(key []byte, data []byte) error { + // TODO: If there is not enough space on page for key+data then split. + // TODO: Move remaining data on page forward. + // TODO: Write leaf node to current location. + // TODO: Adjust available page size. + return nil +} -- cgit v1.2.3