use szferi gomdb

This commit is contained in:
siddontang 2014-08-04 08:48:06 +08:00
parent 9a241194fd
commit cdbb351ab8
3 changed files with 13 additions and 13 deletions

View File

@ -8,6 +8,6 @@ go get github.com/siddontang/copier
go get github.com/siddontang/goleveldb/leveldb go get github.com/siddontang/goleveldb/leveldb
go get -d github.com/siddontang/gomdb go get github.com/szferi/gomdb
go get github.com/boltdb/bolt go get github.com/boltdb/bolt

View File

@ -1,8 +1,8 @@
package mdb package mdb
import ( import (
mdb "github.com/siddontang/gomdb"
"github.com/siddontang/ledisdb/store/driver" "github.com/siddontang/ledisdb/store/driver"
mdb "github.com/szferi/gomdb"
"os" "os"
) )
@ -20,7 +20,7 @@ type MDB struct {
func Open(c *Config) (MDB, error) { func Open(c *Config) (MDB, error) {
path := c.Path path := c.Path
if c.MapSize == 0 { if c.MapSize == 0 {
c.MapSize = 1024 * 1024 * 1024 c.MapSize = 500 * 1024 * 1024
} }
env, err := mdb.NewEnv() env, err := mdb.NewEnv()
@ -90,7 +90,7 @@ func (db MDB) BatchPut(writes []driver.Write) error {
for _, w := range writes { for _, w := range writes {
if w.Value == nil { if w.Value == nil {
itr.key, itr.value, itr.err = itr.c.Get(w.Key, mdb.SET) itr.key, itr.value, itr.err = itr.c.Get(w.Key, nil, mdb.SET)
if itr.err == nil { if itr.err == nil {
itr.err = itr.c.Del(0) itr.err = itr.c.Del(0)
} }
@ -125,7 +125,7 @@ func (db MDB) Delete(key []byte) error {
itr := db.iterator(false) itr := db.iterator(false)
defer itr.Close() defer itr.Close()
itr.key, itr.value, itr.err = itr.c.Get(key, mdb.SET) itr.key, itr.value, itr.err = itr.c.Get(key, nil, mdb.SET)
if itr.err == nil { if itr.err == nil {
itr.err = itr.c.Del(0) itr.err = itr.c.Del(0)
} }
@ -161,31 +161,31 @@ func (itr *MDBIterator) Error() error {
} }
func (itr *MDBIterator) getCurrent() { func (itr *MDBIterator) getCurrent() {
itr.key, itr.value, itr.err = itr.c.Get(nil, mdb.GET_CURRENT) itr.key, itr.value, itr.err = itr.c.Get(nil, nil, mdb.GET_CURRENT)
itr.setState() itr.setState()
} }
func (itr *MDBIterator) Seek(key []byte) { func (itr *MDBIterator) Seek(key []byte) {
itr.key, itr.value, itr.err = itr.c.Get(key, mdb.SET_RANGE) itr.key, itr.value, itr.err = itr.c.Get(key, nil, mdb.SET_RANGE)
itr.setState() itr.setState()
} }
func (itr *MDBIterator) Next() { func (itr *MDBIterator) Next() {
itr.key, itr.value, itr.err = itr.c.Get(nil, mdb.NEXT) itr.key, itr.value, itr.err = itr.c.Get(nil, nil, mdb.NEXT)
itr.setState() itr.setState()
} }
func (itr *MDBIterator) Prev() { func (itr *MDBIterator) Prev() {
itr.key, itr.value, itr.err = itr.c.Get(nil, mdb.PREV) itr.key, itr.value, itr.err = itr.c.Get(nil, nil, mdb.PREV)
itr.setState() itr.setState()
} }
func (itr *MDBIterator) First() { func (itr *MDBIterator) First() {
itr.key, itr.value, itr.err = itr.c.Get(nil, mdb.FIRST) itr.key, itr.value, itr.err = itr.c.Get(nil, nil, mdb.FIRST)
itr.setState() itr.setState()
} }
func (itr *MDBIterator) Last() { func (itr *MDBIterator) Last() {
itr.key, itr.value, itr.err = itr.c.Get(nil, mdb.LAST) itr.key, itr.value, itr.err = itr.c.Get(nil, nil, mdb.LAST)
itr.setState() itr.setState()
} }

View File

@ -1,8 +1,8 @@
package mdb package mdb
import ( import (
mdb "github.com/siddontang/gomdb"
"github.com/siddontang/ledisdb/store/driver" "github.com/siddontang/ledisdb/store/driver"
mdb "github.com/szferi/gomdb"
) )
type Tx struct { type Tx struct {
@ -53,7 +53,7 @@ func (t *Tx) BatchPut(writes []driver.Write) error {
for _, w := range writes { for _, w := range writes {
if w.Value == nil { if w.Value == nil {
itr.key, itr.value, itr.err = itr.c.Get(w.Key, mdb.SET) itr.key, itr.value, itr.err = itr.c.Get(w.Key, nil, mdb.SET)
if itr.err == nil { if itr.err == nil {
itr.err = itr.c.Del(0) itr.err = itr.c.Del(0)
} }