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

Method write

dgraph/cmd/bulk/schema.go:185–209  ·  view source on GitHub ↗
(db *badger.DB, preds []string)

Source from the content-addressed store, hash-verified

183}
184
185func (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}

Callers 1

writeSchemaMethod · 0.80

Calls 6

SetAtMethod · 0.95
FlushMethod · 0.95
NewTxnWriterFunction · 0.92
SchemaKeyFunction · 0.92
CheckFunction · 0.92
TypeKeyFunction · 0.92

Tested by

no test coverage detected