From a1f43f4d60bf434baebf13b4810e5db4916baec5 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Sat, 1 Mar 2014 09:13:59 -0700 Subject: Allow reads of unflushed nodes. This commit allows cursors to read updated values from within the RWTransaction. --- db.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'db.go') diff --git a/db.go b/db.go index 22da2e6..8403afc 100644 --- a/db.go +++ b/db.go @@ -304,7 +304,7 @@ func (db *DB) RWTransaction() (*RWTransaction, error) { } // Create a transaction associated with the database. - t := &RWTransaction{nodes: make(map[pgid]*node)} + t := &RWTransaction{} t.init(db) db.rwtransaction = t @@ -571,7 +571,8 @@ func (db *DB) Stat() (*Stat, error) { // page retrieves a page reference from the mmap based on the current page size. func (db *DB) page(id pgid) *page { - return (*page)(unsafe.Pointer(&db.data[id*pgid(db.pageSize)])) + pos := id*pgid(db.pageSize) + return (*page)(unsafe.Pointer(&db.data[pos])) } // pageInBuffer retrieves a page reference from a given byte array based on the current page size. -- cgit v1.2.3