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

Method uid

dgraph/cmd/live/run.go:259–277  ·  view source on GitHub ↗
(val string, ns uint64)

Source from the content-addressed store, hash-verified

257}
258
259func (l *loader) uid(val string, ns uint64) string {
260 // Attempt to parse as a UID (in the same format that dgraph outputs - a
261 // hex number prefixed by "0x"). If parsing succeeds, then this is assumed
262 // to be an existing node in the graph. There is limited protection against
263 // a user selecting an unassigned UID in this way - it may be assigned
264 // later to another node. It is up to the user to avoid this.
265 if !opt.newUids {
266 if uid, err := strconv.ParseUint(val, 0, 64); err == nil {
267 return fmt.Sprintf("%#x", uid)
268 }
269 }
270
271 // TODO(Naman): Do we still need this here? As xidmap which uses btree does not keep hold of this string.
272 sb := strings.Builder{}
273 x.Check2(sb.WriteString(x.NamespaceAttr(ns, val)))
274 uid, _ := l.alloc.AssignUid(sb.String())
275
276 return fmt.Sprintf("%#x", uid)
277}
278
279func generateBlankNode(val string) string {
280 // generates "u_hash(val)"

Callers 1

processLoadFileMethod · 0.95

Calls 4

Check2Function · 0.92
NamespaceAttrFunction · 0.92
AssignUidMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected