joeyac opened a new issue #9311: URL: https://github.com/apache/arrow/issues/9311
writer.cc: construct table like https://arrow.apache.org/docs/cpp/examples/row_columnar_conversion.html :: VectorToColumnarTable, then use the following code write table to stdout: ``` arrow::Status WriteTableToStdout(const std::shared_ptr<arrow::Table> &table) { arrow::TableBatchReader tbr(*table); BatchVector out_batches; std::shared_ptr<arrow::RecordBatch> rb = nullptr; while (true) { ARROW_RETURN_NOT_OK(tbr.ReadNext(&rb)); if (rb == nullptr) break; out_batches.push_back(rb); } arrow::io::StdoutStream output_stream; auto write_options = arrow::ipc::IpcWriteOptions::Defaults(); PARQUET_ASSIGN_OR_THROW( std::shared_ptr<arrow::ipc::RecordBatchWriter> writer, arrow::ipc::MakeStreamWriter(&output_stream, out_batches[0]->schema(), write_options)); for (const auto& batch : out_batches) { ARROW_RETURN_NOT_OK(writer->WriteRecordBatch(*batch)); } std::cerr << "write done" << std::endl; writer->Close(); return arrow::Status::OK(); } ``` reader.cc: use the following code read RecordBatch from stdin: ``` arrow::Status ReadTableFromStdin(std::shared_ptr<arrow::Table>* table) { BatchVector out_batches; arrow::io::StdinStream input_stream; PARQUET_ASSIGN_OR_THROW(auto stream_reader, arrow::ipc::RecordBatchStreamReader::Open(&input_stream)); PARQUET_THROW_NOT_OK(stream_reader->ReadAll(&out_batches)); PARQUET_ASSIGN_OR_THROW(*table, arrow::Table::FromRecordBatches(out_batches)); return arrow::Status::OK(); } ``` finally, I found `mutable_ccv_ptr` is nullptr so I can't modify the table value. ``` auto cost_components = std::static_pointer_cast<arrow::ListArray>(table->column(2)->chunk(0)); auto cost_components_values = std::static_pointer_cast<arrow::DoubleArray>(cost_components->values()); const double* ccv_ptr = cost_components_values->data()->GetValues<double>(1); double* mutable_ccv_ptr = cost_components_values->data()->GetMutableValues<double>(1); ``` But in example https://arrow.apache.org/docs/cpp/examples/row_columnar_conversion.html, I found I can modify value through `mutable_ccv_ptr` like this. Did I use it wrong? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
