| 333 | } |
| 334 | |
| 335 | Result<std::shared_ptr<InspectedFragment>> DoInspectFragment( |
| 336 | const FileSource& source, const JsonFragmentScanOptions& format_options, |
| 337 | MemoryPool* pool) { |
| 338 | ARROW_ASSIGN_OR_RAISE(auto stream, source.OpenCompressed()); |
| 339 | ARROW_ASSIGN_OR_RAISE( |
| 340 | stream, io::BufferedInputStream::Create(format_options.read_options.block_size, |
| 341 | default_memory_pool(), std::move(stream))); |
| 342 | |
| 343 | ARROW_ASSIGN_OR_RAISE(auto first_block, |
| 344 | stream->Peek(format_options.read_options.block_size)); |
| 345 | |
| 346 | auto parse_options = GetInitialParseOptions(format_options.parse_options); |
| 347 | ARROW_ASSIGN_OR_RAISE(auto struct_type, |
| 348 | ParseToStructType(first_block, parse_options, pool)); |
| 349 | |
| 350 | std::vector<std::string> column_names; |
| 351 | column_names.reserve(struct_type->num_fields()); |
| 352 | for (const auto& f : struct_type->fields()) { |
| 353 | column_names.push_back(f->name()); |
| 354 | } |
| 355 | |
| 356 | return std::make_shared<JsonInspectedFragment>(std::move(column_names), |
| 357 | std::move(stream), source.Size()); |
| 358 | } |
| 359 | |
| 360 | } // namespace |
| 361 |
no test coverage detected