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

Function Load

schema/schema.go:531–558  ·  view source on GitHub ↗

Load reads the latest schema for the given predicate from the DB.

(predicate string)

Source from the content-addressed store, hash-verified

529
530// Load reads the latest schema for the given predicate from the DB.
531func Load(predicate string) error {
532 if len(predicate) == 0 {
533 return errors.Errorf("Empty predicate")
534 }
535 State().DeleteMutSchema(predicate)
536 key := x.SchemaKey(predicate)
537 txn := pstore.NewTransactionAt(math.MaxUint64, false)
538 defer txn.Discard()
539 item, err := txn.Get(key)
540 if err == badger.ErrKeyNotFound || err == badger.ErrBannedKey {
541 return nil
542 }
543 if err != nil {
544 return err
545 }
546 var s pb.SchemaUpdate
547 err = item.Value(func(val []byte) error {
548 x.Check(proto.Unmarshal(val, &s))
549 return nil
550 })
551 if err != nil {
552 return err
553 }
554 State().Set(predicate, &s)
555 State().elog.Printf(logUpdate(&s, predicate))
556 glog.Infoln(logUpdate(&s, predicate))
557 return nil
558}
559
560// LoadFromDb reads schema information from db and stores it in memory
561func LoadFromDb(ctx context.Context) error {

Callers 2

undoSchemaUpdateFunction · 0.92
populateKeyValuesFunction · 0.92

Calls 9

SchemaKeyFunction · 0.92
CheckFunction · 0.92
logUpdateFunction · 0.85
DeleteMutSchemaMethod · 0.80
StateFunction · 0.70
GetMethod · 0.65
SetMethod · 0.65
ErrorfMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected