BITMAP_NOT
更新时间:2025-10-16
描述
计算第一个 Bitmap 减去第二个 Bitmap 之后的集合,并返回为新的 Bitmap。
语法
SQL
1bitmap_not(<bitmap1>, <bitmap2>)
参数
| 参数 | 描述 |
|---|---|
<bitmap1> |
第一个 Bitmap |
<bitmap2> |
第二个 Bitmap |
返回值
<bitmap1> 减去 <bitmap2> 后集合的 Bitmap。
示例
计算两个 Bitmap 之间的差集:
SQL
1select bitmap_to_string(bitmap_not(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4')));
结果如下,因 <bitmap1> 的所有元素也在 <bitmap2> 中,所以结果是一个空的 Bitmap:
Text
1+----------------------------------------------------------------------------------------+
2| bitmap_to_string(bitmap_not(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'))) |
3+----------------------------------------------------------------------------------------+
4| |
5+----------------------------------------------------------------------------------------+
61 row in set (0.01 sec)
计算 <bitmap1> 中存在但 <bitmap2> 中不存在的元素的差集:
SQL
1select bitmap_to_string(bitmap_not(bitmap_from_string('2,3,5'), bitmap_from_string('1,2,3,4')));
结果如下,将是一个包含元素 5 的 Bitmap:
Text
1+----------------------------------------------------------------------------------------+
2| bitmap_to_string(bitmap_not(bitmap_from_string('2,3,5'), bitmap_from_string('1,2,3,4'))) |
3+----------------------------------------------------------------------------------------+
4| 5 |
5+----------------------------------------------------------------------------------------+
61 row in set (0.01 sec)
