felipecrv commented on code in PR #36256:
URL: https://github.com/apache/arrow/pull/36256#discussion_r1242413851


##########
cpp/src/arrow/compute/kernels/scalar_if_else_benchmark.cc:
##########
@@ -57,9 +57,45 @@ struct GetBytesProcessed<Type, enable_if_base_binary<Type>> {
   }
 };
 
+template <typename DataType>
+struct GetBytesProcessed<DataType, enable_if_list_like<DataType>> {
+  static int64_t Get(const std::shared_ptr<Array>& arr) {
+    using OffsetType = typename TypeTraits<DataType>::OffsetType::c_type;
+
+    int64_t total_bytes = 0;
+    if constexpr (DataType::type_id == Type::LIST ||
+                  DataType::type_id == Type::LARGE_LIST) {
+      total_bytes += (arr->length() + 1) * sizeof(OffsetType);
+    } else {
+      ADD_FAILURE() << "GetBytesProcessed dispatching not implemented for "
+                    << arr->type()->ToString();
+    }
+
+    auto child_array = std::static_pointer_cast<ListArray>(arr)->values();
+    switch (child_array->type_id()) {
+      case Type::UINT32:
+        total_bytes += GetBytesProcessed<UInt32Type>::Get(child_array);
+        break;
+      case Type::UINT64:
+        total_bytes += GetBytesProcessed<UInt64Type>::Get(child_array);
+        break;
+      case Type::STRING:
+        total_bytes += GetBytesProcessed<StringType>::Get(child_array);
+        break;
+      case Type::LARGE_STRING:
+        total_bytes += GetBytesProcessed<LargeStringType>::Get(child_array);
+        break;
+      default:
+        ADD_FAILURE() << "GetBytesProcessed dispatching not implemented for "
+                      << child_array->type()->ToString();
+        break;
+    }
+    return total_bytes;
+  }
+};

Review Comment:
   I think the size of the data is important here to differentiate between list 
array containing lists of small and big sizes.



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