mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-24 01:00:18 +01:00
Enabled interleaving in LevelDB backend.
This commit is contained in:
parent
a0bdf95f95
commit
35130a5202
19
leveldb.go
19
leveldb.go
@ -16,6 +16,7 @@ import (
|
|||||||
type LevelDBBackend struct {
|
type LevelDBBackend struct {
|
||||||
cache *leveldb.Cache
|
cache *leveldb.Cache
|
||||||
db *leveldb.DB
|
db *leveldb.DB
|
||||||
|
interleaved bool
|
||||||
encoder common.KeyTranscoder
|
encoder common.KeyTranscoder
|
||||||
decoder common.KeyTranscoder
|
decoder common.KeyTranscoder
|
||||||
mutex sync.RWMutex
|
mutex sync.RWMutex
|
||||||
@ -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,9 +49,23 @@ 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,
|
||||||
|
interleaved: interleaved,
|
||||||
encoder: encoder,
|
encoder: encoder,
|
||||||
decoder: decoder}
|
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