benibus commented on code in PR #36489:
URL: https://github.com/apache/arrow/pull/36489#discussion_r1260197232
##########
cpp/src/arrow/c/bridge.cc:
##########
@@ -663,6 +672,112 @@ Status ExportRecordBatch(const RecordBatch& batch, struct
ArrowArray* out,
return Status::OK();
}
+//////////////////////////////////////////////////////////////////////////
+// C device arrays
+
+Status ValidateDeviceInfo(const ArrayData& data, DeviceType* device_type,
+ int64_t* device_id) {
+ for (const auto& buf : data.buffers) {
+ if (!buf) {
+ continue;
+ }
+
+ if (*device_type == DeviceType::UNKNOWN) {
Review Comment:
Pretty sure this loop would fail to catch a discrepancy if all buffers had
`DeviceType::UNKNOWN` except for the last one.
##########
cpp/src/arrow/c/bridge.cc:
##########
@@ -663,6 +672,112 @@ Status ExportRecordBatch(const RecordBatch& batch, struct
ArrowArray* out,
return Status::OK();
}
+//////////////////////////////////////////////////////////////////////////
+// C device arrays
+
+Status ValidateDeviceInfo(const ArrayData& data, DeviceType* device_type,
+ int64_t* device_id) {
Review Comment:
Not a big deal ATM, but a `DeviceInfo` struct might be good have (not just
here, but in general), e.g:
```c++
struct DeviceInfo {
explicit DeviceInfo(DeviceType type = DeviceType::UNKNOWN, int64_t id = -1)
: type(type), id(id) {}
DeviceType type;
int64_t id;
};
```
--
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]