Merge branch 'develop' into scan-feature

This commit is contained in:
wenyekui 2014-08-15 11:45:51 +08:00
commit 23e97f3878
8 changed files with 19 additions and 3 deletions

View File

@ -34,7 +34,8 @@ type LevelDBConfig struct {
}
type LMDBConfig struct {
MapSize int `toml:"map_size" json:"map_size"`
MapSize int `toml:"map_size" json:"map_size"`
NoSync bool `toml:"nosync" json:"nosync"`
}
type BinLogConfig struct {

View File

@ -14,7 +14,8 @@
},
"lmdb" : {
"map_size" : 524288000
"map_size" : 524288000,
"nosync" : true
},
"access_log" : ""

View File

@ -34,6 +34,7 @@ max_open_files = 1024
[lmdb]
map_size = 524288000
nosync = true
[binlog]
max_file_size = 0

View File

@ -18,6 +18,7 @@ func TestConfig(t *testing.T) {
dstCfg.LevelDB.CacheSize = 524288000
dstCfg.LevelDB.MaxOpenFiles = 1024
dstCfg.LMDB.MapSize = 524288000
dstCfg.LMDB.NoSync = true
cfg, err := NewConfigWithFile("./config.toml")
if err != nil {

View File

@ -36,6 +36,7 @@ max_open_files = 1024
[lmdb]
map_size = 524288000
nosync = true
[binlog]
# Set either size or num to 0 to disable binlog

View File

@ -1,3 +1,5 @@
// +build hyperleveldb
package store
import (

View File

@ -1,3 +1,5 @@
// +build hyperleveldb
package store
import (

View File

@ -23,6 +23,8 @@ type MDB struct {
func (s Store) Open(path string, c *config.Config) (driver.IDB, error) {
mapSize := c.LMDB.MapSize
noSync := c.LMDB.NoSync
if mapSize <= 0 {
mapSize = 500 * 1024 * 1024
}
@ -48,7 +50,12 @@ func (s Store) Open(path string, c *config.Config) (driver.IDB, error) {
}
}
err = env.Open(path, mdb.NOSYNC|mdb.NOMETASYNC|mdb.WRITEMAP|mdb.MAPASYNC|mdb.CREATE, 0755)
var flags uint = mdb.CREATE
if noSync {
flags |= mdb.NOSYNC | mdb.NOMETASYNC | mdb.WRITEMAP | mdb.MAPASYNC
}
err = env.Open(path, flags, 0755)
if err != nil {
return MDB{}, err
}