This is an automated email from the ASF dual-hosted git repository.
laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 2acc2878d [common] minor optimization on ComputeHashBuckets
2acc2878d is described below
commit 2acc2878d0c0b70ba22e26fe4a186d412d8ed74a
Author: Alexey Serbin <[email protected]>
AuthorDate: Mon Jul 31 10:18:16 2023 -0700
[common] minor optimization on ComputeHashBuckets
It's enough to find the very first 'false' element in the boolean vector
of selected predicate values to decide whether to continue with the code
in PartitionPruner::ComputeHashBuckets(). Also, using std::all_of()
might employ optimizations in the specialized implementation of
std::vector<bool> container, if there were any.
In addition, I looked at the possibility to use boost::dynamic_bitset
instead of std::vector<bool> for PartitionPruner::PruneHashComponent()
in this context, but it seems PruneHashComponent() isn't exactly at
hot paths of reading and writing data.
This is a follow-up to 5d6774b1022f26d33abd6cc9fb9950749084942
Change-Id: Iecd9a739f408646c0dab74727f919e4f6ce3ce7e
Reviewed-on: http://gerrit.cloudera.org:8080/20288
Tested-by: Kudu Jenkins
Reviewed-by: Mahesh Reddy <[email protected]>
Reviewed-by: Yifan Zhang <[email protected]>
Reviewed-by: Yuqi Du <[email protected]>
Reviewed-by: Yingchun Lai <[email protected]>
---
src/kudu/common/partition_pruner.cc | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/kudu/common/partition_pruner.cc
b/src/kudu/common/partition_pruner.cc
index a5bb56cb9..af01a69ae 100644
--- a/src/kudu/common/partition_pruner.cc
+++ b/src/kudu/common/partition_pruner.cc
@@ -221,14 +221,13 @@ void PartitionPruner::ComputeHashBuckets(const Schema&
schema, // NOLINT(misc-no
vector<bool>* hash_bucket_bitset) {
DCHECK(predicate_values_selected);
DCHECK(hash_bucket_bitset);
- bool all_hash_bucket_needed = true;
- for (const auto b : *hash_bucket_bitset) {
- all_hash_bucket_needed &= b;
- }
- if (all_hash_bucket_needed) {
+
+ if (std::all_of(hash_bucket_bitset->begin(),
+ hash_bucket_bitset->end(),
+ [](bool b) { return b; })) {
return;
}
- size_t level = predicate_values_selected->size();
+ const size_t level = predicate_values_selected->size();
DCHECK_EQ(hash_dimension.column_ids.size(), predicate_values_list.size());
if (level == hash_dimension.column_ids.size()) {
string encoded_string;