This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-1.1-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
new c4175f1495 [Fix](cherry-pick) fix sub_bitmap calculate wrong result to
return null (#14145)
c4175f1495 is described below
commit c4175f1495b6e90a5029cba4ea4f17fd2a5e32c5
Author: zhangstar333 <[email protected]>
AuthorDate: Thu Nov 10 14:18:38 2022 +0800
[Fix](cherry-pick) fix sub_bitmap calculate wrong result to return null
(#14145)
---
be/src/util/bitmap_value.h | 89 +++++++++++++++++++++++++++++++++++-----------
1 file changed, 68 insertions(+), 21 deletions(-)
diff --git a/be/src/util/bitmap_value.h b/be/src/util/bitmap_value.h
index d6791c1867..c34c0a8e80 100644
--- a/be/src/util/bitmap_value.h
+++ b/be/src/util/bitmap_value.h
@@ -1622,19 +1622,35 @@ public:
*/
int64_t sub_range(const int64_t& range_start, const int64_t& range_end,
BitmapValue* ret_bitmap) {
- 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;
+ switch (_type) {
+ case EMPTY:
+ return 0;
+ case SINGLE: {
+ //only single value, so _sv must in [range_start,range_end)
+ if (range_start <= _sv && _sv < range_end) {
+ ret_bitmap->add(_sv);
+ return 1;
} else {
- break;
+ return 0;
}
}
- return count;
+ case BITMAP: {
+ 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;
+ }
+ }
+ return count;
+ }
+ }
+ return 0;
}
/**
@@ -1645,19 +1661,35 @@ public:
*/
int64_t sub_limit(const int64_t& range_start, const int64_t&
cardinality_limit,
BitmapValue* ret_bitmap) {
- int64_t count = 0;
- for (auto it = _bitmap.begin(); it != _bitmap.end(); ++it) {
- if (*it < range_start) {
- continue;
- }
- if (count < cardinality_limit) {
- ret_bitmap->add(*it);
- ++count;
+ switch (_type) {
+ case EMPTY:
+ return 0;
+ case SINGLE: {
+ //only single value, so range_start must less than _sv
+ if (range_start > _sv) {
+ return 0;
} else {
- break;
+ ret_bitmap->add(_sv);
+ return 1;
}
}
- return count;
+ case BITMAP: {
+ int64_t count = 0;
+ for (auto it = _bitmap.begin(); it != _bitmap.end(); ++it) {
+ if (*it < range_start) {
+ continue;
+ }
+ if (count < cardinality_limit) {
+ ret_bitmap->add(*it);
+ ++count;
+ } else {
+ break;
+ }
+ }
+ return count;
+ }
+ }
+ return 0;
}
/**
@@ -1666,8 +1698,23 @@ public:
* Analog of the substring string function, but for bitmap.
*/
int64_t offset_limit(const int64_t& offset, const int64_t& limit,
BitmapValue* ret_bitmap) {
- if (std::abs(offset) >= _bitmap.cardinality()) {
+ switch (_type) {
+ case EMPTY:
return 0;
+ case SINGLE: {
+ //only single value, so offset must start 0
+ if (offset == 0) {
+ ret_bitmap->add(_sv);
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ case BITMAP: {
+ if (std::abs(offset) >= _bitmap.cardinality()) {
+ return 0;
+ }
+ }
}
int64_t abs_offset = offset;
if (offset < 0) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]