aboutsummaryrefslogtreecommitdiff
path: root/node.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-05-15 14:04:57 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-05-15 14:04:57 -0600
commita1873dd6f65654d463455ae2d381c35c12f71f51 (patch)
tree4b5b5cff16a08bbeebe0e7c2909eaf003cf90ec2 /node.go
parentMerge pull request #165 from benbjohnson/strict-mode (diff)
downloaddedo-a1873dd6f65654d463455ae2d381c35c12f71f51.tar.gz
dedo-a1873dd6f65654d463455ae2d381c35c12f71f51.tar.xz
Add option to adjust fill percentage.
This commit adds the ability to adjust the fill percentage for splitting nodes. This works by setting a threshold that is a percentage of a total page size. When that threshold is crossed during a split then a new node is created. This is primarily beneficial for append-only workloads. Fixes #163.
Diffstat (limited to '')
-rw-r--r--node.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/node.go b/node.go
index 5ad581e..e345d7f 100644
--- a/node.go
+++ b/node.go
@@ -215,8 +215,14 @@ func (n *node) split(pageSize int) []*node {
return nodes
}
- // Set fill threshold to 50%.
- threshold := pageSize / 2
+ // Determine the threshold before starting a new node.
+ var fillPercent = n.bucket.tx.db.FillPercent
+ if fillPercent < minFillPercent {
+ fillPercent = minFillPercent
+ } else if fillPercent > maxFillPercent {
+ fillPercent = maxFillPercent
+ }
+ threshold := int(float64(pageSize) * fillPercent)
// Group into smaller pages and target a given fill size.
size := pageHeaderSize