| 110 | } |
| 111 | |
| 112 | arrow::Result<std::shared_ptr<ds::Dataset>> GetDatasetFromFile( |
| 113 | std::shared_ptr<fs::FileSystem> fs, std::shared_ptr<ds::ParquetFileFormat> format, |
| 114 | std::string file) { |
| 115 | ds::FileSystemFactoryOptions options; |
| 116 | // The factory will try to build a child dataset. |
| 117 | ARROW_ASSIGN_OR_RAISE(auto factory, |
| 118 | ds::FileSystemDatasetFactory::Make(fs, {file}, format, options)); |
| 119 | |
| 120 | // Try to infer a common schema for all files. |
| 121 | ARROW_ASSIGN_OR_RAISE(auto schema, factory->Inspect(conf.inspect_options)); |
| 122 | // Caller can optionally decide another schema as long as it is compatible |
| 123 | // with the previous one, e.g. `factory->Finish(compatible_schema)`. |
| 124 | ARROW_ASSIGN_OR_RAISE(auto child, factory->Finish(conf.finish_options)); |
| 125 | |
| 126 | ds::DatasetVector children; |
| 127 | children.resize(conf.repeat, child); |
| 128 | return ds::UnionDataset::Make(std::move(schema), std::move(children)); |
| 129 | } |
| 130 | |
| 131 | arrow::Result<std::shared_ptr<ds::Dataset>> GetDatasetFromPath( |
| 132 | std::shared_ptr<fs::FileSystem> fs, std::shared_ptr<ds::ParquetFileFormat> format, |
no test coverage detected