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

Method addIndexMapEntries

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

Source from the content-addressed store, hash-verified

432}
433
434func (m *mapper) addIndexMapEntries(nq dql.NQuad, de *pb.DirectedEdge) {
435 if nq.GetObjectValue() == nil {
436 return // Cannot index UIDs
437 }
438
439 sch := m.schema.getSchema(x.NamespaceAttr(nq.GetNamespace(), nq.GetPredicate()))
440 for _, tokerName := range sch.GetTokenizer() {
441 // Find tokeniser.
442 toker, ok := tok.GetTokenizer(tokerName)
443 if !ok {
444 log.Fatalf("unknown tokenizer %q", tokerName)
445 }
446
447 // Create storage value.
448 storageVal := types.Val{
449 Tid: types.TypeID(de.GetValueType()),
450 Value: de.GetValue(),
451 }
452
453 // Convert from storage type to schema type.
454 schemaVal, err := types.Convert(storageVal, types.TypeID(sch.GetValueType()))
455 // Shouldn't error, since we've already checked for convertibility when
456 // doing edge postings. So okay to be fatal.
457 x.Check(err)
458
459 // Extract tokens.
460 toks, err := tok.BuildTokens(schemaVal.Value, tok.GetTokenizerForLang(toker, nq.Lang))
461 x.Check(err)
462
463 attr := x.NamespaceAttr(nq.Namespace, nq.Predicate)
464 // Store index posting.
465 for _, t := range toks {
466 m.addMapEntry(
467 x.IndexKey(attr, t),
468 &pb.Posting{
469 Uid: de.GetEntity(),
470 PostingType: pb.Posting_REF,
471 },
472 m.state.shards.shardFor(attr),
473 )
474 }
475 }
476}

Callers 1

processNQuadMethod · 0.95

Calls 15

addMapEntryMethod · 0.95
NamespaceAttrFunction · 0.92
GetTokenizerFunction · 0.92
TypeIDTypeAlias · 0.92
ConvertFunction · 0.92
CheckFunction · 0.92
BuildTokensFunction · 0.92
GetTokenizerForLangFunction · 0.92
IndexKeyFunction · 0.92
getSchemaMethod · 0.80
FatalfMethod · 0.80
GetEntityMethod · 0.80

Tested by

no test coverage detected