| 42 | } |
| 43 | |
| 44 | std::shared_ptr<arrow::RecordBatch> GetArrowRecordBatch( |
| 45 | ::google::cloud::bigquery::storage::v1::ArrowRecordBatch const& |
| 46 | record_batch_in, |
| 47 | std::shared_ptr<arrow::Schema> schema) { |
| 48 | std::shared_ptr<arrow::Buffer> buffer = std::make_shared<arrow::Buffer>( |
| 49 | record_batch_in.serialized_record_batch()); |
| 50 | arrow::io::BufferReader buffer_reader(buffer); |
| 51 | arrow::ipc::DictionaryMemo dictionary_memo; |
| 52 | arrow::ipc::IpcReadOptions read_options; |
| 53 | auto result = arrow::ipc::ReadRecordBatch(schema, &dictionary_memo, |
| 54 | read_options, &buffer_reader); |
| 55 | if (!result.ok()) { |
| 56 | std::cout << "Unable to parse record batch\n"; |
| 57 | throw result.status(); |
| 58 | } |
| 59 | std::shared_ptr<arrow::RecordBatch> record_batch = result.ValueOrDie(); |
| 60 | return record_batch; |
| 61 | } |
| 62 | |
| 63 | void PrintColumnNames(std::shared_ptr<arrow::RecordBatch> record_batch) { |
| 64 | // Print each column name for the record batch. |