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 2021/10/18 17:43:47 UTC

[GitHub] [arrow] bkietz commented on a change in pull request #11350: ARROW-14211: [C++][Compute] Fixing thread sanitizer problems in hash join node

bkietz commented on a change in pull request #11350:
URL: https://github.com/apache/arrow/pull/11350#discussion_r731151891



##########
File path: cpp/src/arrow/compute/exec/hash_join.cc
##########
@@ -636,6 +637,47 @@ class HashJoinBasicImpl : public HashJoinImpl {
     return ScanHashTable(thread_index);
   }
 
+  void InitHasMatchIfNeeded(ThreadLocalState* local_state) {
+    if (local_state->is_has_match_initialized) {
+      return;
+    }
+    if (!hash_table_empty_) {
+      int32_t num_rows = hash_table_keys_.num_rows();
+      local_state->has_match.resize(BitUtil::BytesForBits(num_rows));
+      memset(local_state->has_match.data(), 0, BitUtil::BytesForBits(num_rows));
+    }
+    local_state->is_has_match_initialized = true;
+  }
+
+  void MergeHasMatch() {
+    if (hash_table_empty_) {
+      return;
+    }
+
+    int32_t num_rows = hash_table_keys_.num_rows();
+    has_match_.resize(BitUtil::BytesForBits(num_rows));
+    memset(has_match_.data(), 0, BitUtil::BytesForBits(num_rows));
+
+    for (size_t tid = 0; tid < local_states_.size(); ++tid) {
+      if (!local_states_[tid].is_initialized) {
+        continue;
+      }
+      if (!local_states_[tid].is_has_match_initialized) {
+        continue;
+      }
+      uint8_t* dst8 = has_match_.data();
+      const uint8_t* src8 = local_states_[tid].has_match.data();
+      uint64_t* dst64 = reinterpret_cast<uint64_t*>(dst8);
+      const uint64_t* src64 = reinterpret_cast<const uint64_t*>(src8);
+      for (int32_t i = 0; i < num_rows / 64; ++i) {
+        dst64[i] |= src64[i];
+      }
+      for (int32_t i = num_rows / 64 * 8; i < BitUtil::CeilDiv(num_rows, 8); ++i) {
+        dst8[i] |= src8[i];
+      }

Review comment:
       ```suggestion
         arrow::internal::BitmapOr(has_match_.data(), 0, local_states_[tid].has_match.data(),
                                   0, num_rows, has_match_.data(), 0);
   ```




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