processFile forwards a file to the RDF or JSON processor as appropriate
(ctx context.Context, fs filestore.FileStore, filename string, key x.Sensitive)
| 446 | |
| 447 | // processFile forwards a file to the RDF or JSON processor as appropriate |
| 448 | func (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 | |
| 470 | func (l *loader) processLoadFile(ctx context.Context, rd *bufio.Reader, ck chunker.Chunker) error { |
| 471 | nqbuf := ck.NQuads() |
no test coverage detected