You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2021/12/26 03:03:32 UTC
[incubator-doris] branch master updated: [feature](function) support bitmap_union/intersect have more columns parameters (#7379)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 0c15473 [feature](function) support bitmap_union/intersect have more columns parameters (#7379)
0c15473 is described below
commit 0c154733e0d697773f5f1af990eb059ff6ef9af0
Author: zhangstar333 <87...@users.noreply.github.com>
AuthorDate: Sun Dec 26 11:03:20 2021 +0800
[feature](function) support bitmap_union/intersect have more columns parameters (#7379)
support multi bitmap parameter for all bitmap aggregation function
---
be/src/exprs/bitmap_function.cpp | 156 +++++++++++-
be/src/exprs/bitmap_function.h | 17 +-
be/test/exprs/bitmap_function_test.cpp | 270 +++++++++++++++++++++
.../sql-functions/bitmap-functions/bitmap_and.md | 32 ++-
.../bitmap-functions/bitmap_and_count.md | 25 +-
.../sql-functions/bitmap-functions/bitmap_or.md | 32 ++-
.../bitmap-functions/bitmap_or_count.md | 16 +-
.../sql-functions/bitmap-functions/bitmap_xor.md | 25 +-
.../bitmap-functions/bitmap_xor_count.md | 25 +-
.../sql-functions/bitmap-functions/bitmap_and.md | 30 ++-
.../bitmap-functions/bitmap_and_count.md | 25 +-
.../sql-functions/bitmap-functions/bitmap_or.md | 32 ++-
.../bitmap-functions/bitmap_or_count.md | 18 +-
.../sql-functions/bitmap-functions/bitmap_xor.md | 25 +-
.../bitmap-functions/bitmap_xor_count.md | 25 +-
gensrc/script/doris_builtins_functions.py | 18 ++
16 files changed, 747 insertions(+), 24 deletions(-)
diff --git a/be/src/exprs/bitmap_function.cpp b/be/src/exprs/bitmap_function.cpp
index 3cbeab1..aa68880 100644
--- a/be/src/exprs/bitmap_function.cpp
+++ b/be/src/exprs/bitmap_function.cpp
@@ -473,6 +473,31 @@ StringVal BitmapFunctions::bitmap_or(FunctionContext* ctx, const StringVal& lhs,
return serialize(ctx, &bitmap);
}
+StringVal BitmapFunctions::bitmap_or(FunctionContext* ctx, const StringVal& lhs,
+ int num_args, const StringVal* bitmap_strs) {
+ DCHECK_GE(num_args, 1);
+ if (lhs.is_null || bitmap_strs->is_null) {
+ return StringVal::null();
+ }
+ BitmapValue bitmap;
+ if (lhs.len == 0) {
+ bitmap |= *reinterpret_cast<BitmapValue*>(lhs.ptr);
+ } else {
+ bitmap |= BitmapValue((char*)lhs.ptr);
+ }
+ for (int i = 0; i < num_args; ++i) {
+ if (bitmap_strs[i].is_null) {
+ return StringVal::null();
+ }
+ if (bitmap_strs[i].len == 0) {
+ bitmap |= *reinterpret_cast<BitmapValue*>(bitmap_strs[i].ptr);
+ } else {
+ bitmap |= BitmapValue((char*)bitmap_strs[i].ptr);
+ }
+ }
+ return serialize(ctx, &bitmap);
+}
+
StringVal BitmapFunctions::bitmap_and(FunctionContext* ctx, const StringVal& lhs,
const StringVal& rhs) {
if (lhs.is_null || rhs.is_null) {
@@ -492,6 +517,32 @@ StringVal BitmapFunctions::bitmap_and(FunctionContext* ctx, const StringVal& lhs
}
return serialize(ctx, &bitmap);
}
+
+StringVal BitmapFunctions::bitmap_and(FunctionContext* ctx, const StringVal& lhs,
+ int num_args, const StringVal* bitmap_strs) {
+ DCHECK_GE(num_args, 1);
+ if (lhs.is_null || bitmap_strs->is_null) {
+ return StringVal::null();
+ }
+ BitmapValue bitmap;
+ if (lhs.len == 0) {
+ bitmap |= *reinterpret_cast<BitmapValue*>(lhs.ptr);
+ } else {
+ bitmap |= BitmapValue((char*)lhs.ptr);
+ }
+ for (int i = 0; i < num_args; ++i) {
+ if (bitmap_strs[i].is_null) {
+ return StringVal::null();
+ }
+ if (bitmap_strs[i].len == 0) {
+ bitmap &= *reinterpret_cast<BitmapValue*>(bitmap_strs[i].ptr);
+ } else {
+ bitmap &= BitmapValue((char*)bitmap_strs[i].ptr);
+ }
+ }
+ return serialize(ctx, &bitmap);
+}
+
BigIntVal BitmapFunctions::bitmap_and_count(FunctionContext* ctx, const StringVal& lhs,
const StringVal& rhs) {
if (lhs.is_null || rhs.is_null) {
@@ -511,6 +562,32 @@ BigIntVal BitmapFunctions::bitmap_and_count(FunctionContext* ctx, const StringVa
}
}
+BigIntVal BitmapFunctions::bitmap_and_count(FunctionContext* ctx, const StringVal& lhs, int num_args,
+ const StringVal* bitmap_strs) {
+ DCHECK_GE(num_args, 1);
+ if (lhs.is_null || bitmap_strs->is_null) {
+ return BigIntVal::null();
+ }
+ BitmapValue bitmap;
+ if (lhs.len == 0) {
+ bitmap |= *reinterpret_cast<BitmapValue*>(lhs.ptr);
+ } else {
+ bitmap |= BitmapValue((char*)lhs.ptr);
+ }
+
+ for (int i = 0; i < num_args; i++) {
+ if (bitmap_strs[i].is_null) {
+ return BigIntVal::null();
+ }
+ if (bitmap_strs[i].len == 0) {
+ bitmap &= *reinterpret_cast<BitmapValue*>(bitmap_strs[i].ptr);
+ } else {
+ bitmap &= BitmapValue((char*)bitmap_strs[i].ptr);
+ }
+ }
+ return {static_cast<int64_t>(bitmap.cardinality())};
+}
+
BigIntVal BitmapFunctions::bitmap_or_count(FunctionContext* ctx, const StringVal& lhs,
const StringVal& rhs) {
if (lhs.is_null || rhs.is_null) {
@@ -530,6 +607,32 @@ BigIntVal BitmapFunctions::bitmap_or_count(FunctionContext* ctx, const StringVal
}
}
+BigIntVal BitmapFunctions::bitmap_or_count(FunctionContext* ctx, const StringVal& lhs, int num_args,
+ const StringVal* bitmap_strs) {
+ DCHECK_GE(num_args, 1);
+ if (lhs.is_null || bitmap_strs->is_null) {
+ return BigIntVal::null();
+ }
+ BitmapValue bitmap;
+ if (lhs.len == 0) {
+ bitmap |= *reinterpret_cast<BitmapValue*>(lhs.ptr);
+ } else {
+ bitmap |= BitmapValue((char*)lhs.ptr);
+ }
+
+ for (int i = 0; i < num_args; i++) {
+ if (bitmap_strs[i].is_null) {
+ return BigIntVal::null();
+ }
+ if (bitmap_strs[i].len == 0) {
+ bitmap |= *reinterpret_cast<BitmapValue*>(bitmap_strs[i].ptr);
+ } else {
+ bitmap |= BitmapValue((char*)bitmap_strs[i].ptr);
+ }
+ }
+ return {static_cast<int64_t>(bitmap.cardinality())};
+}
+
StringVal BitmapFunctions::bitmap_xor(FunctionContext* ctx, const StringVal& lhs,
const StringVal& rhs) {
if (lhs.is_null || rhs.is_null) {
@@ -550,6 +653,31 @@ StringVal BitmapFunctions::bitmap_xor(FunctionContext* ctx, const StringVal& lhs
return serialize(ctx, &bitmap);
}
+StringVal BitmapFunctions::bitmap_xor(FunctionContext* ctx, const StringVal& lhs,
+ int num_args, const StringVal* bitmap_strs) {
+ DCHECK_GE(num_args, 1);
+ if (lhs.is_null || bitmap_strs->is_null) {
+ return StringVal::null();
+ }
+ BitmapValue bitmap;
+ if (lhs.len == 0) {
+ bitmap |= *reinterpret_cast<BitmapValue*>(lhs.ptr);
+ } else {
+ bitmap |= BitmapValue((char*)lhs.ptr);
+ }
+ for (int i = 0; i < num_args; ++i) {
+ if (bitmap_strs[i].is_null) {
+ return StringVal::null();
+ }
+ if (bitmap_strs[i].len == 0) {
+ bitmap ^= *reinterpret_cast<BitmapValue*>(bitmap_strs[i].ptr);
+ } else {
+ bitmap ^= BitmapValue((char*)bitmap_strs[i].ptr);
+ }
+ }
+ return serialize(ctx, &bitmap);
+}
+
BigIntVal BitmapFunctions::bitmap_xor_count(FunctionContext* ctx, const StringVal& lhs,
const StringVal& rhs) {
if (lhs.is_null || rhs.is_null) {
@@ -569,6 +697,32 @@ BigIntVal BitmapFunctions::bitmap_xor_count(FunctionContext* ctx, const StringVa
}
}
+BigIntVal BitmapFunctions::bitmap_xor_count(FunctionContext* ctx, const StringVal& lhs, int num_args,
+ const StringVal* bitmap_strs) {
+ DCHECK_GE(num_args, 1);
+ if (lhs.is_null || bitmap_strs->is_null) {
+ return BigIntVal::null();
+ }
+ BitmapValue bitmap;
+ if (lhs.len == 0) {
+ bitmap |= *reinterpret_cast<BitmapValue*>(lhs.ptr);
+ } else {
+ bitmap |= BitmapValue((char*)lhs.ptr);
+ }
+
+ for (int i = 0; i < num_args; i++) {
+ if (bitmap_strs[i].is_null) {
+ return BigIntVal::null();
+ }
+ if (bitmap_strs[i].len == 0) {
+ bitmap ^= *reinterpret_cast<BitmapValue*>(bitmap_strs[i].ptr);
+ } else {
+ bitmap ^= BitmapValue((char*)bitmap_strs[i].ptr);
+ }
+ }
+ return {static_cast<int64_t>(bitmap.cardinality())};
+}
+
StringVal BitmapFunctions::bitmap_not(FunctionContext* ctx, const StringVal& lhs,
const StringVal& rhs) {
if (lhs.is_null || rhs.is_null) {
@@ -1097,4 +1251,4 @@ template StringVal BitmapFunctions::orthogonal_bitmap_intersect_count_serialize<
FunctionContext* ctx, const StringVal& src);
template StringVal BitmapFunctions::orthogonal_bitmap_intersect_count_serialize<StringValue>(
FunctionContext* ctx, const StringVal& src);
-} // namespace doris
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/exprs/bitmap_function.h b/be/src/exprs/bitmap_function.h
index c58d28f..f2cee64 100644
--- a/be/src/exprs/bitmap_function.h
+++ b/be/src/exprs/bitmap_function.h
@@ -76,6 +76,21 @@ public:
static StringVal bitmap_and_not(FunctionContext* ctx, const StringVal& src,
const StringVal& dst);
+ //TODO: this functions support variable parameter, but in order to version compatible
+ //so have not remove old functions, and now is the version of 0.15, in the future could remove that functions
+ static StringVal bitmap_or(FunctionContext* ctx, const StringVal& lhs, int num_args,
+ const StringVal* bitmap_strs);
+ static StringVal bitmap_and(FunctionContext* ctx, const StringVal& lhs, int num_args,
+ const StringVal* bitmap_strs);
+ static StringVal bitmap_xor(FunctionContext* ctx, const StringVal& lhs, int num_args,
+ const StringVal* bitmap_strs);
+ static BigIntVal bitmap_or_count(FunctionContext* ctx, const StringVal& lhs, int num_args,
+ const StringVal* bitmap_strs);
+ static BigIntVal bitmap_and_count(FunctionContext* ctx, const StringVal& lhs, int num_args,
+ const StringVal* bitmap_strs);
+ static BigIntVal bitmap_xor_count(FunctionContext* ctx, const StringVal& lhs, int num_args,
+ const StringVal* bitmap_strs);
+
static StringVal bitmap_to_string(FunctionContext* ctx, const StringVal& input);
// Convert a comma separated string to a Bitmap
// Example:
@@ -141,4 +156,4 @@ public:
const StringVal& src);
};
} // namespace doris
-#endif //DORIS_BE_SRC_QUERY_EXPRS_BITMAP_FUNCTION_H
+#endif //DORIS_BE_SRC_QUERY_EXPRS_BITMAP_FUNCTION_H
\ No newline at end of file
diff --git a/be/test/exprs/bitmap_function_test.cpp b/be/test/exprs/bitmap_function_test.cpp
index 49642e3..346a841 100644
--- a/be/test/exprs/bitmap_function_test.cpp
+++ b/be/test/exprs/bitmap_function_test.cpp
@@ -333,6 +333,43 @@ TEST_F(BitmapFunctionsTest, bitmap_or) {
ASSERT_EQ(expected, result);
}
+TEST_F(BitmapFunctionsTest, bitmap_or_variable) {
+ {
+ 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()});
+ BitmapValue bitmap_empty; //test empty
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_src4 = convert_bitmap_to_string(ctx, bitmap_empty);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, bitmap_src4};
+
+ StringVal bitmap_result = BitmapFunctions::bitmap_or(ctx, bitmap_src1, 3, bitmap_strs);
+ BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
+
+ BigIntVal expected(7);//0,1,5,33,1024,2019,18446744073709551615
+ ASSERT_EQ(expected, result);
+ }
+ {
+ 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()});
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, StringVal::null()}; //test null
+
+ StringVal bitmap_result = BitmapFunctions::bitmap_or(ctx, bitmap_src1, 3, bitmap_strs);
+ BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
+
+ BigIntVal expected(0);
+ ASSERT_EQ(expected, result);
+ }
+}
+
TEST_F(BitmapFunctionsTest, bitmap_and) {
BitmapValue bitmap1({1024, 1, 2019});
BitmapValue bitmap2({33, 44, 2019});
@@ -347,6 +384,59 @@ TEST_F(BitmapFunctionsTest, bitmap_and) {
ASSERT_EQ(expected, result);
}
+TEST_F(BitmapFunctionsTest, bitmap_and_variable) {
+ {
+ BitmapValue bitmap1({1024, 1, 0});
+ BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::max()});
+ BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::min()});
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_strs[2] = {bitmap_src2, bitmap_src3};
+
+ StringVal bitmap_result = BitmapFunctions::bitmap_and(ctx, bitmap_src1, 2, bitmap_strs);
+ BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
+
+ BigIntVal expected(1);//0
+ ASSERT_EQ(expected, result);
+ }
+ {
+ 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()});
+ BitmapValue bitmap_empty; //test empty
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_src4 = convert_bitmap_to_string(ctx, bitmap_empty);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, bitmap_src4};
+
+ StringVal bitmap_result = BitmapFunctions::bitmap_and(ctx, bitmap_src1, 3, bitmap_strs);
+ BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
+
+ BigIntVal expected(0);
+ ASSERT_EQ(expected, result);
+ }
+ {
+ 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()});
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, StringVal::null()}; //test null
+
+ StringVal bitmap_result = BitmapFunctions::bitmap_and(ctx, bitmap_src1, 3, bitmap_strs);
+ BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
+
+ BigIntVal expected(0);
+ ASSERT_EQ(expected, result);
+ }
+}
+
TEST_F(BitmapFunctionsTest, bitmap_xor) {
BitmapValue bitmap1({1024, 1, 2019});
BitmapValue bitmap2({33, 44, 2019});
@@ -361,6 +451,59 @@ TEST_F(BitmapFunctionsTest, bitmap_xor) {
ASSERT_EQ(expected, result);
}
+TEST_F(BitmapFunctionsTest, bitmap_xor_variable) {
+ {
+ BitmapValue bitmap1({1024, 1, 0});
+ BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::max()});
+ BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::min()});
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_strs[2] = {bitmap_src2, bitmap_src3};
+
+ StringVal bitmap_result = BitmapFunctions::bitmap_xor(ctx, bitmap_src1, 2, bitmap_strs);
+ BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
+
+ BigIntVal expected(5); //0,1,5,1024,18446744073709551615
+ ASSERT_EQ(expected, result);
+ }
+ {
+ 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()});
+ BitmapValue bitmap_empty; //test empty
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_src4 = convert_bitmap_to_string(ctx, bitmap_empty);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, bitmap_src4};
+
+ StringVal bitmap_result = BitmapFunctions::bitmap_xor(ctx, bitmap_src1, 3, bitmap_strs);
+ BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
+
+ BigIntVal expected(6); //0,1,5,1024,2019,18446744073709551615
+ ASSERT_EQ(expected, result);
+ }
+ {
+ 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()});
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, StringVal::null()}; //test null
+
+ StringVal bitmap_result = BitmapFunctions::bitmap_xor(ctx, bitmap_src1, 3, bitmap_strs);
+ BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
+
+ BigIntVal expected(0);
+ ASSERT_EQ(expected, result);
+ }
+}
+
TEST_F(BitmapFunctionsTest, bitmap_xor_count) {
{
BitmapValue bitmap1({1, 2, 3});
@@ -400,6 +543,54 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_count) {
}
}
+TEST_F(BitmapFunctionsTest, bitmap_xor_count_variable) {
+ {
+ BitmapValue bitmap1({1024, 1, 0});
+ BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::max()});
+ BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::min()});
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_strs[2] = {bitmap_src2, bitmap_src3};
+
+ BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src1, 2, bitmap_strs);
+
+ BigIntVal expected(5); //0,1,5,1024,18446744073709551615
+ ASSERT_EQ(expected, result);
+ }
+ {
+ 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()});
+ BitmapValue bitmap_empty; //test empty
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_src4 = convert_bitmap_to_string(ctx, bitmap_empty);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, bitmap_src4};
+
+ BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src1, 3, bitmap_strs);
+
+ BigIntVal expected(6); //0,1,5,1024,2019,18446744073709551615
+ ASSERT_EQ(expected, result);
+ }
+ {
+ 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()});
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, StringVal::null()}; //test null
+
+ BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src1, 3, bitmap_strs);
+ ASSERT_EQ(BigIntVal::null(), result);
+ }
+}
+
TEST_F(BitmapFunctionsTest, bitmap_xor_count_64) {
{
BitmapValue bitmap1({14001230000000000501ull, 2, 1404560000000000503ull});
@@ -465,6 +656,52 @@ TEST_F(BitmapFunctionsTest, bitmap_and_count) {
ASSERT_EQ(1, result.val);
}
+TEST_F(BitmapFunctionsTest, bitmap_and_count_variable) {
+ {
+ BitmapValue bitmap1({1024, 1, 0});
+ BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::max()});
+ BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::min()});
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_strs[2] = {bitmap_src2, bitmap_src3};
+
+ BigIntVal result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, 2, bitmap_strs);
+ BigIntVal expected(1);//0
+ ASSERT_EQ(expected, result);
+ }
+ {
+ 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()});
+ BitmapValue bitmap_empty; //test empty
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_src4 = convert_bitmap_to_string(ctx, bitmap_empty);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, bitmap_src4};
+
+ BigIntVal result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, 3, bitmap_strs);
+ BigIntVal expected(0);
+ ASSERT_EQ(expected, result);
+ }
+ {
+ 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()});
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, StringVal::null()}; //test null
+
+ BigIntVal result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, 3, bitmap_strs);
+ ASSERT_EQ(BigIntVal::null(), result);
+ }
+}
+
TEST_F(BitmapFunctionsTest, bitmap_and_count_64) {
BitmapValue bitmap1({14333000000000000501ull, 2, 1454100000000000503ull});
BitmapValue bitmap2;
@@ -519,6 +756,39 @@ TEST_F(BitmapFunctionsTest, bitmap_or_count) {
ASSERT_EQ(5, result.val);
}
+TEST_F(BitmapFunctionsTest, bitmap_or_count_variable) {
+ {
+ 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()});
+ BitmapValue bitmap_empty; //test empty
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_src4 = convert_bitmap_to_string(ctx, bitmap_empty);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, bitmap_src4};
+
+ BigIntVal result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, 3, bitmap_strs);
+
+ BigIntVal expected(7);//0,1,5,33,1024,2019,18446744073709551615
+ ASSERT_EQ(expected, result);
+ }
+ {
+ 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()});
+
+ StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
+ StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
+ StringVal bitmap_src3 = convert_bitmap_to_string(ctx, bitmap3);
+ StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, StringVal::null()}; //test null
+
+ BigIntVal result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, 3, bitmap_strs);
+ ASSERT_EQ(BigIntVal::null(), result);
+ }
+}
+
TEST_F(BitmapFunctionsTest, bitmap_or_count_64) {
BitmapValue bitmap1({14087600000000000501ull, 2, 1234500000000000503ull});
BitmapValue bitmap2;
diff --git a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_and.md b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_and.md
index a7a56cb..73c2913 100644
--- a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_and.md
+++ b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_and.md
@@ -28,9 +28,9 @@ under the License.
## description
### Syntax
-`BITMAP BITMAP_AND(BITMAP lhs, BITMAP rhs)`
+`BITMAP BITMAP_AND(BITMAP lhs, BITMAP rhs, ...)`
-Compute intersection of two input bitmaps, return the new bitmap.
+Compute intersection of two or more input bitmaps, return the new bitmap.
## example
@@ -48,6 +48,34 @@ mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt;
+------+
| 1 |
+------+
+
+MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1)));
++----------------------------------------------------------+
+| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) |
++----------------------------------------------------------+
+| 1 |
++----------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
++-----------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
++-----------------------------------------------------------------------------------------------------------------------+
+| 1,2 |
++-----------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()));
++---------------------------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) |
++---------------------------------------------------------------------------------------------------------------------------------------+
+| |
++---------------------------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL));
++-----------------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) |
++-----------------------------------------------------------------------------------------------------------------------------+
+| NULL |
++-----------------------------------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_and_count.md b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_and_count.md
index 3736bf3..84c30c8 100644
--- a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_and_count.md
+++ b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_and_count.md
@@ -28,9 +28,9 @@ under the License.
## description
### Syntax
-`BigIntVal bitmap_and_count(BITMAP lhs, BITMAP rhs)`
+`BigIntVal bitmap_and_count(BITMAP lhs, BITMAP rhs, ...)`
-Calculate the intersection of two input bitmaps and return the number of intersections.
+Calculate the intersection of two or more input bitmaps and return the number of intersections.
## example
@@ -56,6 +56,27 @@ MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3
+----------------------------------------------------------------------------+
| 1 |
+----------------------------------------------------------------------------+
+
+MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'));
++-------------------------------------------------------------------------------------------------------------+
+| (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
++-------------------------------------------------------------------------------------------------------------+
+| 2 |
++-------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty());
++-----------------------------------------------------------------------------------------------------------------------------+
+| (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) |
++-----------------------------------------------------------------------------------------------------------------------------+
+| 0 |
++-----------------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL);
++-------------------------------------------------------------------------------------------------------------------+
+| (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) |
++-------------------------------------------------------------------------------------------------------------------+
+| NULL |
++-------------------------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_or.md b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_or.md
index 77c4441..e720bb0 100644
--- a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_or.md
+++ b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_or.md
@@ -28,9 +28,9 @@ under the License.
## description
### Syntax
-`BITMAP BITMAP_OR(BITMAP lhs, BITMAP rhs)`
+`BITMAP BITMAP_OR(BITMAP lhs, BITMAP rhs, ...)`
-Compute union of two input bitmaps, returns the new bitmap.
+Compute union of two or more input bitmaps, returns the new bitmap.
## example
@@ -48,6 +48,34 @@ mysql> select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(1))) cnt;
+------+
| 1 |
+------+
+
+MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2)));
++---------------------------------------------------------+
+| bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2))) |
++---------------------------------------------------------+
+| 1,2 |
++---------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), NULL));
++--------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), NULL)) |
++--------------------------------------------------------------------------------------------+
+| NULL |
++--------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2),to_bitmap(10),to_bitmap(0),bitmap_empty()));
++------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), bitmap_empty())) |
++------------------------------------------------------------------------------------------------------+
+| 0,1,2,10 |
++------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_or(to_bitmap(10), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) ;
++--------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_or(to_bitmap(10), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
++--------------------------------------------------------------------------------------------------------+
+| 1,2,3,4,5,10 |
++--------------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_or_count.md b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_or_count.md
index f296f48..b3230d3 100644
--- a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_or_count.md
+++ b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_or_count.md
@@ -30,7 +30,7 @@ under the License.
`BigIntVal bitmap_or_count(BITMAP lhs, BITMAP rhs)`
-Calculates the union of two input bitmaps and returns the number of union sets.
+Calculates the union of two or more input bitmaps and returns the number of union sets.
## example
@@ -56,6 +56,20 @@ MySQL> select bitmap_or_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,
+---------------------------------------------------------------------------+
| 5 |
+---------------------------------------------------------------------------+
+
+MySQL> select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), bitmap_empty());
++-----------------------------------------------------------------------------------------------------------+
+| bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), bitmap_empty()) |
++-----------------------------------------------------------------------------------------------------------+
+| 6 |
++-----------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), NULL);
++-------------------------------------------------------------------------------------------------+
+| bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), NULL) |
++-------------------------------------------------------------------------------------------------+
+| NULL |
++-------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_xor.md b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_xor.md
index 2734f36..815358e 100644
--- a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_xor.md
+++ b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_xor.md
@@ -28,9 +28,9 @@ under the License.
## description
### Syntax
-`BITMAP BITMAP_XOR(BITMAP lhs, BITMAP rhs)`
+`BITMAP BITMAP_XOR(BITMAP lhs, BITMAP rhs, ...)`
-Compute the symmetric union of two input bitmaps, return the new bitmap.
+Compute the symmetric union of two or more input bitmaps, return the new bitmap.
## example
@@ -48,6 +48,27 @@ mysql> select bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_
+----------------------------------------------------------------------------------------+
| 1,4 |
+----------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5')));
++---------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'))) |
++---------------------------------------------------------------------------------------------------------------------+
+| 1,3,5 |
++---------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),bitmap_empty()));
++-------------------------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'), bitmap_empty())) |
++-------------------------------------------------------------------------------------------------------------------------------------+
+| 1,3,5 |
++-------------------------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),NULL));
++---------------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'), NULL)) |
++---------------------------------------------------------------------------------------------------------------------------+
+| NULL |
++---------------------------------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_xor_count.md b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_xor_count.md
index e3d0a6f..ad73ea1 100644
--- a/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_xor_count.md
+++ b/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_xor_count.md
@@ -28,9 +28,9 @@ under the License.
### Syntax
-`BIGINT BITMAP_XOR_COUNT(BITMAP lhs, BITMAP rhs)`
+`BIGINT BITMAP_XOR_COUNT(BITMAP lhs, BITMAP rhs, ...)`
-XOR two bitmap sets and return the size of the result set.
+XOR two or more bitmap sets and return the size of the result set.
## example
@@ -55,6 +55,27 @@ mysql> select bitmap_xor_count(bitmap_from_string('1,2,3'),bitmap_from_string('4
+----------------------------------------------------------------------------+
| 6 |
+----------------------------------------------------------------------------+
+
+MySQL> select (bitmap_xor_count(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5')));
++-----------------------------------------------------------------------------------------------------------+
+| (bitmap_xor_count(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'))) |
++-----------------------------------------------------------------------------------------------------------+
+| 3 |
++-----------------------------------------------------------------------------------------------------------+
+
+MySQL> select (bitmap_xor_count(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),bitmap_empty()));
++---------------------------------------------------------------------------------------------------------------------------+
+| (bitmap_xor_count(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'), bitmap_empty())) |
++---------------------------------------------------------------------------------------------------------------------------+
+| 3 |
++---------------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select (bitmap_xor_count(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),NULL));
++-----------------------------------------------------------------------------------------------------------------+
+| (bitmap_xor_count(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'), NULL)) |
++-----------------------------------------------------------------------------------------------------------------+
+| NULL |
++-----------------------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_and.md b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_and.md
index 3bb2b5c..9a8ba62 100644
--- a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_and.md
+++ b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_and.md
@@ -30,7 +30,7 @@ under the License.
`BITMAP BITMAP_AND(BITMAP lhs, BITMAP rhs)`
-计算两个输入bitmap的交集,返回新的bitmap.
+计算两个及以上输入bitmap的交集,返回新的bitmap.
## example
@@ -48,6 +48,34 @@ mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt;
+------+
| 1 |
+------+
+
+MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1)));
++----------------------------------------------------------+
+| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) |
++----------------------------------------------------------+
+| 1 |
++----------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
++-----------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
++-----------------------------------------------------------------------------------------------------------------------+
+| 1,2 |
++-----------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()));
++---------------------------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) |
++---------------------------------------------------------------------------------------------------------------------------------------+
+| |
++---------------------------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL));
++-----------------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) |
++-----------------------------------------------------------------------------------------------------------------------------+
+| NULL |
++-----------------------------------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_and_count.md b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_and_count.md
index 3d3fc28..7e1c1b5 100644
--- a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_and_count.md
+++ b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_and_count.md
@@ -28,9 +28,9 @@ under the License.
## description
### Syntax
-`BigIntVal bitmap_and_count(BITMAP lhs, BITMAP rhs)`
+`BigIntVal bitmap_and_count(BITMAP lhs, BITMAP rhs, ...)`
-计算两个输入bitmap的交集,返回交集的个数.
+计算两个及以上输入bitmap的交集,返回交集的个数.
## example
@@ -56,6 +56,27 @@ MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3
+----------------------------------------------------------------------------+
| 1 |
+----------------------------------------------------------------------------+
+
+MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'));
++-------------------------------------------------------------------------------------------------------------+
+| (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
++-------------------------------------------------------------------------------------------------------------+
+| 2 |
++-------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty());
++-----------------------------------------------------------------------------------------------------------------------------+
+| (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) |
++-----------------------------------------------------------------------------------------------------------------------------+
+| 0 |
++-----------------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL);
++-------------------------------------------------------------------------------------------------------------------+
+| (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) |
++-------------------------------------------------------------------------------------------------------------------+
+| NULL |
++-------------------------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_or.md b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_or.md
index 0ba4743..ef0eeaa 100644
--- a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_or.md
+++ b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_or.md
@@ -28,9 +28,9 @@ under the License.
## description
### Syntax
-`BITMAP BITMAP_OR(BITMAP lhs, BITMAP rhs)`
+`BITMAP BITMAP_OR(BITMAP lhs, BITMAP rhs, ...)`
-计算两个输入bitmap的并集,返回新的bitmap.
+计算两个及以上的输入bitmap的并集,返回新的bitmap.
## example
@@ -48,6 +48,34 @@ mysql> select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(1))) cnt;
+------+
| 1 |
+------+
+
+MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2)));
++---------------------------------------------------------+
+| bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2))) |
++---------------------------------------------------------+
+| 1,2 |
++---------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), NULL));
++--------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), NULL)) |
++--------------------------------------------------------------------------------------------+
+| NULL |
++--------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), bitmap_empty()));
++------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), bitmap_empty())) |
++------------------------------------------------------------------------------------------------------+
+| 0,1,2,10 |
++------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_or(to_bitmap(10), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
++--------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_or(to_bitmap(10), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
++--------------------------------------------------------------------------------------------------------+
+| 1,2,3,4,5,10 |
++--------------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_or_count.md b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_or_count.md
index 8766d2b..6e1104b 100644
--- a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_or_count.md
+++ b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_or_count.md
@@ -28,9 +28,9 @@ under the License.
## description
### Syntax
-`BigIntVal bitmap_or_count(BITMAP lhs, BITMAP rhs)`
+`BigIntVal bitmap_or_count(BITMAP lhs, BITMAP rhs, ...)`
-计算两个输入bitmap的并集,返回并集的个数.
+计算两个及以上输入bitmap的并集,返回并集的个数.
## example
@@ -56,6 +56,20 @@ MySQL> select bitmap_or_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,
+---------------------------------------------------------------------------+
| 5 |
+---------------------------------------------------------------------------+
+
+MySQL> select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), bitmap_empty());
++-----------------------------------------------------------------------------------------------------------+
+| bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), bitmap_empty()) |
++-----------------------------------------------------------------------------------------------------------+
+| 6 |
++-----------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), NULL);
++-------------------------------------------------------------------------------------------------+
+| bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), NULL) |
++-------------------------------------------------------------------------------------------------+
+| NULL |
++-------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_xor.md b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_xor.md
index 3e67e4f..a50cdbc 100644
--- a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_xor.md
+++ b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_xor.md
@@ -28,9 +28,9 @@ under the License.
## description
### Syntax
-`BITMAP BITMAP_XOR(BITMAP lhs, BITMAP rhs)`
+`BITMAP BITMAP_XOR(BITMAP lhs, BITMAP rhs, ...)`
-计算两个输入bitmap的差集,返回新的bitmap.
+计算两个及以上输入bitmap的差集,返回新的bitmap.
## example
@@ -48,6 +48,27 @@ mysql> select bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_
+----------------------------------------------------------------------------------------+
| 1,4 |
+----------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5')));
++---------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'))) |
++---------------------------------------------------------------------------------------------------------------------+
+| 1,3,5 |
++---------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),bitmap_empty()));
++-------------------------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'), bitmap_empty())) |
++-------------------------------------------------------------------------------------------------------------------------------------+
+| 1,3,5 |
++-------------------------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),NULL));
++---------------------------------------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'), NULL)) |
++---------------------------------------------------------------------------------------------------------------------------+
+| NULL |
++---------------------------------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_xor_count.md b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_xor_count.md
index 4f75746..65b0a7e 100644
--- a/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_xor_count.md
+++ b/docs/zh-CN/sql-reference/sql-functions/bitmap-functions/bitmap_xor_count.md
@@ -28,9 +28,9 @@ under the License.
### Syntax
-`BIGINT BITMAP_XOR_COUNT(BITMAP lhs, BITMAP rhs)`
+`BIGINT BITMAP_XOR_COUNT(BITMAP lhs, BITMAP rhs, ...)`
-将两个bitmap集合进行异或操作并返回结果集的大小
+将两个及以上bitmap集合进行异或操作并返回结果集的大小
## example
@@ -55,6 +55,27 @@ mysql> select bitmap_xor_count(bitmap_from_string('1,2,3'),bitmap_from_string('4
+----------------------------------------------------------------------------+
| 6 |
+----------------------------------------------------------------------------+
+
+MySQL> select (bitmap_xor_count(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5')));
++-----------------------------------------------------------------------------------------------------------+
+| (bitmap_xor_count(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'))) |
++-----------------------------------------------------------------------------------------------------------+
+| 3 |
++-----------------------------------------------------------------------------------------------------------+
+
+MySQL> select (bitmap_xor_count(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),bitmap_empty()));
++---------------------------------------------------------------------------------------------------------------------------+
+| (bitmap_xor_count(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'), bitmap_empty())) |
++---------------------------------------------------------------------------------------------------------------------------+
+| 3 |
++---------------------------------------------------------------------------------------------------------------------------+
+
+MySQL> select (bitmap_xor_count(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),NULL));
++-----------------------------------------------------------------------------------------------------------------+
+| (bitmap_xor_count(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'), NULL)) |
++-----------------------------------------------------------------------------------------------------------------+
+| NULL |
++-----------------------------------------------------------------------------------------------------------------+
```
## keyword
diff --git a/gensrc/script/doris_builtins_functions.py b/gensrc/script/doris_builtins_functions.py
index 9cf6ab2..40d08c9 100755
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -1175,18 +1175,30 @@ visible_functions = [
[['bitmap_empty'], 'BITMAP', [],
'_ZN5doris15BitmapFunctions12bitmap_emptyEPN9doris_udf15FunctionContextE',
'', '', 'vec', 'ALWAYS_NOT_NULLABLE'],
+ [['bitmap_or'], 'BITMAP', ['BITMAP','BITMAP','...'],
+ '_ZN5doris15BitmapFunctions9bitmap_orEPN9doris_udf15FunctionContextERKNS1_9StringValEiPS5_',
+ '', '', '', ''],
[['bitmap_or'], 'BITMAP', ['BITMAP','BITMAP'],
'_ZN5doris15BitmapFunctions9bitmap_orEPN9doris_udf15FunctionContextERKNS1_9StringValES6_',
'', '', 'vec', ''],
+ [['bitmap_xor'], 'BITMAP', ['BITMAP','BITMAP','...'],
+ '_ZN5doris15BitmapFunctions10bitmap_xorEPN9doris_udf15FunctionContextERKNS1_9StringValEiPS5_',
+ '', '', '', ''],
[['bitmap_xor'], 'BITMAP', ['BITMAP','BITMAP'],
'_ZN5doris15BitmapFunctions10bitmap_xorEPN9doris_udf15FunctionContextERKNS1_9StringValES6_',
'', '', 'vec', ''],
+ [['bitmap_xor_count'], 'BIGINT', ['BITMAP','BITMAP','...'],
+ '_ZN5doris15BitmapFunctions16bitmap_xor_countEPN9doris_udf15FunctionContextERKNS1_9StringValEiPS5_',
+ '', '', '', ''],
[['bitmap_xor_count'], 'BIGINT', ['BITMAP','BITMAP'],
'_ZN5doris15BitmapFunctions16bitmap_xor_countEPN9doris_udf15FunctionContextERKNS1_9StringValES6_',
'', '', '', ''],
[['bitmap_not'], 'BITMAP', ['BITMAP','BITMAP'],
'_ZN5doris15BitmapFunctions10bitmap_notEPN9doris_udf15FunctionContextERKNS1_9StringValES6_',
'', '', 'vec', ''],
+ [['bitmap_and'], 'BITMAP', ['BITMAP','BITMAP','...'],
+ '_ZN5doris15BitmapFunctions10bitmap_andEPN9doris_udf15FunctionContextERKNS1_9StringValEiPS5_',
+ '', '', '', ''],
[['bitmap_and'], 'BITMAP', ['BITMAP','BITMAP'],
'_ZN5doris15BitmapFunctions10bitmap_andEPN9doris_udf15FunctionContextERKNS1_9StringValES6_',
'', '', 'vec', ''],
@@ -1223,9 +1235,15 @@ visible_functions = [
[['bitmap_subset_limit'], 'BITMAP', ['BITMAP', 'BIGINT', 'BIGINT'],
'_ZN5doris15BitmapFunctions19bitmap_subset_limitEPN9doris_udf15FunctionContextERKNS1_9StringValERKNS1_9BigIntValES9_',
'', '', 'vec', ''],
+ [['bitmap_and_count'], 'BIGINT', ['BITMAP','BITMAP','...'],
+ '_ZN5doris15BitmapFunctions16bitmap_and_countEPN9doris_udf15FunctionContextERKNS1_9StringValEiPS5_',
+ '', '', '', ''],
[['bitmap_and_count'], 'BIGINT', ['BITMAP','BITMAP'],
'_ZN5doris15BitmapFunctions16bitmap_and_countEPN9doris_udf15FunctionContextERKNS1_9StringValES6_',
'', '', '', ''],
+ [['bitmap_or_count'], 'BIGINT', ['BITMAP','BITMAP','...'],
+ '_ZN5doris15BitmapFunctions15bitmap_or_countEPN9doris_udf15FunctionContextERKNS1_9StringValEiPS5_',
+ '', '', '', ''],
[['bitmap_or_count'], 'BIGINT', ['BITMAP','BITMAP'],
'_ZN5doris15BitmapFunctions15bitmap_or_countEPN9doris_udf15FunctionContextERKNS1_9StringValES6_',
'', '', '', ''],
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org