MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cpp-samples / GetArrowRecordBatch

Function GetArrowRecordBatch

bigquery/read/arrow/arrow_read.cc:44–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44std::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
63void PrintColumnNames(std::shared_ptr<arrow::RecordBatch> record_batch) {
64 // Print each column name for the record batch.

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected