MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / CountKey

Function CountKey

x/keys.go:279–293  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

277// next byte: data type prefix (set to ByteCount or ByteCountRev)
278// next four bytes: value of count.
279func 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.
296type ParsedKey struct {

Callers 11

toListMethod · 0.92
TestMultipleTxnListCountFunction · 0.92
TestScalarPredicateCountFunction · 0.92
evaluateMethod · 0.92
RootNsCountKeyFunction · 0.92
addCountMutationMethod · 0.92
FromBackupKeyFunction · 0.85
TestCountKeyFunction · 0.85
TestCountKeyWithStartUidFunction · 0.85
TestBadStartUidFunction · 0.85

Calls 1

generateKeyFunction · 0.70

Tested by 6

TestMultipleTxnListCountFunction · 0.74
TestScalarPredicateCountFunction · 0.74
TestCountKeyFunction · 0.68
TestCountKeyWithStartUidFunction · 0.68
TestBadStartUidFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…