[fix] fix bitmap wrong result (#8478)

Fix a bug when query bitmap return wrong result, even the simplest query. 
Such as
```
CREATE TABLE `pv_bitmap_fix2` (
`dt` int(11) NULL COMMENT "",
`page` varchar(10) NULL COMMENT "",
`user_id_bitmap` bitmap BITMAP_UNION NULL COMMENT ""
) ENGINE=OLAP 
AGGREGATE KEY(`dt`, `page`) 
COMMENT "OLAP" DISTRIBUTED BY HASH(`dt`) BUCKETS 2
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2"
)

Insert any hundreds of rows of data

select count(distinct user_id_bitmap) from pv_bitmap_fix2

the result is wrong
```
This is a bug of vectorization of storage layer.
This commit is contained in:
wangbo
2022-03-16 11:39:41 +08:00
committed by GitHub
parent d39c021d71
commit b8e6c3a00c

View File

@ -63,11 +63,11 @@ public:
}
void insert_many_binary_data(char* data_array, uint32_t* len_array, uint32_t* start_offset_array, size_t num) override {
resize(num);
if constexpr (std::is_same_v<T, BitmapValue>) {
for (size_t i = 0; i < num; i++) {
uint32_t len = len_array[i];
uint32_t start_offset = start_offset_array[i];
insert_default();
BitmapValue* pvalue = &get_element(size() - 1);
if (len != 0) {
BitmapValue value;
@ -81,6 +81,7 @@ public:
for (size_t i = 0; i < num; i++) {
uint32_t len = len_array[i];
uint32_t start_offset = start_offset_array[i];
insert_default();
HyperLogLog* pvalue = &get_element(size() - 1);
if (len != 0) {
HyperLogLog value;