OceanBase Database provides a collection of Roaring bitmap functions for processing Roaring bitmap data. You can use these functions to perform complex Roaring bitmap queries and analysis at the database level. This enables user behavior analysis, user profiling, and crowd targeting applications to efficiently store, query, and process Roaring bitmap data.
The following table describes the Roaring bitmap functions supported by OceanBase Database.
Type of roaring bitmap function
| Function type | Description |
|---|---|
| Roaring bitmap constructor functions | Construct a Roaring bitmap object. |
| Roaring bitmap cardinality calculation functions | Calculate the cardinality of Roaring bitmap data. |
| Roaring bitmap operation functions | Perform basic operations between Roaring bitmap data, such as intersection, union, XOR, and NAND. |
| Roaring bitmap judgment functions | Perform judgment on the input Roaring bitmap data and return a Boolean value. |
| Roaring bitmap output functions | Specify the output format of bitmap data. For example, you can specify to output each element in a Roaring bitmap in order as a string, and separate the elements with commas (,). |
| Roaring bitmap aggregate functions | Aggregate numeric data into a Roaring bitmap. |
Overview of bitmap functions
OceanBase Database supports the following bitmap functions:
| Function type | Function name | Description |
|---|---|---|
| Bitmap constructor | rb_build_empty | Constructs an empty bitmap. |
| Bitmap constructor | rb_build_empty | Constructs an empty bitmap. |
| Bitmap constructor | rb_build_varbinary | Constructs bitmap data using a varbinary. |
| Bitmap constructor | rb_from_string | Constructs bitmap data from a string in a specified format. |
| Bitmap constructor | rb_select | Selects a local range from bitmap data based on specified conditions, saves it as new bitmap data, and returns its value. |
| Bitmap cardinality calculation function | rb_cardinality | Calculates the cardinality of bitmap data. |
| Bitmap cardinality function | rb_and_cardanity and rb_and_null2empty_cardinality | Returns the cardinality of the new bitmap data obtained after performing an AND operation on two bitmap datasets. |
| Bitmap cardinality calculation functions | rb_or_cardinality and rb_or_null2empty_cardinality | Returns the cardinality of a new bitmap data set by performing an OR operation on two bitmap data sets. |
| Bitmap cardinality computation function | rb_xor_cardinality | Returns the cardinality of the new bitmap data obtained after two bitmap data are XORed. |
| Bitmap cardinality | rb_andnot_cardinality and rb_andnot_null2empty_cardinality | Returns the cardinality of the new bitmap data obtained after the bitwise AND NOT operation is performed on the two bitmap data. |
| Bitmap base calculation | rb_or_cardinality_agg | Computes the cardinality of the union of bitmap columns. |
| Bitmap cardinality aggregation | rb_and_cardinality_agg | Calculates the cardinality of the intersection of bitmap columns. |
| Bitmap operation | rb_and and rb_and_null2empty | Calculates the intersection of two bitmap data. |
| Bitmap operation | rb_or and rb_or_null2empty | Calculates the union of two bitmap data. |
| Bitmap operation | rb_xor | Performs the XOR operation on two bitmap data. |
| Bitmap operation | rb_andnot and rb_andnot_null2empty | Performs the bitwise AND-NOT operation on two bitmap data sets. |
| Bitmap check | rb_is_empty | Checks whether the input bitmap data is empty. |
| Bitmap inspection | rb_contains | This function can be used as follows:
|
| Bitmap output | rb_to_varbinary | Outputs bitmap data in the varbinary format. |
| Bitmap output | rb_to_string | Outputs each element of the bitmap data as a string and separates them with commas. |
| Raster bitmap output | rb_to_array | Outputs bitmap data in the form of an array. |
| Bitmap aggregate | rb_build_agg | Aggregates numeric columns into bitmap data. |
| Bitmap aggregation | rb_or_agg | Performs the logical OR operation on multiple rows of bitmap data and aggregates the result as bitmap data. |
| Bitmap aggregate | rb_and_agg | Performs the bitwise AND operation on multiple rows of bitmap data and aggregates the data into a bitmap. |