WillAyd commented on code in PR #45272:
URL: https://github.com/apache/arrow/pull/45272#discussion_r1920484539


##########
cpp/src/arrow/compute/kernels/codegen_internal.h:
##########
@@ -322,6 +329,47 @@ struct ArrayIterator<Type, enable_if_base_binary<Type>> {
   }
 };
 
+template <typename Type>
+struct ArrayIterator<Type, enable_if_list_type<Type>> {
+  using T = typename TypeTraits<Type>::ScalarType;
+  using ArrayT = typename TypeTraits<Type>::ArrayType;
+  using offset_type = typename Type::offset_type;
+
+  const ArraySpan& arr;
+  const offset_type* offsets;
+  offset_type cur_offset;
+  const ArraySpan& values;
+  const uint8_t* data;
+  int64_t position;
+
+  explicit ArrayIterator(const ArraySpan& arr)
+      : arr(arr),
+        offsets(reinterpret_cast<const offset_type*>(arr.buffers[1].data)),
+        cur_offset(offsets[arr.offset]),
+        values(arr.child_data[0]),
+        position(arr.offset) {}
+
+  T operator()() {
+    offset_type next_offset = offsets[++position];
+    const auto len = next_offset - cur_offset;
+    const auto null_count = values.null_count;
+    const std::shared_ptr<Buffer> nulls_buffer =
+        null_count > 0 ? *values.buffers[0].owner : nullptr;
+    std::vector<std::shared_ptr<Buffer>> bufs = {nulls_buffer, 
*values.buffers[1].owner};
+    const auto child_offset = values.offset;
+
+    // TODO: do not hard code child type. also need to be aware of 
non-primitive children
+    const auto array_data = ArrayData::Make(int32(), len, std::move(bufs), 
null_count,

Review Comment:
   Definitely do not want to hard code the data type here but I'm not sure what 
facilities can help select from the ListArray generically - do these exist 
already or would they need to be built out in this function?



-- 
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]

Reply via email to