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

Function ReverseKey

x/keys.go:223–233  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

221// next eight bytes (optional): if the key corresponds to a split list,
222// the startUid of the split stored in this key.
223func 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
235func IndexKeyAfterAllTerms(attr string) []byte {
236 // Use a term with 0xFF to ensure lexicographically after any real term

Callers 12

processNQuadMethod · 0.92
TestReverseEdgeSetDelFunction · 0.92
handleUidPostingsMethod · 0.92
handleHasFunctionMethod · 0.92
RootNsReverseKeyFunction · 0.92
addReverseMutationMethod · 0.92
FromBackupKeyFunction · 0.85
TestReverseKeyFunction · 0.85
TestBadStartUidFunction · 0.85

Calls 1

generateKeyFunction · 0.70

Tested by 5

TestReverseEdgeSetDelFunction · 0.74
TestReverseKeyFunction · 0.68
TestBadStartUidFunction · 0.68