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

@ -35,6 +35,7 @@ type LevelDBConfig struct {
type LMDBConfig 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 { type BinLogConfig struct {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,6 +23,8 @@ type MDB struct {
func (s Store) Open(path string, c *config.Config) (driver.IDB, error) { func (s Store) Open(path string, c *config.Config) (driver.IDB, error) {
mapSize := c.LMDB.MapSize mapSize := c.LMDB.MapSize
noSync := c.LMDB.NoSync
if mapSize <= 0 { if mapSize <= 0 {
mapSize = 500 * 1024 * 1024 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 { if err != nil {
return MDB{}, err return MDB{}, err
} }