From 55e71b090259eb775c1bb74a2c3ec23bdfba8db5 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Mon, 5 May 2014 10:27:02 -0600 Subject: Add inline bucket support. This commit adds support for writing small buckets directly inline to their value in their parent's leaf node. Previously, subbuckets would simply have a bucket header stored in their parent bucket which pointed to the root page. This required that every bucket use at least a single page. This has a high overhead for buckets with only one or two small items. Inline buckets checks subbuckets to see if they only have a small amount of data (about 1kb) and no subbuckets. If these conditions are met then the bucket's root node is written to a fake page which is simply a pointer to the end of the bucket's header. Fixes #124. --- db_test.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'db_test.go') diff --git a/db_test.go b/db_test.go index b7e2a2f..903f65e 100644 --- a/db_test.go +++ b/db_test.go @@ -275,7 +275,7 @@ func TestDB_Stats(t *testing.T) { return err }) stats := db.Stats() - assert.Equal(t, 3, stats.TxStats.PageCount) + assert.Equal(t, 2, stats.TxStats.PageCount) }) } @@ -324,13 +324,7 @@ func TestDB_Consistency(t *testing.T) { if p, _ := tx.Page(5); assert.NotNil(t, p) { assert.Equal(t, "leaf", p.Type) // root leaf } - if p, _ := tx.Page(6); assert.NotNil(t, p) { - assert.Equal(t, "leaf", p.Type) - } - if p, _ := tx.Page(7); assert.NotNil(t, p) { - assert.Equal(t, "free", p.Type) - } - p, _ := tx.Page(8) + p, _ := tx.Page(6) assert.Nil(t, p) return nil }) -- cgit v1.2.3