示例#1
0
文件: row.go 项目: fengshao0907/rpdb
func EncodeDataKeyPrefix(db uint32, key []byte) []byte {
	if len(key) == 0 {
		log.Errorf("encode nil data key")
	}
	w := NewBufWriter(nil)
	encodeRawBytes(w, DataCode, &db, &key)
	return w.Bytes()
}
示例#2
0
文件: row.go 项目: fengshao0907/rpdb
func EncodeMetaKey(db uint32, key []byte) []byte {
	if len(key) == 0 {
		log.Errorf("encode nil meta key")
	}
	tag, slot := HashKeyToSlot(key)
	if len(tag) == len(key) {
		key = nil
	}
	w := NewBufWriter(nil)
	encodeRawBytes(w, MetaCode, &db, &slot, &tag, &key)
	return w.Bytes()
}
示例#3
0
文件: row.go 项目: fengshao0907/rpdb
func DecodeMetaKey(p []byte) (db uint32, key []byte, err error) {
	var tag []byte
	var slot uint32
	r := NewBufReader(p)
	err = decodeRawBytes(r, err, MetaCode, &db, &slot, &tag, &key)
	err = decodeRawBytes(r, err)
	if err != nil {
		return
	}
	if len(key) == 0 {
		key = tag
	}
	if len(key) == 0 {
		log.Errorf("decode nil meta key")
	}
	return
}