[Vectorized][Feature] support some bitmap functions (#8138)

This commit is contained in:
zhangstar333
2022-02-23 11:42:16 +08:00
committed by GitHub
parent 9120de205e
commit 31ab569c1d
7 changed files with 451 additions and 169 deletions

View File

@ -89,6 +89,22 @@ TEST(function_bitmap_test, function_bitmap_and_count) {
delete bitmap1;
delete bitmap2;
delete empty_bitmap;
{
InputTypeSet input_types = {TypeIndex::BitMap, TypeIndex::BitMap, TypeIndex::BitMap};
BitmapValue bitmap1({33, 1, 2019});
BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::min()});
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
auto empty_bitmap = new BitmapValue(); //test empty
DataSet data_set = {{{&bitmap1, &bitmap2, empty_bitmap}, (int64_t)0},
{{&bitmap1, &bitmap2, &bitmap3}, (int64_t)1}, //33
{{&bitmap1, &bitmap2, Null()}, Null()},
{{&bitmap1, &bitmap3, &bitmap3}, (int64_t)1}}; //33
check_function<DataTypeInt64, true>(func_name, input_types, data_set);
delete empty_bitmap;
}
}
TEST(function_bitmap_test, function_bitmap_or_count) {
@ -107,6 +123,22 @@ TEST(function_bitmap_test, function_bitmap_or_count) {
delete bitmap2;
delete bitmap3;
delete empty_bitmap;
{
InputTypeSet input_types = {TypeIndex::BitMap, TypeIndex::BitMap, TypeIndex::BitMap};
BitmapValue bitmap1({1024, 1, 2019});
BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::min()});
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()}); //18446744073709551615
auto empty_bitmap = new BitmapValue(); //test empty
DataSet data_set = {{{&bitmap1, &bitmap2, empty_bitmap}, (int64_t)5}, //0,1,33,1024,2019
{{&bitmap1, &bitmap2, &bitmap3}, (int64_t)7}, //0,1,5,33,1024,2019,18446744073709551615
{{&bitmap1, empty_bitmap, Null()}, Null()},
{{&bitmap1, &bitmap3, &bitmap3}, (int64_t)6}}; //1,5,33,1024,2019,18446744073709551615
check_function<DataTypeInt64, true>(func_name, input_types, data_set);
delete empty_bitmap;
}
}
TEST(function_bitmap_test, function_bitmap_xor_count) {
@ -127,7 +159,65 @@ TEST(function_bitmap_test, function_bitmap_xor_count) {
delete bitmap3;
delete bitmap4;
delete empty_bitmap;
{
InputTypeSet input_types = {TypeIndex::BitMap, TypeIndex::BitMap, TypeIndex::BitMap};
BitmapValue bitmap1({1024, 1, 2019});
BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::min()});
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
auto empty_bitmap = new BitmapValue(); //test empty
DataSet data_set = {{{&bitmap1, &bitmap2, empty_bitmap}, (int64_t)5}, //0,1,33,1024,2019
{{&bitmap1, &bitmap2, &bitmap3}, (int64_t)6}, //0,1,5,1024,2019,18446744073709551615
{{&bitmap1, empty_bitmap, Null()}, Null()},
{{&bitmap1, &bitmap3, &bitmap3}, (int64_t)3}}; //1,1024,2019
check_function<DataTypeInt64, true>(func_name, input_types, data_set);
delete empty_bitmap;
}
}
TEST(function_bitmap_test, function_bitmap_and_not_count) {
std::string func_name = "bitmap_and_not_count";
InputTypeSet input_types = {TypeIndex::BitMap, TypeIndex::BitMap};
BitmapValue bitmap1({1, 2, 3});
BitmapValue bitmap2({3, 4, std::numeric_limits<uint64_t>::min()});
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
auto empty_bitmap = new BitmapValue();
DataSet data_set = {{{&bitmap1, empty_bitmap}, (int64_t)3}, //1,2,3
{{&bitmap2, Null()}, Null()},
{{&bitmap2, &bitmap3}, (int64_t)3}, //0,3,4
{{&bitmap1, &bitmap2}, (int64_t)2}}; //1,2
check_function<DataTypeInt64, true>(func_name, input_types, data_set);
delete empty_bitmap;
}
TEST(function_bitmap_test, function_bitmap_has_all) {
std::string func_name = "bitmap_has_all";
InputTypeSet input_types = {TypeIndex::BitMap, TypeIndex::BitMap};
BitmapValue bitmap1(
{1, 4, 5, std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::min()});
BitmapValue bitmap2(
{4, std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::min()});
BitmapValue bitmap3 = BitmapValue({0, 1, 2});
BitmapValue bitmap4 = BitmapValue({0, 1, 2, std::numeric_limits<uint64_t>::max()});
BitmapValue bitmap5 = BitmapValue({0, 1, 2});
auto empty_bitmap1 = new BitmapValue();
auto empty_bitmap2 = new BitmapValue();
DataSet data_set = {{{&bitmap1, &bitmap2}, uint8(true)},
{{empty_bitmap1, empty_bitmap2}, uint8(true)},
{{&bitmap3, &bitmap4}, uint8(false)},
{{&bitmap4, &bitmap5}, uint8(true)},
{{Null(), empty_bitmap1}, Null()}};
check_function<DataTypeUInt8, true>(func_name, input_types, data_set);
delete empty_bitmap1;
delete empty_bitmap2;
}
} // namespace doris::vectorized
int main(int argc, char** argv) {