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

Method checkAndSetInitialSchema

dgraph/cmd/bulk/schema.go:104–130  ·  view source on GitHub ↗

checkAndSetInitialSchema initializes the schema for namespace if it does not already exist.

(namespace uint64)

Source from the content-addressed store, hash-verified

102
103// checkAndSetInitialSchema initializes the schema for namespace if it does not already exist.
104func (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
132func (s *schemaStore) validateType(de *pb.DirectedEdge, objectIsUID bool) {
133 if objectIsUID {

Callers 2

newSchemaStoreFunction · 0.95
processNQuadMethod · 0.80

Calls 6

CompleteInitialSchemaFunction · 0.92
CompleteInitialTypesFunction · 0.92
NamespaceAttrFunction · 0.92
LockMethod · 0.45
UnlockMethod · 0.45
StoreMethod · 0.45

Tested by

no test coverage detected