メインコンテンツまでスキップ

BITMAP_XOR

説明

2つ以上の入力Bitmapの対称差(XOR演算)を計算し、新しいBitmapを返します。

構文

BITMAP_XOR(<bitmap1>, <bitmap2>, ..., <bitmapN>)

パラメータ

ParameterDescription
<bitmap1>最初のBitmap
<bitmap2>2番目のBitmap
......
<bitmapN>N番目のBitmap

戻り値

複数のBitmapの対称差集合を表すBitmap。

  • パラメータがNULL値の場合、NULLを返します

2つのBitmapの対称差集合を計算するには:

select bitmap_count(bitmap_xor(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'))) cnt;

結果は以下のようになります:

+------+
| cnt |
+------+
| 2 |
+------+

2つのBitmapの対称差分を文字列に変換するには:

select bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'))) res;

結果は次のようになります:

+------+
| res |
+------+
| 1,4 |
+------+

3つのBitmapの対称差集合を計算するには:

select bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'), bitmap_from_string('3,4,5'))) res;

結果は次のようになります:

+-------+
| res |
+-------+
| 1,3,5 |
+-------+

空のBitmapを含む複数のBitmapの対称差集合を計算するには:

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())) res;

結果は次のようになります:

+-------+
| res |
+-------+
| 1,3,5 |
+-------+

NULL値を含む複数のBitmapの対称差集合を計算するには:

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)) res;

結果は次のようになります:

+------+
| res |
+------+
| NULL |
+------+