SUB_BITMAP
Descriptionβ
Extracts a subset of Bitmap elements starting from a specified position and limited by a specified cardinality limit, returning the subset as a new Bitmap.
Syntaxβ
SUB_BITMAP(<bitmap>, <position>, <cardinality_limit>)
Parametersβ
Parameter | Description |
---|---|
<bitmap> | The Bitmap value |
<position> | The starting position (inclusive) |
<cardinality_limit> | The maximum number of elements |
Return Valueβ
A subset Bitmap within the specified range and limit.
Examplesβ
To get a subset of a Bitmap starting from position 0 with a cardinality limit of 3:
select bitmap_to_string(sub_bitmap(bitmap_from_string('1,0,1,2,3,1,5'), 0, 3)) value;
The result will be:
+-------+
| value |
+-------+
| 0,1,2 |
+-------+
To get a subset of a Bitmap starting from position -3 with a cardinality limit of 2:
select bitmap_to_string(sub_bitmap(bitmap_from_string('1,0,1,2,3,1,5'), -3, 2)) value;
The result will be:
+-------+
| value |
+-------+
| 2,3 |
+-------+
To get a subset of a Bitmap starting from position 2 with a cardinality limit of 100:
select bitmap_to_string(sub_bitmap(bitmap_from_string('1,0,1,2,3,1,5'), 2, 100)) value;
The result will be:
+-------+
| value |
+-------+
| 2,3,5 |
+-------+