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

Function DataKey

x/keys.go:201–211  ·  view source on GitHub ↗

DataKey generates a data key with the given attribute and UID. The structure of a data 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 ByteDat

(attr string, uid uint64)

Source from the content-addressed store, hash-verified

199// next eight bytes (optional): if the key corresponds to a split list, the startUid of
200// the split stored in this key and the first byte will be sets to ByteSplit.
201func DataKey(attr string, uid uint64) []byte {
202 extra := 1 + 8 // ByteData + UID
203 buf, prefixLen := generateKey(DefaultPrefix, attr, extra)
204
205 rest := buf[prefixLen:]
206 rest[0] = ByteData
207
208 rest = rest[1:]
209 binary.BigEndian.PutUint64(rest, uid)
210 return buf
211}
212
213// ReverseKey generates a reverse key with the given attribute and UID.
214// The structure of a reverse key is as follows:

Callers 15

processNQuadMethod · 0.92
conflictKeysForNQuadMethod · 0.92
fetchValueFunction · 0.92
TestGetScalarListFunction · 0.92
TestSingleUidReplacementFunction · 0.92
TestLangExactFunction · 0.92
TestReverseEdgeFunction · 0.92
populateGraphExportFunction · 0.92
populateGraphFunction · 0.92
handleValuePostingsMethod · 0.92

Calls 1

generateKeyFunction · 0.70

Tested by 15

TestGetScalarListFunction · 0.74
TestSingleUidReplacementFunction · 0.74
TestLangExactFunction · 0.74
TestReverseEdgeFunction · 0.74
populateGraphExportFunction · 0.74
populateGraphFunction · 0.74
BenchmarkTestCacheFunction · 0.74
TestRollupTimestampFunction · 0.74
TestPostingListReadFunction · 0.74