(val string, ns uint64)
| 257 | } |
| 258 | |
| 259 | func (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 | |
| 279 | func generateBlankNode(val string) string { |
| 280 | // generates "u_hash(val)" |
no test coverage detected