paleolimbot commented on code in PR #40807:
URL: https://github.com/apache/arrow/pull/40807#discussion_r1580251600
##########
cpp/src/arrow/c/bridge.cc:
##########
@@ -2067,14 +2092,20 @@ class ExportedArrayStream {
ARROW_DISALLOW_COPY_AND_ASSIGN(PrivateData);
};
- explicit ExportedArrayStream(struct ArrowArrayStream* stream) :
stream_(stream) {}
+ explicit ExportedArrayStream(StreamType* stream) : stream_(stream) {}
Status GetSchema(struct ArrowSchema* out_schema) {
return ExportStreamSchema(reader(), out_schema);
}
- Status GetNext(struct ArrowArray* out_array) {
- return ExportStreamNext(reader(), next_batch_num(), out_array);
+ Status GetNext(ArrayType* out_array) {
+ if constexpr (std::is_same_v<ArrayType, struct ArrowArray>) {
+ return ExportStreamNext(reader(), next_batch_num(), out_array);
+ } else if constexpr (std::is_same_v<T, ChunkedArray>) {
+ return ExportDeviceStreamNext(reader(), next_batch_num(), nullptr,
out_array);
Review Comment:
Just a small vote from me that I think it might be less confusing to leave
it out of the signature for now if it is not doing anything.
##########
cpp/src/arrow/array/data.cc:
##########
@@ -224,6 +224,36 @@ int64_t ArrayData::ComputeLogicalNullCount() const {
return ArraySpan(*this).ComputeLogicalNullCount();
}
+DeviceAllocationType ArrayData::device_type() const {
+ int type = 0;
Review Comment:
Would a comment (either here or in the header) be appropriate here to
explain that this is walking the tree of buffers to ensure that all of them are
allocated on the same device?
For `type == 0` specifically, it looks like you are using this as a sentinel
for "not yet assigned"? Would it be appropriate to define this somewhere with a
descriptive name?
##########
cpp/src/arrow/c/bridge.cc:
##########
@@ -2041,6 +2041,19 @@ Status ExportStreamNext(const
std::shared_ptr<RecordBatchReader>& src, int64_t i
}
}
+Status ExportDeviceStreamNext(const std::shared_ptr<RecordBatchReader>& src,
int64_t,
Review Comment:
Maybe worth giving it a name (e.g., `int64_t i`) and a comment explaining
that to the unwary reader?
--
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]