Browse Source

Fix tests; Support 'leveldb' for legacy

pull/1842/head
Jae Kwon 8 years ago
parent
commit
5e2a1d3e30
5 changed files with 12 additions and 7 deletions
  1. +4
    -2
      c_level_db.go
  2. +1
    -1
      c_level_db_test.go
  3. +2
    -1
      db.go
  4. +4
    -2
      go_level_db.go
  5. +1
    -1
      go_level_db_test.go

+ 4
- 2
c_level_db.go View File

@ -12,9 +12,11 @@ import (
) )
func init() { func init() {
registerDBCreator(CLevelDBBackendStr, func(name string, dir string) (DB, error) {
dbCreator := func(name string, dir string) (DB, error) {
return NewCLevelDB(name, dir) return NewCLevelDB(name, dir)
}, false)
}
registerDBCreator(LevelDBBackendStr, dbCreator, true)
registerDBCreator(CLevelDBBackendStr, dbCreator, false)
} }
type CLevelDB struct { type CLevelDB struct {


+ 1
- 1
c_level_db_test.go View File

@ -18,7 +18,7 @@ func BenchmarkRandomReadsWrites2(b *testing.B) {
for i := 0; i < int(numItems); i++ { for i := 0; i < int(numItems); i++ {
internal[int64(i)] = int64(0) internal[int64(i)] = int64(0)
} }
db, err := NewGoLevelDB(Fmt("test_%x", RandStr(12)))
db, err := NewGoLevelDB(Fmt("test_%x", RandStr(12)), "")
if err != nil { if err != nil {
b.Fatal(err.Error()) b.Fatal(err.Error())
return return


+ 2
- 1
db.go View File

@ -24,6 +24,7 @@ type Batch interface {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const ( const (
LevelDBBackendStr = "leveldb" // legacy, defaults to goleveldb.
CLevelDBBackendStr = "goleveldb" CLevelDBBackendStr = "goleveldb"
GoLevelDBBackendStr = "cleveldb" GoLevelDBBackendStr = "cleveldb"
MemDBBackendStr = "memdb" MemDBBackendStr = "memdb"
@ -31,7 +32,7 @@ const (
type dbCreator func(name string, dir string) (DB, error) type dbCreator func(name string, dir string) (DB, error)
var backends map[string]dbCreator
var backends = map[string]dbCreator{}
func registerDBCreator(backend string, creator dbCreator, force bool) { func registerDBCreator(backend string, creator dbCreator, force bool) {
_, ok := backends[backend] _, ok := backends[backend]


+ 4
- 2
go_level_db.go View File

@ -12,9 +12,11 @@ import (
) )
func init() { func init() {
registerDBCreator(GoLevelDBBackendStr, func(name string, dir string) (DB, error) {
dbCreator := func(name string, dir string) (DB, error) {
return NewGoLevelDB(name, dir) return NewGoLevelDB(name, dir)
}, false)
}
registerDBCreator(LevelDBBackendStr, dbCreator, false)
registerDBCreator(GoLevelDBBackendStr, dbCreator, false)
} }
type GoLevelDB struct { type GoLevelDB struct {


+ 1
- 1
go_level_db_test.go View File

@ -17,7 +17,7 @@ func BenchmarkRandomReadsWrites(b *testing.B) {
for i := 0; i < int(numItems); i++ { for i := 0; i < int(numItems); i++ {
internal[int64(i)] = int64(0) internal[int64(i)] = int64(0)
} }
db, err := NewCLevelDB(Fmt("test_%x", RandStr(12)))
db, err := NewCLevelDB(Fmt("test_%x", RandStr(12)), "")
if err != nil { if err != nil {
b.Fatal(err.Error()) b.Fatal(err.Error())
return return


Loading…
Cancel
Save