From 83c160eb9094202977faa4836d6d82d68b6e5e9f Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Thu, 21 Aug 2014 22:19:42 +0200 Subject: [PATCH] Added encoder/decoder useful in interleved SQLite backend. --- common/coords.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/common/coords.go b/common/coords.go index ed162aa..2ca3189 100644 --- a/common/coords.go +++ b/common/coords.go @@ -140,10 +140,22 @@ func TransformPlainToInterleaved(pos int64) int64 { return CoordToInterleaved(PlainToCoord(pos)) } -func TransformInterleavedPlain(pos int64) int64 { +func TransformInterleavedToPlain(pos int64) int64 { 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 { if interleaved { return InterleavedToCoord