CountKey generates a count key with the given attribute and uid. The structure of a count key is as follows: byte 0: key type prefix (set to DefaultPrefix) byte 1-2: length of attr next len(attr) bytes: value of attr next byte: data type prefix (set to ByteCount or ByteCountRev) next four bytes: va
(attr string, count uint32, reverse bool)
| 277 | // next byte: data type prefix (set to ByteCount or ByteCountRev) |
| 278 | // next four bytes: value of count. |
| 279 | func CountKey(attr string, count uint32, reverse bool) []byte { |
| 280 | extra := 1 + 4 // ByteCount + Count |
| 281 | buf, prefixLen := generateKey(DefaultPrefix, attr, extra) |
| 282 | |
| 283 | rest := buf[prefixLen:] |
| 284 | if reverse { |
| 285 | rest[0] = ByteCountRev |
| 286 | } else { |
| 287 | rest[0] = ByteCount |
| 288 | } |
| 289 | |
| 290 | rest = rest[1:] |
| 291 | binary.BigEndian.PutUint32(rest, count) |
| 292 | return buf |
| 293 | } |
| 294 | |
| 295 | // ParsedKey represents a key that has been parsed into its multiple attributes. |
| 296 | type ParsedKey struct { |
searching dependent graphs…