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


##########
cpp/src/arrow/compute/kernels/vector_rolling.cc:
##########
@@ -110,16 +110,49 @@ struct ProdWindow {
   using ArgValue = typename GetViewType<ArgType>::T;
   using OutValue = typename GetOutputType<OutType>::T;
   KernelContext* ctx;
-  ArgValue prod = 1;
+  ArgValue prod = 1;  // the product of non-nan and non-zero values in the 
window
+  int64_t nan_count = 0;
+  int64_t zero_count = 0;
+
   explicit ProdWindow(KernelContext* ctx) : ctx(ctx) {}
 
   void Append(ArgValue value, Status* st) {
+    if constexpr (std::is_floating_point_v<ArgValue>) {
+      if (std::isnan(value)) {
+        nan_count++;
+        return;
+      }
+    }
+    if (value == 0) {
+      zero_count++;
+      return;
+    }

Review Comment:
   Wouldn't it be better to let the multiplication proceed and avoid this 
branch?



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