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

Function newSchemaStore

dgraph/cmd/bulk/schema.go:31–59  ·  view source on GitHub ↗
(initial *schema.ParsedSchema, opt *BulkOptions, state *state)

Source from the content-addressed store, hash-verified

29}
30
31func newSchemaStore(initial *schema.ParsedSchema, opt *BulkOptions, state *state) *schemaStore {
32 if opt == nil {
33 log.Fatalf("Cannot create schema store with nil options.")
34 }
35
36 s := &schemaStore{
37 schemaMap: map[string]*pb.SchemaUpdate{},
38 state: state,
39 }
40
41 // Initialize only for the default namespace. Initialization for other namespaces will be done
42 // whenever we see data for a new namespace.
43 s.checkAndSetInitialSchema(x.RootNamespace)
44
45 s.types = initial.Types
46 // This is from the schema read from the schema file.
47 for _, sch := range initial.Preds {
48 p := sch.Predicate
49 sch.Predicate = "" // Predicate is stored in the (badger) key, so not needed in the value.
50 if _, ok := s.schemaMap[p]; ok {
51 fmt.Printf("Predicate %q already exists in schema\n", p)
52 continue
53 }
54 s.checkAndSetInitialSchema(x.ParseNamespace(p))
55 s.schemaMap[p] = sch
56 }
57
58 return s
59}
60
61func (s *schemaStore) getSchema(pred string) *pb.SchemaUpdate {
62 s.RLock()

Callers 1

newLoaderFunction · 0.85

Calls 3

ParseNamespaceFunction · 0.92
FatalfMethod · 0.80

Tested by

no test coverage detected