DecompressAndLoad will load or fetch a graph from the given path, decompress it, and then call the given load function to process the decompressed graph. If no loadFn is provided, db.Load is called.
(qw quad.WriteCloser, batch int, path, typ string)
| 121 | // it, and then call the given load function to process the decompressed graph. |
| 122 | // If no loadFn is provided, db.Load is called. |
| 123 | func DecompressAndLoad(qw quad.WriteCloser, batch int, path, typ string) error { |
| 124 | if path == "" { |
| 125 | return nil |
| 126 | } |
| 127 | qr, err := QuadReaderFor(path, typ) |
| 128 | if err != nil { |
| 129 | return err |
| 130 | } |
| 131 | defer qr.Close() |
| 132 | |
| 133 | _, err = quad.CopyBatch(&batchLogger{w: qw}, qr, batch) |
| 134 | if err != nil { |
| 135 | return fmt.Errorf("db: failed to load data: %v", err) |
| 136 | } |
| 137 | return qw.Close() |
| 138 | } |
| 139 | |
| 140 | type batchLogger struct { |
| 141 | cnt int |
no test coverage detected