Roaring bitmap output functions specify the output format of Roaring bitmap data. For example, you can specify to output each element in a Roaring bitmap in order as a string, with the elements separated with commas (,). OceanBase Database supports the rb_to_varbinary() and rb_to_string() Roaring bitmap output functions.
rb_to_varbinary
rb_to_varbinary() outputs Roaring bitmap data in the varbinary format. The syntax is as follows:
rb_to_varbinary(rb, [format])
The format parameter is optional and can be set only to roaring now. After you specify this parameter, only the BITMAP_32 and BITMAP_64 formats are supported for the output binary data. If you do not specify this parameter, the default output format is varbinary, which comprises seven subtypes, including BITMAP_32 and BITMAP_6.
Here are some examples:
SELECT rb_to_varbinary((1,2,3));
+------------------------------------------------------------------------------------+
| rb_to_varbinary(rb_from_string('1,2,3')) |
+------------------------------------------------------------------------------------+
| 0x010303010000000200000003000000 |
+------------------------------------------------------------------------------------+
1 row in set
SELECT rb_to_varbinary((1,2,3),'roaring');
+----------------------------------------------------------------------------------------------------------+
| rb_to_varbinary(rb_from_string('1,2,3'), 'roaring') |
+----------------------------------------------------------------------------------------------------------+
| 0x01053A300000010000000000020010000000010002000300 |
+----------------------------------------------------------------------------------------------------------+
1 row in set
rb_to_string
rb_to_string() outputs each element in a Roaring bitmap in order as a string, with the elements separated with commas (,). Elements are output in the UINT64 format, and a maximum of 1,000,000 elements can be output. The syntax is as follows:
rb_to_string(rb)
Here are some examples:
SELECT rb_to_string(rb_from_string('1,2,3'));
+---------------------------------------+
| rb_to_string(rb_from_string('1,2,3')) |
+---------------------------------------+
| 1,2,3 |
+---------------------------------------+
1 row in set
SELECT rb_to_string(x'010101000000');
+-------------------------------+
| rb_to_string(x'010101000000') |
+-------------------------------+
| 1 |
+-------------------------------+
1 row in set