aboutsummaryrefslogtreecommitdiff
path: root/db.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-05-15 14:25:29 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-05-15 14:25:29 -0600
commitcc6302194b6134806669cbeafcaf799fa0ea040c (patch)
tree7ca8faaae8099222c0c7964eee3e0a95dea5bd51 /db.go
parentMerge pull request #165 from benbjohnson/strict-mode (diff)
parentChange verbiage, fix node test. (diff)
downloaddedo-cc6302194b6134806669cbeafcaf799fa0ea040c.tar.gz
dedo-cc6302194b6134806669cbeafcaf799fa0ea040c.tar.xz
Merge pull request #166 from benbjohnson/fill-percent
Add option to adjust fill percentage.
Diffstat (limited to 'db.go')
-rw-r--r--db.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/db.go b/db.go
index 758c911..c768ce3 100644
--- a/db.go
+++ b/db.go
@@ -24,6 +24,15 @@ const version = 2
// Represents a marker value to indicate that a file is a Bolt DB.
const magic uint32 = 0xED0CDAED
+const (
+ minFillPercent = 0.1
+ maxFillPercent = 1.0
+)
+
+// DefaultFillPercent is the percentage that split pages are filled.
+// This value can be changed by setting DB.FillPercent.
+const DefaultFillPercent = 0.5
+
var (
// ErrDatabaseNotOpen is returned when a DB instance is accessed before it
// is opened or after it is closed.
@@ -54,6 +63,11 @@ type DB struct {
// debugging purposes.
StrictMode bool
+ // Sets the threshold for filling nodes when they split. By default,
+ // the database will fill to 50% but it can be useful to increase this
+ // amount if you know that your write workloads are mostly append-only.
+ FillPercent float64
+
path string
file *os.File
data []byte
@@ -94,7 +108,7 @@ func (db *DB) String() string {
// Open creates and opens a database at the given path.
// If the file does not exist then it will be created automatically.
func Open(path string, mode os.FileMode) (*DB, error) {
- var db = &DB{opened: true}
+ var db = &DB{opened: true, FillPercent: DefaultFillPercent}
// Open data file and separate sync handler for metadata writes.
db.path = path