From 782ead0dbf3095d0e843c2036bf40cc8ecd9b4d1 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Mon, 19 May 2014 12:08:33 -0600 Subject: Fix freelist allocation direction. This commit fixes the freelist so that it frees from the beginning of the data file instead of the end. It also adds a fast path for pages which can be allocated from the first free pages and it includes read transaction stats. --- bucket_test.go | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'bucket_test.go') diff --git a/bucket_test.go b/bucket_test.go index f6bd13f..16172a5 100644 --- a/bucket_test.go +++ b/bucket_test.go @@ -899,30 +899,21 @@ func TestBucket_Delete_Quick(t *testing.T) { assert.NoError(t, err) // Remove items one at a time and check consistency. - for i, item := range items { + for _, item := range items { err := db.Update(func(tx *Tx) error { return tx.Bucket([]byte("widgets")).Delete(item.Key) }) assert.NoError(t, err) + } - // Anything before our deletion index should be nil. - db.View(func(tx *Tx) error { - b := tx.Bucket([]byte("widgets")) - for j, exp := range items { - value := b.Get(exp.Key) - if j > i { - if !assert.Equal(t, exp.Value, value) { - t.FailNow() - } - } else { - if !assert.Nil(t, value) { - t.FailNow() - } - } - } + // Anything before our deletion index should be nil. + db.View(func(tx *Tx) error { + tx.Bucket([]byte("widgets")).ForEach(func(k, v []byte) error { + t.Fatalf("bucket should be empty; found: %06x", trunc(k, 3)) return nil }) - } + return nil + }) }) return true } -- cgit v1.2.3