mapleFU commented on issue #43768:
URL: https://github.com/apache/arrow/issues/43768#issuecomment-2302124920
```c++
template <typename ArgType>
struct IndexImpl : public ScalarAggregator {
using ArgValue = typename internal::GetViewType<ArgType>::T;
Status Consume(KernelContext* ctx, const ExecSpan& batch) override {
// short-circuit
if (index >= 0 || !options.value->is_valid) {
return Status::OK();
}
const ArgValue desired =
internal::UnboxScalar<ArgType>::Unbox(*options.value);
if (batch[0].is_scalar()) {
seen = batch.length;
if (batch[0].scalar->is_valid) {
const ArgValue v =
internal::UnboxScalar<ArgType>::Unbox(*batch[0].scalar);
if (v == desired) {
index = 0;
return Status::Cancelled("Found");
}
}
return Status::OK();
}
const ArraySpan& input = batch[0].array;
seen = input.length;
int64_t i = 0;
ARROW_UNUSED(internal::VisitArrayValuesInline<ArgType>(
input,
[&](ArgValue v) -> Status {
if (v == desired) {
index = i;
return Status::Cancelled("Found");
} else {
++i;
return Status::OK();
}
},
[&]() -> Status {
++i;
return Status::OK();
}));
return Status::OK();
}
```
Besides, "index" kernel even set `seen` to input array, like it will only
handle input once..
--
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]