mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-17 15:48:17 +01:00
Moved special code for interleaver out of common.
This commit is contained in:
parent
954cc1928b
commit
8cd23d257f
@ -176,31 +176,3 @@ func TranscodeInterleavedToPlain(key []byte) ([]byte, error) {
|
||||
return EncodeStringToBytes(TransformInterleavedToPlain(pos))
|
||||
}
|
||||
}
|
||||
|
||||
func SelectKeySplitter(interleaved bool) KeySplitter {
|
||||
if interleaved {
|
||||
return InterleavedToCoord
|
||||
}
|
||||
return PlainToCoord
|
||||
}
|
||||
|
||||
func SelectKeyJoiner(interleaved bool) KeyJoiner {
|
||||
if interleaved {
|
||||
return CoordToInterleaved
|
||||
}
|
||||
return CoordToPlain
|
||||
}
|
||||
|
||||
func SelectKeyDecoder(interleaved bool) KeyDecoder {
|
||||
if interleaved {
|
||||
return DecodeFromBigEndian
|
||||
}
|
||||
return DecodeStringFromBytes
|
||||
}
|
||||
|
||||
func SelectKeyEncoder(interleaved bool) KeyEncoder {
|
||||
if interleaved {
|
||||
return EncodeToBigEndian
|
||||
}
|
||||
return EncodeStringToBytes
|
||||
}
|
||||
|
@ -20,6 +20,34 @@ func usage() {
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
func selectKeySplitter(interleaved bool) common.KeySplitter {
|
||||
if interleaved {
|
||||
return common.InterleavedToCoord
|
||||
}
|
||||
return common.PlainToCoord
|
||||
}
|
||||
|
||||
func selectKeyJoiner(interleaved bool) common.KeyJoiner {
|
||||
if interleaved {
|
||||
return common.CoordToInterleaved
|
||||
}
|
||||
return common.CoordToPlain
|
||||
}
|
||||
|
||||
func selectKeyDecoder(interleaved bool) common.KeyDecoder {
|
||||
if interleaved {
|
||||
return common.DecodeFromBigEndian
|
||||
}
|
||||
return common.DecodeStringFromBytes
|
||||
}
|
||||
|
||||
func selectKeyEncoder(interleaved bool) common.KeyEncoder {
|
||||
if interleaved {
|
||||
return common.EncodeToBigEndian
|
||||
}
|
||||
return common.EncodeStringToBytes
|
||||
}
|
||||
|
||||
func copyProducerToConsumer(producer BlockProducer, consumer BlockConsumer) (err error) {
|
||||
var block Block
|
||||
i := 0
|
||||
@ -86,14 +114,14 @@ func main() {
|
||||
if srcBackend == "sqlite" {
|
||||
if producer, err = NewSQLiteBlockProducer(
|
||||
flag.Arg(0),
|
||||
common.SelectKeySplitter(srcInterleaved)); err != nil {
|
||||
selectKeySplitter(srcInterleaved)); err != nil {
|
||||
log.Fatalf("Cannot open '%s': %s", flag.Arg(0), err)
|
||||
}
|
||||
} else { // LevelDB
|
||||
if producer, err = NewLevelDBBlockProducer(
|
||||
flag.Arg(0),
|
||||
common.SelectKeySplitter(srcInterleaved),
|
||||
common.SelectKeyDecoder(srcInterleaved)); err != nil {
|
||||
selectKeySplitter(srcInterleaved),
|
||||
selectKeyDecoder(srcInterleaved)); err != nil {
|
||||
log.Fatalf("Cannot open '%s': %s", flag.Arg(0), err)
|
||||
}
|
||||
}
|
||||
@ -101,14 +129,15 @@ func main() {
|
||||
|
||||
if dstBackend == "sqlite" {
|
||||
if consumer, err = NewSQLiteBlockConsumer(
|
||||
flag.Arg(1), common.SelectKeyJoiner(dstInterleaved)); err != nil {
|
||||
flag.Arg(1),
|
||||
selectKeyJoiner(dstInterleaved)); err != nil {
|
||||
log.Fatalf("Cannot open '%s': %s", flag.Arg(1), err)
|
||||
}
|
||||
} else { // LevelDB
|
||||
if consumer, err = NewLevelDBBlockConsumer(
|
||||
flag.Arg(1),
|
||||
common.SelectKeyJoiner(dstInterleaved),
|
||||
common.SelectKeyEncoder(dstInterleaved)); err != nil {
|
||||
selectKeyJoiner(dstInterleaved),
|
||||
selectKeyEncoder(dstInterleaved)); err != nil {
|
||||
log.Fatalf("Cannot open '%s': %s", flag.Arg(1), err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user