(db *badger.DB, preds []string)
| 183 | } |
| 184 | |
| 185 | func (s *schemaStore) write(db *badger.DB, preds []string) { |
| 186 | w := posting.NewTxnWriter(db) |
| 187 | for _, pred := range preds { |
| 188 | sch, ok := s.schemaMap[pred] |
| 189 | if !ok { |
| 190 | continue |
| 191 | } |
| 192 | k := x.SchemaKey(pred) |
| 193 | v, err := proto.Marshal(sch) |
| 194 | x.Check(err) |
| 195 | // Write schema and types always at timestamp 1, s.state.writeTs may not be equal to 1 |
| 196 | // if bulk loader was restarted or other similar scenarios. |
| 197 | x.Check(w.SetAt(k, v, posting.BitSchemaPosting, 1)) |
| 198 | } |
| 199 | |
| 200 | // Write all the types as all groups should have access to all the types. |
| 201 | for _, typ := range s.types { |
| 202 | k := x.TypeKey(typ.TypeName) |
| 203 | v, err := proto.Marshal(typ) |
| 204 | x.Check(err) |
| 205 | x.Check(w.SetAt(k, v, posting.BitSchemaPosting, 1)) |
| 206 | } |
| 207 | |
| 208 | x.Check(w.Flush()) |
| 209 | } |
no test coverage detected