AlenkaF commented on code in PR #40359:
URL: https://github.com/apache/arrow/pull/40359#discussion_r1514553902
##########
cpp/src/arrow/record_batch.cc:
##########
@@ -253,14 +253,65 @@ inline void ConvertColumnsToTensor(const RecordBatch&
batch, uint8_t* out) {
using CType = typename arrow::TypeTraits<DataType>::CType;
auto* out_values = reinterpret_cast<CType*>(out);
- // Loop through all of the columns
- for (int i = 0; i < batch.num_columns(); ++i) {
- const auto* in_values = batch.column(i)->data()->GetValues<CType>(1);
-
- // Copy data of each column
- memcpy(out_values, in_values, sizeof(CType) * batch.num_rows());
- out_values += batch.num_rows();
- } // End loop through columns
+ if (TypeTraits<DataType>::type_singleton() ==
+ batch.column(0)->type()) { // If all columns are of same data type
+ // Loop through all of the columns
+ for (int i = 0; i < batch.num_columns(); ++i) {
+ const auto& arr = *batch.column(i);
+ auto data = arr.data();
+ const auto& in_values = data->GetValues<CType>(1);
Review Comment:
Oh thanks, I missed this one!
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]