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

Function updateSchema

worker/mutation.go:283–299  ·  view source on GitHub ↗

updateSchema commits the schema to disk in blocking way, should be ok because this happens only during schema mutations or we see a new predicate.

(s *pb.SchemaUpdate, ts uint64)

Source from the content-addressed store, hash-verified

281// updateSchema commits the schema to disk in blocking way, should be ok because this happens
282// only during schema mutations or we see a new predicate.
283func updateSchema(s *pb.SchemaUpdate, ts uint64) error {
284 schema.State().Set(s.Predicate, s)
285 schema.State().DeleteMutSchema(s.Predicate)
286 txn := pstore.NewTransactionAt(ts, true)
287 defer txn.Discard()
288 data, err := proto.Marshal(s)
289 x.Check(err)
290 e := &badger.Entry{
291 Key: x.SchemaKey(s.Predicate),
292 Value: data,
293 UserMeta: posting.BitSchemaPosting,
294 }
295 if err = txn.SetEntry(e.WithDiscard()); err != nil {
296 return err
297 }
298 return txn.CommitAt(ts, nil)
299}
300
301func createSchema(attr string, typ types.TypeID, hint pb.Metadata_HintType, ts uint64) error {
302 ctx := schema.GetWriteContext(context.Background())

Callers 4

applySchemaFunction · 0.70
runSchemaMutationFunction · 0.70
createSchemaFunction · 0.70
ApplyInitialSchemaFunction · 0.70

Calls 5

StateFunction · 0.92
CheckFunction · 0.92
SchemaKeyFunction · 0.92
DeleteMutSchemaMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected