aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-07-10 14:00:32 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-07-10 14:00:32 -0600
commitcc8004c98058ad9a70bd3181cab57b4c72a26cb8 (patch)
tree1b7e4df114c5e1348b5dd34851f00fb7c17024ad
parentAdd freelist cache. (diff)
parentFix test for path errors. (diff)
downloaddedo-cc8004c98058ad9a70bd3181cab57b4c72a26cb8.tar.gz
dedo-cc8004c98058ad9a70bd3181cab57b4c72a26cb8.tar.xz
Merge branch 'master' of https://github.com/boltdb/bolt into free-cache
-rw-r--r--README.md6
-rw-r--r--db.go2
-rw-r--r--db_test.go5
3 files changed, 10 insertions, 3 deletions
diff --git a/README.md b/README.md
index bf45319..18dcf25 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,12 @@ Since Bolt is meant to be used as such a low-level piece of functionality, simpl
> — [Tobias Lütke](https://twitter.com/tobi)
+## Resources
+
+For more information on getting started with Bolt, check out the following articles:
+
+* [Intro to BoltDB: Painless Performant Persistence](http://blog.natefinch.com/2014/07/intro-to-boltdb-painless-performant.html) by [Nate Finch](https://github.com/natefinch).
+
## Project Status
Bolt is functionally complete and has nearly full unit test coverage. The library test suite also includes randomized black box testing to ensure database consistency and thread safety. Bolt is currently in use in a few projects, however, it is still at a beta stage so please use with caution and report any bugs found.
diff --git a/db.go b/db.go
index 4d7ec12..b839e23 100644
--- a/db.go
+++ b/db.go
@@ -212,7 +212,7 @@ func (db *DB) munmap() error {
// mmapSize determines the appropriate size for the mmap given the current size
// of the database. The minimum size is 4MB and doubles until it reaches 1GB.
func (db *DB) mmapSize(size int) int {
- if size < minMmapSize {
+ if size <= minMmapSize {
return minMmapSize
} else if size < maxMmapStep {
size *= 2
diff --git a/db_test.go b/db_test.go
index 74ffcb9..9bd1ac1 100644
--- a/db_test.go
+++ b/db_test.go
@@ -21,7 +21,7 @@ var statsFlag = flag.Bool("stats", false, "show performance stats")
// Ensure that opening a database with a bad path returns an error.
func TestOpen_BadPath(t *testing.T) {
- db, err := Open("/../bad-path", 0666, nil)
+ db, err := Open("", 0666, nil)
assert.Error(t, err)
assert.Nil(t, db)
}
@@ -297,7 +297,8 @@ func TestDB_mmapSize(t *testing.T) {
assert.Equal(t, db.mmapSize(0), minMmapSize)
assert.Equal(t, db.mmapSize(16384), minMmapSize)
assert.Equal(t, db.mmapSize(minMmapSize-1), minMmapSize)
- assert.Equal(t, db.mmapSize(minMmapSize), minMmapSize*2)
+ assert.Equal(t, db.mmapSize(minMmapSize), minMmapSize)
+ assert.Equal(t, db.mmapSize(minMmapSize+1), (minMmapSize*2)+4096)
assert.Equal(t, db.mmapSize(10000000), 20000768)
assert.Equal(t, db.mmapSize((1<<30)-1), 2147483648)
assert.Equal(t, db.mmapSize(1<<30), 1<<31)