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

Method createPostings

dgraph/cmd/bulk/mapper.go:398–432  ·  view source on GitHub ↗
(nq dql.NQuad,
	de *pb.DirectedEdge)

Source from the content-addressed store, hash-verified

396}
397
398func (m *mapper) createPostings(nq dql.NQuad,
399 de *pb.DirectedEdge) (*pb.Posting, *pb.Posting) {
400
401 m.schema.validateType(de, nq.ObjectValue == nil)
402
403 p := posting.NewPosting(de)
404 sch := m.schema.getSchema(x.NamespaceAttr(nq.GetNamespace(), nq.GetPredicate()))
405 if nq.GetObjectValue() != nil {
406 lang := de.GetLang()
407 switch {
408 case len(lang) > 0:
409 p.Uid = farm.Fingerprint64([]byte(lang))
410 case sch.List:
411 p.Uid = farm.Fingerprint64(de.Value)
412 default:
413 p.Uid = math.MaxUint64
414 }
415 }
416 p.Facets = nq.Facets
417
418 // Early exit for no reverse edge.
419 if sch.GetDirective() != pb.SchemaUpdate_REVERSE {
420 return p, nil
421 }
422
423 // Reverse predicate
424 x.AssertTruef(nq.GetObjectValue() == nil, "only has reverse schema if object is UID")
425 de.Entity, de.ValueId = de.ValueId, de.Entity
426 m.schema.validateType(de, true)
427 rp := posting.NewPosting(de)
428
429 de.Entity, de.ValueId = de.ValueId, de.Entity // de reused so swap back.
430
431 return p, rp
432}
433
434func (m *mapper) addIndexMapEntries(nq dql.NQuad, de *pb.DirectedEdge) {
435 if nq.GetObjectValue() == nil {

Callers 1

processNQuadMethod · 0.95

Calls 9

NewPostingFunction · 0.92
NamespaceAttrFunction · 0.92
AssertTruefFunction · 0.92
validateTypeMethod · 0.80
getSchemaMethod · 0.80
GetDirectiveMethod · 0.80
GetNamespaceMethod · 0.45
GetPredicateMethod · 0.45
GetLangMethod · 0.45

Tested by

no test coverage detected