diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-07-24 11:25:57 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-07-24 11:25:57 -0600 |
commit | d021755f077c19224e32f5d88a4f35a4076e00d6 (patch) | |
tree | 8082796f45131be814281ffd2b3acefab92d2656 /bucket.go | |
parent | Merge pull request #228 from benbjohnson/fix-large-append (diff) | |
parent | Add FillPercent documentation. (diff) | |
download | dedo-d021755f077c19224e32f5d88a4f35a4076e00d6.tar.gz dedo-d021755f077c19224e32f5d88a4f35a4076e00d6.tar.xz |
Merge pull request #229 from benbjohnson/bucket-fill-percent
Change fill percent to be per-bucket.
Diffstat (limited to 'bucket.go')
-rw-r--r-- | bucket.go | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -23,6 +23,15 @@ const ( const bucketHeaderSize = int(unsafe.Sizeof(bucket{})) +const ( + minFillPercent = 0.1 + maxFillPercent = 1.0 +) + +// DefaultFillPercent is the percentage that split pages are filled. +// This value can be changed by setting Bucket.FillPercent. +const DefaultFillPercent = 0.5 + // Bucket represents a collection of key/value pairs inside the database. type Bucket struct { *bucket @@ -31,6 +40,13 @@ type Bucket struct { page *page // inline page reference rootNode *node // materialized node for the root page. nodes map[pgid]*node // node cache + + // Sets the threshold for filling nodes when they split. By default, + // the bucket will fill to 50% but it can be useful to increase this + // amount if you know that your write workloads are mostly append-only. + // + // This is non-persisted across transactions so it must be set in every Tx. + FillPercent float64 } // bucket represents the on-file representation of a bucket. @@ -44,7 +60,7 @@ type bucket struct { // newBucket returns a new bucket associated with a transaction. func newBucket(tx *Tx) Bucket { - var b = Bucket{tx: tx} + var b = Bucket{tx: tx, FillPercent: DefaultFillPercent} if tx.writable { b.buckets = make(map[string]*Bucket) b.nodes = make(map[pgid]*node) @@ -155,7 +171,11 @@ func (b *Bucket) CreateBucket(key []byte) (*Bucket, error) { } // Create empty, inline bucket. - var bucket = Bucket{bucket: &bucket{}, rootNode: &node{isLeaf: true}} + var bucket = Bucket{ + bucket: &bucket{}, + rootNode: &node{isLeaf: true}, + FillPercent: DefaultFillPercent, + } var value = bucket.write() // Insert into node. |