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

Function SplitKey

x/keys.go:512–526  ·  view source on GitHub ↗

SplitKey takes a key baseKey and generates the key of the list split that starts at startUid.

(baseKey []byte, startUid uint64)

Source from the content-addressed store, hash-verified

510
511// SplitKey takes a key baseKey and generates the key of the list split that starts at startUid.
512func SplitKey(baseKey []byte, startUid uint64) ([]byte, error) {
513 keyCopy := make([]byte, len(baseKey)+8)
514 copy(keyCopy, baseKey)
515
516 if keyCopy[0] != DefaultPrefix {
517 return nil, errors.Errorf("only keys with default prefix can have a split key")
518 }
519 // Change the first byte (i.e the key prefix) to ByteSplit to signal this is an
520 // individual part of a single list key.
521 keyCopy[0] = ByteSplit
522
523 // Append the start uid at the end of the key.
524 binary.BigEndian.PutUint64(keyCopy[len(baseKey):], startUid)
525 return keyCopy, nil
526}
527
528// Parse would parse the key. ParsedKey does not reuse the key slice, so the key slice can change
529// without affecting the contents of ParsedKey.

Callers 11

TestMultiPartListMarshalFunction · 0.92
readListPartMethod · 0.92
VerifySnapshotFunction · 0.85
VerifyPostingSplitsFunction · 0.85
FromBackupKeyFunction · 0.85
TestIndexKeyWithStartUidFunction · 0.85
TestCountKeyWithStartUidFunction · 0.85
TestBadStartUidFunction · 0.85

Calls 2

copyFunction · 0.85
ErrorfMethod · 0.45

Tested by 6

TestMultiPartListMarshalFunction · 0.74
TestIndexKeyWithStartUidFunction · 0.68
TestCountKeyWithStartUidFunction · 0.68
TestBadStartUidFunction · 0.68