nirandaperera commented on a change in pull request #11886:
URL: https://github.com/apache/arrow/pull/11886#discussion_r777588759
##########
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:
nit `arrays.push_back(std::move(array))`
--
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]