amol- commented on a change in pull request #11886:
URL: https://github.com/apache/arrow/pull/11886#discussion_r777976116



##########
File path: cpp/src/arrow/compute/kernels/vector_selection.cc
##########
@@ -2378,26 +2378,44 @@ struct NonZeroVisitor {
     using T = typename GetViewType<Type>::T;
     uint32_t index = 0;
 
-    VisitArrayDataInline<Type>(
-        this->array,
-        [&](T v) {
-          if (v) {
-            this->builder->UnsafeAppend(index);
-          }
-          ++index;
-        },
-        [&]() { ++index; });
+    for (ArrayDataVector::const_iterator current_array = arrays.begin();
+         current_array != arrays.end(); ++current_array) {
+      VisitArrayDataInline<Type>(
+          **current_array,
+          [&](T v) {
+            if (v) {
+              this->builder->UnsafeAppend(index);
+            }
+            ++index;
+          },
+          [&]() { ++index; });
+    }
+
     return Status::OK();
   }
 };
 
 Status IndicesNonZeroExec(KernelContext* ctx, const ExecBatch& batch, Datum* 
out) {
-  std::shared_ptr<ArrayData> array = batch[0].array();
   UInt64Builder builder;
+  ArrayDataVector arrays;
+  Datum input = batch[0];
+
+  if (input.kind() == Datum::ARRAY) {
+    std::shared_ptr<ArrayData> array = input.array();
+    RETURN_NOT_OK(builder.Reserve(array->length));
+    arrays.push_back(array);

Review comment:
       :+1: as the shared_ptrs pushed into the array are destroy once the block 
is exited, there was no need to increase references and as you mentioned we 
could easily steal the existing one.




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