跳到主要内容

BITMAP_AND_NOT,BITMAP_ANDNOT

描述

将两个 BITMAP 进行与非操作并返回计算结果,其中入参第一个叫 基准 BITMAP, 第二个叫 排除 BITMAP

别名

  • BITMAP_ANDNOT

语法

BITMAP_AND_NOT(<bitmap1>, <bitmap2>)

参数

参数说明
<bitmap1>被求与非的基准 BITMAP
<bitmap2>被求与非的排除 BITMAP

返回值

返回一个 BITMAP。

  • 当参数存在空值时,返回 NULL

举例

select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt;
+------+
| cnt |
+------+
| 2 |
+------+
select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')));
+--------------------------------------------------------------------------------------------+
| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'))) |
+--------------------------------------------------------------------------------------------+
| 1,2 |
+--------------------------------------------------------------------------------------------+
select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty()));
+-------------------------------------------------------------------------------+
| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_empty())) |
+-------------------------------------------------------------------------------+
| 1,2,3 |
+-------------------------------------------------------------------------------+
select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL));
+---------------------------------------------------------------------+
| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), NULL)) |
+---------------------------------------------------------------------+
| NULL |
+---------------------------------------------------------------------+