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 {
|
type LevelDBBackend struct {
|
||||||
cache *leveldb.Cache
|
cache *leveldb.Cache
|
||||||
db *leveldb.DB
|
db *leveldb.DB
|
||||||
encoder common.KeyTranscoder
|
interleaved bool
|
||||||
decoder common.KeyTranscoder
|
encoder common.KeyTranscoder
|
||||||
mutex sync.RWMutex
|
decoder common.KeyTranscoder
|
||||||
|
mutex sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
type LevelDBSession struct {
|
type LevelDBSession struct {
|
||||||
@ -28,9 +29,9 @@ type LevelDBSession struct {
|
|||||||
|
|
||||||
func NewLeveDBBackend(
|
func NewLeveDBBackend(
|
||||||
path string,
|
path string,
|
||||||
encoder common.KeyTranscoder,
|
interleaved bool,
|
||||||
decoder common.KeyTranscoder,
|
|
||||||
cacheSize int) (ldb *LevelDBBackend, err error) {
|
cacheSize int) (ldb *LevelDBBackend, err error) {
|
||||||
|
|
||||||
opts := leveldb.NewOptions()
|
opts := leveldb.NewOptions()
|
||||||
|
|
||||||
var cache *leveldb.Cache
|
var cache *leveldb.Cache
|
||||||
@ -48,11 +49,25 @@ func NewLeveDBBackend(
|
|||||||
}
|
}
|
||||||
return
|
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{
|
ldb = &LevelDBBackend{
|
||||||
cache: cache,
|
cache: cache,
|
||||||
db: db,
|
db: db,
|
||||||
encoder: encoder,
|
interleaved: interleaved,
|
||||||
decoder: decoder}
|
encoder: encoder,
|
||||||
|
decoder: decoder}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
main.go
16
main.go
@ -13,8 +13,6 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/s_l_teichmann/mtredisalize/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -48,9 +46,7 @@ func main() {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
args := flag.Args()
|
if flag.NArg() < 1 {
|
||||||
|
|
||||||
if len(args) < 1 {
|
|
||||||
log.Fatal("Missing path to world")
|
log.Fatal("Missing path to world")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,16 +60,14 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path := flag.Arg(0)
|
||||||
|
|
||||||
if driver == "sqlite" {
|
if driver == "sqlite" {
|
||||||
if backend, err = NewSqliteBackend(args[0], interleaved); err != nil {
|
if backend, err = NewSqliteBackend(path, interleaved); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if backend, err = NewLeveDBBackend(
|
if backend, err = NewLeveDBBackend(path, interleaved, cacheSize); err != nil {
|
||||||
args[0],
|
|
||||||
common.IdentityTranscoder,
|
|
||||||
common.IdentityTranscoder,
|
|
||||||
cacheSize); err != nil {
|
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user