MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / processNQuad

Method processNQuad

dgraph/cmd/bulk/mapper.go:312–349  ·  view source on GitHub ↗
(nq dql.NQuad)

Source from the content-addressed store, hash-verified

310}
311
312func (m *mapper) processNQuad(nq dql.NQuad) {
313 if m.opt.Namespace != math.MaxUint64 {
314 // Use the specified namespace passed through '--force-namespace' flag.
315 nq.Namespace = m.opt.Namespace
316 }
317 sid := m.uid(nq.GetSubject(), nq.Namespace)
318 if sid == 0 {
319 panic(fmt.Sprintf("invalid UID with value 0 for %v", nq.GetSubject()))
320 }
321 var oid uint64
322 var de *pb.DirectedEdge
323 if nq.GetObjectValue() == nil {
324 oid = m.uid(nq.GetObjectId(), nq.Namespace)
325 if oid == 0 {
326 panic(fmt.Sprintf("invalid UID with value 0 for %v", nq.GetObjectId()))
327 }
328 de = nq.CreateUidEdge(sid, oid)
329 } else {
330 var err error
331 de, err = nq.CreateValueEdge(sid)
332 x.Check(err)
333 }
334
335 m.schema.checkAndSetInitialSchema(nq.Namespace)
336
337 // Appropriate schema must exist for the nquad's namespace by this time.
338 de.Attr = x.NamespaceAttr(de.Namespace, de.Attr)
339 fwd, rev := m.createPostings(nq, de)
340 shard := m.state.shards.shardFor(de.Attr)
341 key := x.DataKey(de.Attr, sid)
342 m.addMapEntry(key, fwd, shard)
343
344 if rev != nil {
345 key = x.ReverseKey(de.Attr, oid)
346 m.addMapEntry(key, rev, shard)
347 }
348 m.addIndexMapEntries(nq, de)
349}
350
351func (m *mapper) uid(xid string, ns uint64) uint64 {
352 if !m.opt.NewUids {

Callers 2

runMethod · 0.95
lookupUidMethod · 0.95

Calls 12

uidMethod · 0.95
createPostingsMethod · 0.95
addMapEntryMethod · 0.95
addIndexMapEntriesMethod · 0.95
CheckFunction · 0.92
NamespaceAttrFunction · 0.92
DataKeyFunction · 0.92
ReverseKeyFunction · 0.92
CreateUidEdgeMethod · 0.80
CreateValueEdgeMethod · 0.80
shardForMethod · 0.45

Tested by

no test coverage detected