You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "felipecrv (via GitHub)" <gi...@apache.org> on 2023/04/14 18:10:43 UTC
[GitHub] [arrow] felipecrv opened a new issue, #35141: [C++] Add versions of IsNull/IsValid that take an ArrowType tparam so implementation can be statically dispatched
felipecrv opened a new issue, #35141:
URL: https://github.com/apache/arrow/issues/35141
### Describe the enhancement requested
#34408 introduced more branches to the implementations of `IsNull` and `IsValid` testing the type to of the array to dispatch specific implementations for a few special types. Although these branches are easy on the branch predictor, it's good to offer users that know the type ahead of time a way to eliminate those branches completely from their loops.
Proposed implementation using `if constexpr`:
```cpp
template <typename ArrowType>
bool IsNullFast(int64_t i) const {
return !IsValidFast<ArrowType>(i);
}
template <typename ArrowType>
bool IsValidFast(int64_t i) const {
if constexpr (ArrowType::type_id == Type::NA) {
return false;
} else if constexpr (ArrowType::type_id == Type::SPARSE_UNION) {
return !internal::IsNullSparseUnion(*this, i);
} else if constexpr (ArrowType::type_id == Type::DENSE_UNION) {
return !internal::IsNullDenseUnion(*this, i);
} else if constexpr (ArrowType::type_id == Type::RUN_END_ENCODED) {
return !internal::IsNullRunEndEncoded(*this, i);
} else {
if (buffers[0] != NULLPTR) {
return bit_util::GetBit(buffers[0]->data(), i + offset);
}
return null_count.load() != length;
}
}
```
### Component(s)
C++
--
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: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] felipecrv commented on issue #35141: [C++] Add versions of IsNull/IsValid that take an ArrowType tparam so implementation can be statically dispatched
Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv commented on issue #35141:
URL: https://github.com/apache/arrow/issues/35141#issuecomment-1509042393
take
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org