You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mapleFU (via GitHub)" <gi...@apache.org> on 2023/04/17 03:35:23 UTC

[GitHub] [arrow] mapleFU commented on a diff in pull request #35149: GH-35141: [C++] Versions of IsNull/IsValid that don't branch on type

mapleFU commented on code in PR #35149:
URL: https://github.com/apache/arrow/pull/35149#discussion_r1168124493


##########
cpp/src/arrow/array/data.h:
##########
@@ -434,16 +455,36 @@ struct ARROW_EXPORT ArraySpan {
   inline bool IsValid(int64_t i) const {
     if (this->buffers[0].data != NULLPTR) {
       return bit_util::GetBit(this->buffers[0].data, i + this->offset);
+    }
+    const auto type = this->type->id();
+    if (type == Type::SPARSE_UNION) {
+      return !IsNullSparseUnion(i);
+    } else if (type == Type::DENSE_UNION) {
+      return !IsNullDenseUnion(i);
+    } else if (type == Type::RUN_END_ENCODED) {
+      return !IsNullRunEndEncoded(i);
+    }
+    return this->null_count != this->length;
+  }
+
+  template <typename ArrowType>
+  inline bool IsNullFast(int64_t i) const {
+    return !IsValidFast<ArrowType>(i);
+  }
+
+  template <typename ArrowType>
+  inline bool IsValidFast(int64_t i) const {
+    if constexpr (ArrowType::type_id == Type::NA) {

Review Comment:
   Do we need to add a DCHECK to check that `ArrowType` is equal to the real type in the 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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org