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)
| 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. |
| 283 | func 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 | |
| 301 | func createSchema(attr string, typ types.TypeID, hint pb.Metadata_HintType, ts uint64) error { |
| 302 | ctx := schema.GetWriteContext(context.Background()) |
no test coverage detected