Bitmap operation functions
Bitmap operation functions perform basic operations on bitmap data. The following are the bitmap operation functions supported by seekdb: rb_and(), rb_or(), rb_xor(), rb_andnot(), rb_and_null2empty(), rb_or_null2empty(), and rb_andnot_null2empty().
rb_and and rb_and_null2empty
The rb_and() function computes the intersection of two bitmap data sets. The syntax is as follows:
rb_and(rb1, rb2)
The order of the parameters rb1 and rb2 does not affect the result.
Here is an example:
SELECT rb_to_string(rb_and(rb_from_string('1,2,3'), rb_from_string('2,3,4')));
+------------------------------------------------------------------------+
| rb_to_string(rb_and(rb_from_string('1,2,3'), rb_from_string('2,3,4'))) |
+------------------------------------------------------------------------+
| 2,3 |
+------------------------------------------------------------------------+
1 row in set (0.001 sec)
SELECT rb_to_string(rb_and(rb_from_string('1,2,3'), NULL));
+-----------------------------------------------------+
| rb_to_string(rb_and(rb_from_string('1,2,3'), NULL)) |
+-----------------------------------------------------+
| NULL |
+-----------------------------------------------------+
1 row in set (0.001 sec)
The rb_and_null2empty() function performs the same logical operation as rb_and(), but treats empty input as an empty bitmap data set.
SELECT rb_to_string(rb_and_null2empty(rb_from_string('1,2,3'), NULL));
+----------------------------------------------------------------+
| rb_to_string(rb_and_null2empty(rb_from_string('1,2,3'), NULL)) |
+----------------------------------------------------------------+
| |
+----------------------------------------------------------------+
1 row in set (0.001 sec)
rb_or and rb_or_null2empty
The rb_or() function computes the union of two bitmap data sets. The syntax is as follows:
rb_or(rb1, rb2)
The order of the parameters rb1 and rb2 does not affect the result.
Here is an example:
SELECT rb_to_string(rb_or(rb_from_string('1,2,3'), rb_from_string('2,3,4')));
+-----------------------------------------------------------------------+
| rb_to_string(rb_or(rb_from_string('1,2,3'), rb_from_string('2,3,4'))) |
+-----------------------------------------------------------------------+
| 1,2,3,4 |
+-----------------------------------------------------------------------+
1 row in set (0.001 sec)
The rb_or_null2empty() function performs the same logical operation as rb_or(), but treats empty input as an empty bitmap data set.
rb_xor
The rb_xor() function performs an XOR operation on two bitmap data sets. The syntax is as follows:
rb_xor(rb1, rb2)
The order of the parameters rb1 and rb2 does not affect the result.
Here is an example:
SELECT rb_to_string(rb_xor(rb_from_string('1,2,3'), rb_from_string('2,3,4')));
+------------------------------------------------------------------------+
| rb_to_string(rb_xor(rb_from_string('1,2,3'), rb_from_string('2,3,4'))) |
+------------------------------------------------------------------------+
| 1,4 |
+------------------------------------------------------------------------+
1 row in set (0.001 sec)
rb_andnot and rb_andnot_null2empty
The rb_andnot() function performs an AND NOT operation on two bitmap data sets. The syntax is as follows:
rb_andnot(rb1, rb2)
This function calculates the difference between rb1 and rb2, returning a bitmap data set where the value is rb1 - rb2.
Here is an example:
SELECT rb_to_string(rb_andnot(rb_from_string('1,2,3'), rb_from_string('2,3,4')));
+---------------------------------------------------------------------------+
| rb_to_string(rb_andnot(rb_from_string('1,2,3'), rb_from_string('2,3,4'))) |
+---------------------------------------------------------------------------+
| 1 |
+---------------------------------------------------------------------------+
1 row in set (0.001 sec)
The rb_andnot_null2empty() function performs the same logical operation as rb_andnot(), but treats empty input as an empty bitmap data set.