MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / readSchema

Function readSchema

dgraph/cmd/bulk/loader.go:296–326  ·  view source on GitHub ↗
(opt *BulkOptions)

Source from the content-addressed store, hash-verified

294}
295
296func readSchema(opt *BulkOptions) *schema.ParsedSchema {
297 if opt.SchemaFile == "" {
298 return genDQLSchema(opt)
299 }
300
301 f, err := filestore.Open(opt.SchemaFile)
302 x.Check(err)
303 defer func() {
304 if err := f.Close(); err != nil {
305 glog.Warningf("error while closing fd: %v", err)
306 }
307 }()
308
309 key := opt.EncryptionKey
310 if !opt.Encrypted {
311 key = nil
312 }
313 r, err := enc.GetReader(key, f)
314 x.Check(err)
315 if filepath.Ext(opt.SchemaFile) == ".gz" {
316 r, err = gzip.NewReader(r)
317 x.Check(err)
318 }
319
320 buf, err := io.ReadAll(r)
321 x.Check(err)
322
323 result, err := schema.ParseWithNamespace(string(buf), opt.Namespace)
324 x.Check(err)
325 return result
326}
327
328func genDQLSchema(opt *BulkOptions) *schema.ParsedSchema {
329 gqlSchBytes := readGqlSchema(opt)

Callers 1

newLoaderFunction · 0.70

Calls 7

OpenFunction · 0.92
CheckFunction · 0.92
GetReaderFunction · 0.92
ParseWithNamespaceFunction · 0.92
genDQLSchemaFunction · 0.85
WarningfMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…