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() }
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() }
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 }