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

Function ExtractBlankUIDs

query/mutation.go:144–182  ·  view source on GitHub ↗
(ctx context.Context, gmuList []*dql.Mutation)

Source from the content-addressed store, hash-verified

142}
143
144func ExtractBlankUIDs(ctx context.Context, gmuList []*dql.Mutation) (map[string]uint64, error) {
145 newUids := make(map[string]uint64)
146 var err error
147 for _, gmu := range gmuList {
148 for _, nq := range gmu.Set {
149 // We dont want to assign uids to these.
150 if nq.Subject == x.Star && nq.ObjectValue.GetDefaultVal() == x.Star {
151 return newUids, errors.New("predicate deletion should be called via alter")
152 }
153
154 if len(nq.Subject) == 0 {
155 return nil, errors.Errorf("subject must not be empty for nquad: %+v", nq)
156 }
157 var uid uint64
158 if strings.HasPrefix(nq.Subject, "_:") {
159 newUids[nq.Subject] = 0
160 } else if uid, err = dql.ParseUid(nq.Subject); err != nil {
161 return newUids, err
162 }
163 if err = verifyUid(ctx, uid); err != nil {
164 return newUids, err
165 }
166
167 if len(nq.ObjectId) > 0 {
168 var uid uint64
169 if strings.HasPrefix(nq.ObjectId, "_:") {
170 newUids[nq.ObjectId] = 0
171 } else if uid, err = dql.ParseUid(nq.ObjectId); err != nil {
172 return newUids, err
173 }
174 if err = verifyUid(ctx, uid); err != nil {
175 return newUids, err
176 }
177 }
178 }
179 }
180
181 return newUids, nil
182}
183
184// AssignUids tries to assign unique ids to each identity in the subjects and objects in the
185// format of _:xxx. An identity, e.g. _:a, will only be assigned one uid regardless how many times

Callers 1

AssignUidsFunction · 0.85

Calls 3

ParseUidFunction · 0.92
verifyUidFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected