DataKey generates a data key with the given attribute and UID. The structure of a data key is as follows: byte 0: key type prefix (set to DefaultPrefix or ByteSplit if part of a multi-part list) byte 1-2: length of attr next len(attr) bytes: value of attr next byte: data type prefix (set to ByteDat
(attr string, uid uint64)
| 199 | // next eight bytes (optional): if the key corresponds to a split list, the startUid of |
| 200 | // the split stored in this key and the first byte will be sets to ByteSplit. |
| 201 | func DataKey(attr string, uid uint64) []byte { |
| 202 | extra := 1 + 8 // ByteData + UID |
| 203 | buf, prefixLen := generateKey(DefaultPrefix, attr, extra) |
| 204 | |
| 205 | rest := buf[prefixLen:] |
| 206 | rest[0] = ByteData |
| 207 | |
| 208 | rest = rest[1:] |
| 209 | binary.BigEndian.PutUint64(rest, uid) |
| 210 | return buf |
| 211 | } |
| 212 | |
| 213 | // ReverseKey generates a reverse key with the given attribute and UID. |
| 214 | // The structure of a reverse key is as follows: |