Skip to main content

orthogonal_bitmap_expr_calculate

Description​

The ORTHOGONAL_BITMAP_EXPR_CALCULATE function returns the set obtained after performing intersection, union, and difference calculations on the Bitmap expression.

Syntax​

ORTHOGONAL_BITMAP_EXPR_CALCULATE(<bitmap_column>, <column_to_filter>, <input_string>)

Parameters​

ε‚ζ•°θ―΄ζ˜Ž
<bitmap_column>The Bitmap type expression needs to be obtained
<column_to_filter>The filtering dimension column, the Key column for calculation
<input_string>The calculation expression string, meaning that the Bitmap intersection, union, and difference set expressions are calculated based on the Key column. The supported operators in the expression: &represents intersection calculation, | represents union calculation, - represents difference calculation, ^ represents XOR calculation, and \ represents escape characters

Return Value​

Returns a set of BITMAP type.

Example​

select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000);
Note: 1000, 20000, 30000 plastic tags represent different labels of users
+-------------------------------------------------------------------------------------------------------------------------------+
| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) |
+-------------------------------------------------------------------------------------------------------------------------------+
| 1000 |
+-------------------------------------------------------------------------------------------------------------------------------+
select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23');
Note: 'A:a/b', 'B:2-4', etc. are string types tag, representing different labels of users, where 'B:2-4' needs to be escaped as'B:2\\-4'
+-----------------------------------------------------------------------------------------------------------+
| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) |
+-----------------------------------------------------------------------------------------------------------+
| 30 |
+-----------------------------------------------------------------------------------------------------------+