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


##########
cpp/src/arrow/device.cc:
##########
@@ -218,6 +221,9 @@ Result<std::shared_ptr<Buffer>> 
CPUMemoryManager::ViewBufferTo(
   if (!to->is_cpu()) {
     return nullptr;
   }
+  if (buf->device_type() != DeviceAllocationType::kCPU) {

Review Comment:
   Same comments here.



##########
cpp/src/arrow/device.cc:
##########
@@ -193,6 +193,9 @@ Result<std::shared_ptr<Buffer>> 
CPUMemoryManager::ViewBufferFrom(
   if (!from->is_cpu()) {
     return nullptr;
   }
+  if (buf->device_type() != DeviceAllocationType::kCPU) {
+    return std::make_shared<Buffer>(buf->address(), buf->size(), 
shared_from_this());

Review Comment:
   The problem is that the returned buffer won't keep the underlying `buf` 
alive. You should set `buf` as parent.



##########
cpp/src/arrow/c/bridge_test.cc:
##########
@@ -4302,6 +4302,16 @@ TEST_F(TestDeviceArrayRoundtrip, Primitive) {
   TestWithJSON(mm, int32(), "[4, 5, null]");
 }
 
+TEST_F(TestDeviceArrayRoundtrip, Struct) {

Review Comment:
   Should there also be a roundtrip with string/binary data?



##########
cpp/src/arrow/device.cc:
##########
@@ -193,6 +193,9 @@ Result<std::shared_ptr<Buffer>> 
CPUMemoryManager::ViewBufferFrom(
   if (!from->is_cpu()) {
     return nullptr;
   }
+  if (buf->device_type() != DeviceAllocationType::kCPU) {

Review Comment:
   Perhaps add a comment motivating this piece of code?



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