IndexKey generates a index key with the given attribute and term. The structure of an index 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 By
(attr, term string)
| 256 | // next eight bytes (optional): if the key corresponds to a split list, the startUid of |
| 257 | // the split stored in this key. |
| 258 | func IndexKey(attr, term string) []byte { |
| 259 | extra := 1 + len(term) // ByteIndex + term |
| 260 | buf, prefixLen := generateKey(DefaultPrefix, attr, extra) |
| 261 | |
| 262 | rest := buf[prefixLen:] |
| 263 | rest[0] = ByteIndex |
| 264 | |
| 265 | rest = rest[1:] |
| 266 | AssertTrue(len(rest) == len(term)) |
| 267 | AssertTrue(len(term) == copy(rest, term)) |
| 268 | return buf |
| 269 | } |
| 270 | |
| 271 | // CountKey generates a count key with the given attribute and uid. |
| 272 | // The structure of a count key is as follows: |