You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/01/06 08:09:22 UTC

[GitHub] [arrow] edponce commented on a change in pull request #12080: ARROW-15118: [C++] Avoid bitmap buffer if all inputs are all valid for Scalar Kernels

edponce commented on a change in pull request #12080:
URL: https://github.com/apache/arrow/pull/12080#discussion_r779356911



##########
File path: cpp/src/arrow/compute/exec.cc
##########
@@ -370,12 +370,15 @@ class NullPropagator {
  public:
   NullPropagator(KernelContext* ctx, const ExecBatch& batch, ArrayData* output)
       : ctx_(ctx), batch_(batch), output_(output) {
+    bool are_all_ins_valids = false;

Review comment:
       Maybe `are_all_ins_valids` --> `are_all_values_valid`

##########
File path: cpp/src/arrow/compute/exec.cc
##########
@@ -370,12 +370,15 @@ class NullPropagator {
  public:
   NullPropagator(KernelContext* ctx, const ExecBatch& batch, ArrayData* output)
       : ctx_(ctx), batch_(batch), output_(output) {
+    bool are_all_ins_valids = false;
     for (const Datum& datum : batch_.values) {
       auto null_generalization = NullGeneralization::Get(datum);
 
       if (null_generalization == NullGeneralization::ALL_NULL) {
         is_all_null_ = true;
       }
+      are_all_ins_valids =
+          are_all_ins_valids && (null_generalization == NullGeneralization::ALL_VALID);

Review comment:
       This logic is not correct bc `are_all_ins_valids` is initialized with `false` and performing and AND will always result in `false`.
   
   Also, since `null_generalization` is already checked against "not ALL_VALID", you can invert the logic to reduce the number of operations and restructure the checks.
   ```c++
   // This would also reset the bitmap if there are no buffer values, which AFAIK should not occur and if it occurs, then resetting the null bitmap also makes sense.
   bool are_all_ins_valids = true;
   for (...) {
     if (null_generalization != NullGeneralization::ALL_VALID) {
       are_all_ins_valids = false;
       if (null_generalization == NullGeneralization::ALL_NULL) {
         is_all_null_ = true;
       }
       if (datum.kind() == Datum::ARRAY) {
         arrays_with_nulls_.push_back(datum.array().get());
       }
     }
     ...
   }
   ```




-- 
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