aboutsummaryrefslogtreecommitdiff
path: root/db.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 /db.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 'db.go')
-rw-r--r--db.go6
1 files changed, 5 insertions, 1 deletions
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 {