MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / processFile

Method processFile

dgraph/cmd/live/run.go:448–468  ·  view source on GitHub ↗

processFile forwards a file to the RDF or JSON processor as appropriate

(ctx context.Context, fs filestore.FileStore, filename string,
	key x.Sensitive)

Source from the content-addressed store, hash-verified

446
447// processFile forwards a file to the RDF or JSON processor as appropriate
448func (l *loader) processFile(ctx context.Context, fs filestore.FileStore, filename string,
449 key x.Sensitive) error {
450
451 fmt.Printf("Processing data file %q\n", filename)
452
453 rd, cleanup := fs.ChunkReader(filename, key)
454 defer cleanup()
455
456 loadType := chunker.DataFormat(filename, opt.dataFormat)
457 if loadType == chunker.UnknownFormat {
458 if isJson, err := chunker.IsJSONData(rd); err == nil {
459 if isJson {
460 loadType = chunker.JsonFormat
461 } else {
462 return errors.Errorf("need --format=rdf or --format=json to load %s", filename)
463 }
464 }
465 }
466
467 return l.processLoadFile(ctx, rd, chunker.NewChunker(loadType, opt.batchSize))
468}
469
470func (l *loader) processLoadFile(ctx context.Context, rd *bufio.Reader, ck chunker.Chunker) error {
471 nqbuf := ck.NQuads()

Callers 1

runFunction · 0.80

Calls 7

processLoadFileMethod · 0.95
DataFormatFunction · 0.92
IsJSONDataFunction · 0.92
NewChunkerFunction · 0.92
cleanupFunction · 0.85
ChunkReaderMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected