Convert JSON file to IPC binary format
| 77 | |
| 78 | // Convert JSON file to IPC binary format |
| 79 | static Status ConvertJsonToArrow(const std::string& json_path, |
| 80 | const std::string& arrow_path) { |
| 81 | ARROW_ASSIGN_OR_RAISE(auto in_file, io::ReadableFile::Open(json_path)); |
| 82 | ARROW_ASSIGN_OR_RAISE(auto out_file, io::FileOutputStream::Open(arrow_path)); |
| 83 | |
| 84 | ARROW_ASSIGN_OR_RAISE(int64_t file_size, in_file->GetSize()); |
| 85 | ARROW_ASSIGN_OR_RAISE(auto json_buffer, in_file->Read(file_size)); |
| 86 | |
| 87 | ARROW_ASSIGN_OR_RAISE(auto reader, IntegrationJsonReader::Open(json_buffer)); |
| 88 | |
| 89 | if (FLAGS_verbose) { |
| 90 | std::cout << "Found schema:\n" |
| 91 | << reader->schema()->ToString(/* show_metadata = */ true) << std::endl; |
| 92 | } |
| 93 | |
| 94 | ARROW_ASSIGN_OR_RAISE(auto writer, ipc::MakeFileWriter(out_file, reader->schema(), |
| 95 | IpcWriteOptions::Defaults())); |
| 96 | for (int i = 0; i < reader->num_record_batches(); ++i) { |
| 97 | ARROW_ASSIGN_OR_RAISE(auto batch, reader->ReadRecordBatch(i)); |
| 98 | RETURN_NOT_OK(writer->WriteRecordBatch(*batch)); |
| 99 | } |
| 100 | return writer->Close(); |
| 101 | } |
| 102 | |
| 103 | // Convert IPC binary format to JSON |
| 104 | static Status ConvertArrowToJson(const std::string& arrow_path, |
no test coverage detected