aboutsummaryrefslogtreecommitdiff
path: root/bucket_test.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-05-05 10:27:02 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-05-05 16:39:55 -0600
commit55e71b090259eb775c1bb74a2c3ec23bdfba8db5 (patch)
treea955d1a2bf1d7174e5255a8d68a8e57a103a8819 /bucket_test.go
parentMerge pull request #153 from benbjohnson/consolidate (diff)
downloaddedo-55e71b090259eb775c1bb74a2c3ec23bdfba8db5.tar.gz
dedo-55e71b090259eb775c1bb74a2c3ec23bdfba8db5.tar.xz
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.
Diffstat (limited to 'bucket_test.go')
-rw-r--r--bucket_test.go20
1 files changed, 10 insertions, 10 deletions
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
})