edponce commented on a change in pull request #10896:
URL: https://github.com/apache/arrow/pull/10896#discussion_r685350549
##########
File path: cpp/src/arrow/compute/kernels/scalar_validity.cc
##########
@@ -76,6 +77,22 @@ struct IsInfOperator {
struct IsNullOperator {
static Status Call(KernelContext* ctx, const Scalar& in, Scalar* out) {
+ bool is_nan_value = false;
+ bool is_floating = false;
+ if (in.type == float32()) {
+ is_nan_value = std::isnan(internal::UnboxScalar<FloatType>::Unbox(in));
+ is_floating = true;
+ } else if (in.type == float64()) {
+ is_nan_value = std::isnan(internal::UnboxScalar<DoubleType>::Unbox(in));
+ is_floating = true;
+ }
Review comment:
I would add a check for validity prior to checking float type to prevent
unnecessary checks when null bit is enabled. Nit: Also, I would change logic to
to use `&&` instead of `||`, feels a bit more readable (and less characters).
```c++
bool* out_value = &checked_cast<BooleanScalar*>(out)->value;
if (in.is_valid) {
switch (in.type->id()) {
case Type::FLOAT:
*out_value = options.nan_is_null &&
std::isnan(internal::UnboxScalar<FloatType>::Unbox(in));
case Type::DOUBLE:
*out_value = options.nan_is_null &&
std::isnan(internal::UnboxScalar<DoubleType>::Unbox(in));
default:
*out_value = false;
}
} else {
*out_value = true;
}
```
--
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]