(nq dql.NQuad, de *pb.DirectedEdge)
| 432 | } |
| 433 | |
| 434 | func (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 | } |
no test coverage detected