Added encoder/decoder useful in interleved SQLite backend.

This commit is contained in:
Sascha L. Teichmann 2014-08-21 22:19:42 +02:00
parent b393712801
commit 83c160eb90

View File

@ -140,10 +140,22 @@ func TransformPlainToInterleaved(pos int64) int64 {
return CoordToInterleaved(PlainToCoord(pos)) return CoordToInterleaved(PlainToCoord(pos))
} }
func TransformInterleavedPlain(pos int64) int64 { func TransformInterleavedToPlain(pos int64) int64 {
return CoordToPlain(InterleavedToCoord(pos)) return CoordToPlain(InterleavedToCoord(pos))
} }
func DecodeStringFromBytesToInterleaved(key []byte) (v int64, err error) {
if v, err = DecodeStringFromBytes(key); err != nil {
return
}
v = TransformPlainToInterleaved(v)
return
}
func EncodeStringToBytesFromInterleaved(key int64) ([]byte, error) {
return EncodeStringToBytes(TransformInterleavedToPlain(key))
}
func SelectKeySplitter(interleaved bool) KeySplitter { func SelectKeySplitter(interleaved bool) KeySplitter {
if interleaved { if interleaved {
return InterleavedToCoord return InterleavedToCoord