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.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'db.go') diff --git a/db.go b/db.go index 9754f21..d96a161 100644 --- a/db.go +++ b/db.go @@ -563,6 +563,11 @@ func (db *DB) Check() error { } func (db *DB) checkBucket(b *Bucket, reachable map[pgid]*page, errors *ErrorList) { + // Ignore inline buckets. + if b.root == 0 { + return + } + // Check every page used by this bucket. b.tx.forEachPage(b.root, 0, func(p *page, _ int) { // Ensure each page is only referenced once. @@ -576,7 +581,6 @@ func (db *DB) checkBucket(b *Bucket, reachable map[pgid]*page, errors *ErrorList // Retrieve page info. info, err := b.tx.Page(int(p.id)) - // warnf("[page] %d + %d (%s)", p.id, p.overflow, info.Type) if err != nil { *errors = append(*errors, err) } else if info == nil { -- cgit v1.2.3