Added transcoders for interleaved LevelDB backend.

This commit is contained in:
Sascha L. Teichmann 2014-08-23 13:49:45 +02:00
parent 712708f87c
commit 954cc1928b

View File

@ -161,6 +161,22 @@ func IdentityTranscoder(key []byte) ([]byte, error) {
return key, nil
}
func TranscodePlainToInterleaved(key []byte) ([]byte, error) {
if pos, err := DecodeStringFromBytesToInterleaved(key); err != nil {
return nil, err
} else {
return EncodeToBigEndian(pos)
}
}
func TranscodeInterleavedToPlain(key []byte) ([]byte, error) {
if pos, err := DecodeFromBigEndian(key); err != nil {
return nil, err
} else {
return EncodeStringToBytes(TransformInterleavedToPlain(pos))
}
}
func SelectKeySplitter(interleaved bool) KeySplitter {
if interleaved {
return InterleavedToCoord