pitrou commented on code in PR #38443:
URL: https://github.com/apache/arrow/pull/38443#discussion_r1409275278


##########
cpp/src/arrow/c/bridge.cc:
##########
@@ -566,15 +575,31 @@ struct ArrayExporter {
       --n_buffers;
       ++buffers_begin;
     }
+
+    bool need_variadic_buffer_sizes =
+        data->type->id() == Type::BINARY_VIEW || data->type->id() == 
Type::STRING_VIEW;
+    if (need_variadic_buffer_sizes) {
+      ++n_buffers;
+    }
+
     export_.buffers_.resize(n_buffers);
     std::transform(buffers_begin, data->buffers.end(), 
export_.buffers_.begin(),
                    [](const std::shared_ptr<Buffer>& buffer) -> const void* {
                      return buffer ? buffer->data() : nullptr;
                    });
 
+    if (need_variadic_buffer_sizes) {
+      auto variadic_buffers = util::span(data->buffers).subspan(2);
+      export_.variadic_buffer_sizes_.resize(variadic_buffers.size());
+      for (auto [size, buf] : Zip(export_.variadic_buffer_sizes_, 
variadic_buffers)) {
+        size = buf->size();
+      }

Review Comment:
   Yes, or perhaps simply avoid `Zip` here and use the more usual and more 
readable push-back approach:
   ```c++
         export_.variadic_buffer_sizes_.reserve(variadic_buffers.size());
         for (const auto& buf : variadic_buffers) {
           export_.variadic_buffer_sizes_.push_back(buf->size());
         }



-- 
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]

Reply via email to