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. --- bucket_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'bucket_test.go') diff --git a/bucket_test.go b/bucket_test.go index dc89bcc..8fcf84c 100644 --- a/bucket_test.go +++ b/bucket_test.go @@ -583,18 +583,18 @@ func TestBucket_Stats_Small(t *testing.T) { db.View(func(tx *Tx) error { b := tx.Bucket([]byte("whozawhats")) stats := b.Stats() - assert.Equal(t, stats.BranchPageN, 0) - assert.Equal(t, stats.BranchOverflowN, 0) - assert.Equal(t, stats.LeafPageN, 1) - assert.Equal(t, stats.LeafOverflowN, 0) - assert.Equal(t, stats.KeyN, 1) - assert.Equal(t, stats.Depth, 1) + assert.Equal(t, 0, stats.BranchPageN) + assert.Equal(t, 0, stats.BranchOverflowN) + assert.Equal(t, 1, stats.LeafPageN) + assert.Equal(t, 0, stats.LeafOverflowN) + assert.Equal(t, 1, stats.KeyN) + assert.Equal(t, 1, stats.Depth) if os.Getpagesize() != 4096 { // Incompatible page size - assert.Equal(t, stats.BranchInuse, 0) - assert.Equal(t, stats.BranchAlloc, 0) - assert.Equal(t, stats.LeafInuse, 38) - assert.Equal(t, stats.LeafAlloc, 4096) + assert.Equal(t, 0, stats.BranchInuse) + assert.Equal(t, 0, stats.BranchAlloc) + assert.Equal(t, 38, stats.LeafInuse) + assert.Equal(t, 4096, stats.LeafAlloc) } return nil }) -- cgit v1.2.3