MCPcopy
hub / github.com/dgraph-io/dgraph / IndexKey

Function IndexKey

x/keys.go:258–269  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

256// next eight bytes (optional): if the key corresponds to a split list, the startUid of
257// the split stored in this key.
258func 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:

Callers 15

addIndexMapEntriesMethod · 0.92
conflictKeysForNQuadMethod · 0.92
uidsForMatchFunction · 0.92
uidsForRegexFunction · 0.92
sortWithIndexFunction · 0.92
intersectBucketFunction · 0.92
TestSingleStringFunction · 0.92
handleUidPostingsMethod · 0.92
getInequalityTokensFunction · 0.92
RootNsIndexKeyFunction · 0.92
addIndexMutationMethod · 0.92

Calls 3

copyFunction · 0.85
generateKeyFunction · 0.70
AssertTrueFunction · 0.70

Tested by 7

TestSingleStringFunction · 0.74
TestTokensTableFunction · 0.74
TestRebuildTokIndexFunction · 0.74
TestIndexKeyFunction · 0.68
TestIndexKeyWithStartUidFunction · 0.68