示例#1
0
// EncodeRecordKey encodes the string value to a byte slice.
func EncodeRecordKey(tablePrefix string, h int64, columnID int64) []byte {
	var (
		buf []byte
		err error
	)

	if columnID == 0 { // Ignore columnID.
		buf, err = kv.EncodeValue(tablePrefix, h)
	} else {
		buf, err = kv.EncodeValue(tablePrefix, h, columnID)
	}
	if err != nil {
		log.Fatal("should never happend")
	}
	return buf
}
示例#2
0
// EncodeValue implements table.Table EncodeValue interface.
func (t *Table) EncodeValue(raw interface{}) ([]byte, error) {
	v, err := t.flatten(raw)
	if err != nil {
		return nil, err
	}
	return kv.EncodeValue(v)
}
示例#3
0
文件: tables.go 项目: winkyao/tidb
func isIndexValsEqual(vals1, vals2 []interface{}) bool {
	byteVals1, _ := kv.EncodeValue(vals1...)
	byteVals2, _ := kv.EncodeValue(vals2...)

	return bytes.Equal(byteVals1, byteVals2)
}