Skip to content

Commit

Permalink
add debug check to confirm device_type in ArrayData constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroshade committed May 6, 2024
1 parent db077b0 commit 5cf3bc4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cpp/src/arrow/array/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ struct ARROW_EXPORT ArrayData {
int64_t null_count = kUnknownNullCount, int64_t offset = 0)
: ArrayData(std::move(type), length, null_count, offset) {
this->buffers = std::move(buffers);
#ifndef NDEBUG
// in debug mode, call the `device_type` function to trigger
// the DCHECKs that validate all the buffers are on the same device
ARROW_UNUSED(this->device_type());
#endif
}

ArrayData(std::shared_ptr<DataType> type, int64_t length,
Expand All @@ -110,6 +115,12 @@ struct ARROW_EXPORT ArrayData {
: ArrayData(std::move(type), length, null_count, offset) {
this->buffers = std::move(buffers);
this->child_data = std::move(child_data);
#ifndef NDEBUG
// in debug mode, call the `device_type` function to trigger
// the DCHECKs that validate all the buffers (including children)
// are on the same device
ARROW_UNUSED(this->device_type());
#endif
}

static std::shared_ptr<ArrayData> Make(std::shared_ptr<DataType> type, int64_t length,
Expand Down

0 comments on commit 5cf3bc4

Please sign in to comment.