[Function] Add bitmap-xor-count function for doris (#6982)

Add bitmap-xor-count function for doris

relate to #6875
This commit is contained in:
xy720
2021-11-02 16:37:00 +08:00
committed by GitHub
parent f0a71a067b
commit aeec9c45e6
8 changed files with 190 additions and 0 deletions

View File

@ -347,6 +347,59 @@ TEST_F(BitmapFunctionsTest, bitmap_and) {
ASSERT_EQ(expected, result);
}
TEST_F(BitmapFunctionsTest, bitmap_xor) {
BitmapValue bitmap1({1024, 1, 2019});
BitmapValue bitmap2({33, 44, 2019});
StringVal bitmap_src = convert_bitmap_to_string(ctx, bitmap1);
StringVal bitmap_dst = convert_bitmap_to_string(ctx, bitmap2);
StringVal bitmap_str = BitmapFunctions::bitmap_xor(ctx, bitmap_src, bitmap_dst);
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
BigIntVal expected(4);
ASSERT_EQ(expected, result);
}
TEST_F(BitmapFunctionsTest, bitmap_xor_count) {
{
BitmapValue bitmap1({1, 2, 3});
BitmapValue bitmap2({3, 4, 5});
StringVal bitmap_src = convert_bitmap_to_string(ctx, bitmap1);
StringVal bitmap_dst = convert_bitmap_to_string(ctx, bitmap2);
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src, bitmap_dst);
BigIntVal expected(4);
ASSERT_EQ(expected, result);
}
{
BitmapValue bitmap1({1, 2, 3});
BitmapValue bitmap2({1, 2, 3});
StringVal bitmap_src = convert_bitmap_to_string(ctx, bitmap1);
StringVal bitmap_dst = convert_bitmap_to_string(ctx, bitmap2);
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src, bitmap_dst);
BigIntVal expected(0);
ASSERT_EQ(expected, result);
}
{
BitmapValue bitmap1({1, 2, 3});
BitmapValue bitmap2({4, 5, 6});
StringVal bitmap_src = convert_bitmap_to_string(ctx, bitmap1);
StringVal bitmap_dst = convert_bitmap_to_string(ctx, bitmap2);
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src, bitmap_dst);
BigIntVal expected(6);
ASSERT_EQ(expected, result);
}
}
TEST_F(BitmapFunctionsTest, bitmap_and_count) {
BitmapValue bitmap1({0, 1, 2});
BitmapValue bitmap2;