From 09e1b0d0e77738bd6974922c60e921906c41942d Mon Sep 17 00:00:00 2001 From: "hengjiang.ly" Date: Wed, 17 Jul 2024 18:46:28 -0700 Subject: [PATCH] fix numProbedBuckets (#10433) Summary: When searching for keys in a bucket, if the tag hits multiple keys, the accumulation logic of numProbedBucket may be wrong. Pull Request resolved: https://github.com/facebookincubator/velox/pull/10433 Reviewed By: Yuhta Differential Revision: D59872520 Pulled By: kevinwilfong fbshipit-source-id: 2995fcfe97ea1734478a4552c0bb366a5611fe98 --- velox/exec/HashTable.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/velox/exec/HashTable.cpp b/velox/exec/HashTable.cpp index 02ff92e688c1..feb7e1fd6e42 100644 --- a/velox/exec/HashTable.cpp +++ b/velox/exec/HashTable.cpp @@ -231,8 +231,8 @@ class ProbeState { return group_; } const auto kEmptyGroup = BaseHashTable::TagVector::broadcast(kEmptyTag); - for (int64_t numProbedBuckets = 0; numProbedBuckets < table.numBuckets(); - ++numProbedBuckets) { + int64_t numProbedBuckets = 0; + while (numProbedBuckets < table.numBuckets()) { if (!hits_) { const uint16_t empty = simd::toBitMask(tagsInTable_ == kEmptyGroup); if (empty) { @@ -248,6 +248,7 @@ class ProbeState { continue; } bucketOffset_ = table.nextBucketOffset(bucketOffset_); + ++numProbedBuckets; tagsInTable_ = BaseHashTable::loadTags( reinterpret_cast(table.table_), bucketOffset_); hits_ = simd::toBitMask(tagsInTable_ == wantedTags_) & kFullMask;