checkAndSetInitialSchema initializes the schema for namespace if it does not already exist.
(namespace uint64)
| 102 | |
| 103 | // checkAndSetInitialSchema initializes the schema for namespace if it does not already exist. |
| 104 | func (s *schemaStore) checkAndSetInitialSchema(namespace uint64) { |
| 105 | if _, ok := s.namespaces.Load(namespace); ok { |
| 106 | return |
| 107 | } |
| 108 | s.Lock() |
| 109 | defer s.Unlock() |
| 110 | |
| 111 | if _, ok := s.namespaces.Load(namespace); ok { |
| 112 | return |
| 113 | } |
| 114 | // Load all initial predicates. Some predicates that might not be used when |
| 115 | // the alpha is started (e.g ACL predicates) might be included but it's |
| 116 | // better to include them in case the input data contains triples with these |
| 117 | // predicates. |
| 118 | for _, update := range schema.CompleteInitialSchema(namespace) { |
| 119 | s.schemaMap[update.Predicate] = update |
| 120 | } |
| 121 | s.types = append(s.types, schema.CompleteInitialTypes(namespace)...) |
| 122 | |
| 123 | if s.opt.StoreXids { |
| 124 | s.schemaMap[x.NamespaceAttr(namespace, "xid")] = &pb.SchemaUpdate{ |
| 125 | ValueType: pb.Posting_STRING, |
| 126 | Tokenizer: []string{"hash"}, |
| 127 | } |
| 128 | } |
| 129 | s.namespaces.Store(namespace, struct{}{}) |
| 130 | } |
| 131 | |
| 132 | func (s *schemaStore) validateType(de *pb.DirectedEdge, objectIsUID bool) { |
| 133 | if objectIsUID { |
no test coverage detected