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_filte> | 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 |
+-----------------------------------------------------------------------------------------------------------+