mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-04 11:30:14 -05:00
implementing codec
This commit is contained in:
@@ -599,10 +599,6 @@ func compareAddr(l, r hash.Hash) int {
|
||||
return l.Compare(r)
|
||||
}
|
||||
|
||||
func compareZAddr(l, r [zAddrSize]byte) int {
|
||||
return bytes.Compare(l[:], r[:])
|
||||
}
|
||||
|
||||
func writeRaw(buf, val []byte) {
|
||||
expectSize(buf, ByteSize(len(val)))
|
||||
copy(buf, val)
|
||||
@@ -629,8 +625,17 @@ func stringFromBytes(b []byte) string {
|
||||
return *(*string)(unsafe.Pointer(&b))
|
||||
}
|
||||
|
||||
func compareZAddr(l, r [zAddrSize]byte) int {
|
||||
return bytes.Compare(l[:], r[:])
|
||||
}
|
||||
|
||||
func readZAddr(val []byte) (res [zAddrSize]byte) {
|
||||
expectSize(val, zAddrSize)
|
||||
copy(res[:zAddrSize], val[:zAddrSize])
|
||||
return
|
||||
}
|
||||
|
||||
func writeZAddr(buf []byte, v [zAddrSize]byte) {
|
||||
expectSize(buf, zAddrSize)
|
||||
copy(buf, v[:zAddrSize])
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
package val
|
||||
|
||||
import (
|
||||
"github.com/dolthub/go-mysql-server/sql/types"
|
||||
"math"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -243,6 +242,10 @@ func TestCompare(t *testing.T) {
|
||||
},
|
||||
// z-address
|
||||
{
|
||||
typ: Type{Enc: StringEnc},
|
||||
l: encZAddr([zAddrSize]byte{}),
|
||||
r: encZAddr([zAddrSize]byte{}),
|
||||
cmp: 0,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -301,9 +304,10 @@ func encStr(s string) []byte {
|
||||
return buf
|
||||
}
|
||||
|
||||
func encZAddr(g types.GeometryValue) []byte {
|
||||
buf := ZAddr(g)
|
||||
return buf[:]
|
||||
func encZAddr(z [zAddrSize]byte) []byte {
|
||||
buf := make([]byte, zAddrSize)
|
||||
writeZAddr(buf, z)
|
||||
return buf
|
||||
}
|
||||
|
||||
func encYear(y int16) []byte {
|
||||
|
||||
@@ -366,3 +366,12 @@ func (tb *TupleBuilder) ensureCapacity(sz ByteSize) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PutZAddr writes a bounding box to the ith field of the Tuple being built.
|
||||
func (tb *TupleBuilder) PutZAddr(i int, v [zAddrSize]byte) {
|
||||
tb.Desc.expectEncoding(i, ZAddrEnc)
|
||||
tb.ensureCapacity(zAddrSize)
|
||||
tb.fields[i] = tb.buf[tb.pos : tb.pos+zAddrSize]
|
||||
writeZAddr(tb.fields[i], v)
|
||||
tb.pos += zAddrSize
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user