Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cpp/src/arrow/array/data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,28 +233,40 @@ DeviceAllocationType ArrayData::device_type() const {
int type = 0;
for (const auto& buf : buffers) {
if (!buf) continue;
#ifdef NDEBUG
return buf->device_type();
#else
if (type == 0) {
type = static_cast<int>(buf->device_type());
} else {
DCHECK_EQ(type, static_cast<int>(buf->device_type()));
}
#endif
}

for (const auto& child : child_data) {
if (!child) continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that, unlike buffers, this should not happen.

#ifdef NDEBUG
return child->device_type();
#else
if (type == 0) {
type = static_cast<int>(child->device_type());
} else {
DCHECK_EQ(type, static_cast<int>(child->device_type()));
}
#endif
}

if (dictionary) {
#ifdef NDEBUG
return dictionary->device_type();
#else
if (type == 0) {
type = static_cast<int>(dictionary->device_type());
} else {
DCHECK_EQ(type, static_cast<int>(dictionary->device_type()));
}
#endif
}

return type == 0 ? DeviceAllocationType::kCPU : static_cast<DeviceAllocationType>(type);
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ struct ARROW_EXPORT ArrayData {
/// \see GetNullCount
int64_t ComputeLogicalNullCount() const;

/// \brief Returns the device_type of the underlying buffers and children
/// \brief Return the device_type of the underlying buffers and children
///
/// If there are no buffers in this ArrayData object, it just returns
/// DeviceAllocationType::kCPU as a default. We also assume that all buffers
Expand Down