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

Function VerifyPostingSplits

x/debug.go:107–136  ·  view source on GitHub ↗

VerifyPostingSplits checks if all the keys from parts are present in kvs. Parts is a map of split keys -> postinglist.

(kvs []*bpb.KV, plist *pb.PostingList,
	parts map[uint64]*pb.PostingList, baseKey []byte)

Source from the content-addressed store, hash-verified

105// VerifyPostingSplits checks if all the keys from parts are
106// present in kvs. Parts is a map of split keys -> postinglist.
107func VerifyPostingSplits(kvs []*bpb.KV, plist *pb.PostingList,
108 parts map[uint64]*pb.PostingList, baseKey []byte) {
109 if len(plist.Splits) == 0 {
110 return
111 }
112
113 if plist.Splits[0] != uint64(1) {
114 log.Panic("Posting split verification failed: First uid of split ",
115 plist.Splits[0], " is not 1\nPosting: ", plist)
116 }
117 for _, uid := range plist.Splits {
118 if _, ok := parts[uid]; !ok {
119 log.Panic(uid, " split uid is not present")
120 }
121
122 partKey, kErr := SplitKey(baseKey, uid)
123 if kErr != nil {
124 log.Panic("Error while generating splitKey. baseKey: ",
125 baseKey, " startUid: ", uid)
126 }
127 keyIdx := sort.Search(len(kvs), func(i int) bool {
128 return bytes.Compare(kvs[i].Key, partKey) >= 0
129 })
130
131 if keyIdx == len(kvs) {
132 log.Panic("Posting split verification failed: ", partKey,
133 " split key not found\nbaseKey: ", baseKey, "\nPosting: ", plist)
134 }
135 }
136}

Callers 1

RollupMethod · 0.92

Calls 4

SplitKeyFunction · 0.85
PanicMethod · 0.80
CompareMethod · 0.80
SearchMethod · 0.65

Tested by

no test coverage detected