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

Function readSchema

testutil/backup.go:196–226  ·  view source on GitHub ↗
(pdir string, dType dataType)

Source from the content-addressed store, hash-verified

194)
195
196func readSchema(pdir string, dType dataType) ([]string, error) {
197 db, err := openDgraph(pdir)
198 if err != nil {
199 return nil, err
200 }
201 defer db.Close()
202 values := make([]string, 0)
203
204 txn := db.NewTransactionAt(math.MaxUint64, false)
205 defer txn.Discard()
206 itr := txn.NewIterator(badger.DefaultIteratorOptions)
207 defer itr.Close()
208
209 for itr.Rewind(); itr.Valid(); itr.Next() {
210 item := itr.Item()
211 pk, err := x.Parse(item.Key())
212 x.Check(err)
213
214 switch {
215 case item.UserMeta() != posting.BitSchemaPosting:
216 continue
217 case pk.IsSchema() && dType != schemaPredicate:
218 continue
219 case pk.IsType() && dType != schemaType:
220 continue
221 }
222
223 values = append(values, x.ParseAttr(pk.Attr))
224 }
225 return values, nil
226}
227
228// GetPredicateNames returns the list of all the predicates stored in the restored pdir.
229func GetPredicateNames(pdir string) ([]string, error) {

Callers 2

GetPredicateNamesFunction · 0.70
GetTypeNamesFunction · 0.70

Calls 12

ParseFunction · 0.92
CheckFunction · 0.92
ParseAttrFunction · 0.92
openDgraphFunction · 0.85
NewIteratorMethod · 0.80
ValidMethod · 0.80
ItemMethod · 0.80
IsSchemaMethod · 0.80
IsTypeMethod · 0.80
CloseMethod · 0.65
NextMethod · 0.45
KeyMethod · 0.45

Tested by

no test coverage detected