Bitmap functions are a set of specialized functions provided in the OceanBase AI Database system for efficiently compressing and processing bitmap data. These functions enable users to perform complex bitmap queries and analyses at the database level, allowing applications such as user behavior analysis, user profiling, and audience segmentation to store, query, and manipulate bitmap data efficiently.
The following table describes the bitmap functions in OceanBase AI Database and their purposes:
Bitmap function types
Bitmap Function Types |
Description |
|---|---|
| Bitmap Constructor | A function for creating a new bitmap data type. |
| Bitmap cardinality functions | Used to calculate the cardinality of bitmap data. |
| Bitmap arithmetic functions | Provides functions for basic operations on bitmap data, such as intersection, union, XOR, and NAND. |
| Bitmap predicate functions | A function that performs some judgment on the input bitmap data and returns a boolean value. |
| Bitmap output functions | A function used to select the output format for bitmap data. For example, it can output each element of the bitmap data as a string in sequence, separated by commas. |
| Bitmap aggregate functions | Provides functions for aggregating numeric types into a bitmap type, that is, performing aggregate operations on bitmap data. |
Overview of bitmap functions
The following table lists all bitmap functions supported by OceanBase AI Database:
Function type |
Function name |
Description |
|---|---|---|
| Bitmap Constructor | rb_build_empty | Constructs an empty bitmap data structure. |
| Bitmap Constructor | rb_build_empty | Constructs an empty bitmap data structure. |
| Bitmap Constructor | rb_build_varbinary | Build bitmap data using varbinary. |
| Bitmap Constructor | rb_from_string | Construct bitmap data using strings in a specific format. |
| Bitmap Constructor | rb_select | Retrieves a local range of values from a bitmap based on specified conditions, saves it as a new bitmap, and returns its value. |
| Bitmap Cardinality Function | rb_cardinality | Used to calculate the cardinality of bitmap data. |
| Bitmap Cardinality Function | rb_and_cardinality and rb_and_null2empty_cardinality | Returns the cardinality of the new bitmap data obtained after performing an AND operation on two bitmap data. |
| Bitmap Cardinality Function | rb_or_cardinality and rb_or_null2empty_cardinality | Returns the cardinality of the new bitmap data obtained by performing an OR operation on two bitmap data. |
| Bitmap Cardinality Function | rb_xor_cardinality | Returns the cardinality of the new bitmap data obtained after performing an XOR operation on two bitmap data. |
| Bitmap Cardinality Function | rb_andnot_cardinality and rb_andnot_null2empty_cardinality | Returns the cardinality of the new bitmap data obtained after performing an AND NOT operation on two bitmap data. |
| Bitmap Cardinality Function | rb_or_cardinality_agg | Computes the union cardinality of a bitmap column. |
| Bitmap Cardinality Function | rb_and_cardinality_agg | Computes the intersection cardinality of bitmap columns. |
| Bitmap Arithmetic Functions | rb_and and rb_and_null2empty | Computes the intersection of two bitmap data. |
| Bitmap Arithmetic Functions | rb_or and rb_or_null2empty | Computes the union of two bitmap data. |
| Bitmap Arithmetic Functions | rb_xor | Provides the XOR operation for two bitmap data. |
| Bitmap Arithmetic Functions | rb_andnot and rb_andnot_null2empty | Two bitwise NOT operations for bitmap data are provided. |
| Bitmap predicate function | rb_is_empty | Determines whether the input bitmap data is empty. |
| Bitmap predicate function | rb_contains | Two usages:
|
| Bitmap Output Function | rb_to_varbinary | Used to output bitmap data in varbinary format. |
| Bitmap Output Function | rb_to_string | Output each element of the bitmap data in a string format, separated by commas. |
| Bitmap Output Function | rb_to_array | Output bitmap data in an array format. |
| Bitmap aggregate functions | rb_build_agg | Aggregates numeric columns into bitmap data. |
| Bitmap aggregate functions | rb_or_agg | Perform a bitwise OR operation on multiple rows of bitmap data and aggregate the results into a single bitmap. |
| Bitmap aggregate function | rb_and_agg | Performs an AND operation on multiple rows of a bitmap column and aggregates the results into a bitmap. |