mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-23 16:50:18 +01:00
Enabled interleaving in LevelDB backend.
This commit is contained in:
parent
a0bdf95f95
commit
35130a5202
37
leveldb.go
37
leveldb.go
@ -14,11 +14,12 @@ import (
|
||||
)
|
||||
|
||||
type LevelDBBackend struct {
|
||||
cache *leveldb.Cache
|
||||
db *leveldb.DB
|
||||
encoder common.KeyTranscoder
|
||||
decoder common.KeyTranscoder
|
||||
mutex sync.RWMutex
|
||||
cache *leveldb.Cache
|
||||
db *leveldb.DB
|
||||
interleaved bool
|
||||
encoder common.KeyTranscoder
|
||||
decoder common.KeyTranscoder
|
||||
mutex sync.RWMutex
|
||||
}
|
||||
|
||||
type LevelDBSession struct {
|
||||
@ -28,9 +29,9 @@ type LevelDBSession struct {
|
||||
|
||||
func NewLeveDBBackend(
|
||||
path string,
|
||||
encoder common.KeyTranscoder,
|
||||
decoder common.KeyTranscoder,
|
||||
interleaved bool,
|
||||
cacheSize int) (ldb *LevelDBBackend, err error) {
|
||||
|
||||
opts := leveldb.NewOptions()
|
||||
|
||||
var cache *leveldb.Cache
|
||||
@ -48,11 +49,25 @@ func NewLeveDBBackend(
|
||||
}
|
||||
return
|
||||
}
|
||||
var (
|
||||
encoder common.KeyTranscoder
|
||||
decoder common.KeyTranscoder
|
||||
)
|
||||
|
||||
if interleaved {
|
||||
encoder = common.TranscodeInterleavedToPlain
|
||||
decoder = common.TranscodePlainToInterleaved
|
||||
} else {
|
||||
encoder = common.IdentityTranscoder
|
||||
decoder = common.IdentityTranscoder
|
||||
}
|
||||
|
||||
ldb = &LevelDBBackend{
|
||||
cache: cache,
|
||||
db: db,
|
||||
encoder: encoder,
|
||||
decoder: decoder}
|
||||
cache: cache,
|
||||
db: db,
|
||||
interleaved: interleaved,
|
||||
encoder: encoder,
|
||||
decoder: decoder}
|
||||
return
|
||||
}
|
||||
|
||||
|
16
main.go
16
main.go
@ -13,8 +13,6 @@ import (
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"bitbucket.org/s_l_teichmann/mtredisalize/common"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -48,9 +46,7 @@ func main() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
args := flag.Args()
|
||||
|
||||
if len(args) < 1 {
|
||||
if flag.NArg() < 1 {
|
||||
log.Fatal("Missing path to world")
|
||||
}
|
||||
|
||||
@ -64,16 +60,14 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
path := flag.Arg(0)
|
||||
|
||||
if driver == "sqlite" {
|
||||
if backend, err = NewSqliteBackend(args[0], interleaved); err != nil {
|
||||
if backend, err = NewSqliteBackend(path, interleaved); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
if backend, err = NewLeveDBBackend(
|
||||
args[0],
|
||||
common.IdentityTranscoder,
|
||||
common.IdentityTranscoder,
|
||||
cacheSize); err != nil {
|
||||
if backend, err = NewLeveDBBackend(path, interleaved, cacheSize); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user