Skip to content

[enhancement]optimize some bitmap function logic#17218

Closed
ucasfl wants to merge 2 commits intoapache:masterfrom
ucasfl:bitmap
Closed

[enhancement]optimize some bitmap function logic#17218
ucasfl wants to merge 2 commits intoapache:masterfrom
ucasfl:bitmap

Conversation

@ucasfl
Copy link
Contributor

@ucasfl ucasfl commented Feb 28, 2023

Proposed changes

Issue Number: close #xxx

Optimize logic of bitmap function bitmap_subset_in_range and bitmap_subset_limit: pass arguments by value for basic type, and reduce branch stantement for better vectorization.

Problem summary

Describe your changes.

Checklist(Required)

  • Does it affect the original behavior
  • Has unit tests been added
  • Has document been added or modified
  • Does it need to update dependencies
  • Is this PR support rollback (If NO, please explain WHY)

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

Signed-off-by: flynn <fenglv15@mails.ucas.ac.cn>
@ucasfl ucasfl changed the title [Optimize]optimize some bitmap function logic [enhancement]optimize some bitmap function logic Feb 28, 2023
*/
int64_t sub_range(const int64_t& range_start, const int64_t& range_end,
BitmapValue* ret_bitmap) {
int64_t sub_range(int64_t range_start, int64_t range_end, BitmapValue* ret_bitmap) {
Copy link
Contributor Author

@ucasfl ucasfl Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's prefer pass by value than pass by const reference for basic data type.

@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Comment on lines 1712 to 1720
auto it = _bitmap.begin();
for (; it != _bitmap.end() && *it < range_start;) {
++it;
}

int64_t count = 0;
for (auto it = _bitmap.begin(); it != _bitmap.end(); ++it) {
if (*it < range_start) {
continue;
}
if (*it < range_end) {
ret_bitmap->add(*it);
++count;
} else {
break;
}
for (; it != _bitmap.end() && *it < range_end; ++it) {
ret_bitmap->add(*it);
++count;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reducing branch statement for better vectorization.

@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: flynn <fenglv15@mails.ucas.ac.cn>
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@morningman
Copy link
Contributor

Please describe your change

@ucasfl
Copy link
Contributor Author

ucasfl commented Mar 1, 2023

Please describe your change

done.

@ucasfl ucasfl closed this Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants