ReverseKey generates a reverse key with the given attribute and UID. The structure of a reverse 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 t
(attr string, uid uint64)
| 221 | // next eight bytes (optional): if the key corresponds to a split list, |
| 222 | // the startUid of the split stored in this key. |
| 223 | func ReverseKey(attr string, uid uint64) []byte { |
| 224 | extra := 1 + 8 // ByteReverse + UID |
| 225 | buf, prefixLen := generateKey(DefaultPrefix, attr, extra) |
| 226 | |
| 227 | rest := buf[prefixLen:] |
| 228 | rest[0] = ByteReverse |
| 229 | |
| 230 | rest = rest[1:] |
| 231 | binary.BigEndian.PutUint64(rest, uid) |
| 232 | return buf |
| 233 | } |
| 234 | |
| 235 | func IndexKeyAfterAllTerms(attr string) []byte { |
| 236 | // Use a term with 0xFF to ensure lexicographically after any real term |