jorisvandenbossche commented on code in PR #42010:
URL: https://github.com/apache/arrow/pull/42010#discussion_r1638172658
##########
cpp/src/arrow/pretty_print.cc:
##########
@@ -413,18 +414,36 @@ Status ArrayPrinter::WriteValidityBitmap(const Array&
array) {
}
}
+Result<std::shared_ptr<Array>> CopyStartEndToCPU(const Array& arr, int window)
{
+ std::shared_ptr<Array> arr_sliced;
+ if (arr.length() > (2 * window + 1)) {
+ ARROW_ASSIGN_OR_RAISE(auto arr_start,
+ arr.Slice(0, window +
1)->CopyTo(default_cpu_memory_manager()));
+ ARROW_ASSIGN_OR_RAISE(
+ auto arr_end,
+ arr.Slice(arr.length() - window -
1)->CopyTo(default_cpu_memory_manager()));
+ ARROW_ASSIGN_OR_RAISE(arr_sliced, Concatenate({arr_start, arr_end}));
+ } else {
+ ARROW_ASSIGN_OR_RAISE(arr_sliced,
arr.CopyTo(default_cpu_memory_manager()));
Review Comment:
@pitrou I am using the slice+copy approach above in the idea of only copying
a small part of the full array to the CPU device. However, on second though, I
assume that this actually doesn't work as intended? The `Slice` is zero-copy
(just adding offsets), and I assume the `CopyTo` just naively copies all
buffers of the array in its entirety, not actually truncating and copying only
the part of the buffer that is needed?
--
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]