Skip to content

Commit 5350668

Browse files
catpineappleyuanyuan8983
authored andcommitted
[doc](sql) bitmap-1 func (apache#1852)
## Versions - [x] dev - [x] 3.0 - [x] 2.1 - [ ] 2.0 ## Languages - [x] Chinese - [x] English ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built
1 parent ca2ce39 commit 5350668

File tree

60 files changed

+2115
-1302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2115
-1302
lines changed

docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,61 +24,74 @@ specific language governing permissions and limitations
2424
under the License.
2525
-->
2626

27-
## bitmap_and_count
28-
### description
29-
#### Syntax
27+
## Description
3028

31-
`BigIntVal bitmap_and_count(BITMAP lhs, BITMAP rhs, ...)`
29+
Computes the intersection of two or more input BITMAPs and returns the number of intersections.
3230

33-
Calculate the intersection of two or more input bitmaps and return the number of intersections.
34-
35-
### example
31+
## Syntax
3632

33+
```sql
34+
BITMAP_AND_COUNT(<bitmap>, <bitmap>,[, <bitmap>...])
3735
```
38-
MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_empty());
39-
+---------------------------------------------------------------+
40-
| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_empty()) |
41-
+---------------------------------------------------------------+
42-
| 0 |
43-
+---------------------------------------------------------------+
4436

37+
## Parameters
4538

46-
MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('1,2,3'));
47-
+----------------------------------------------------------------------------+
48-
| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2,3')) |
49-
+----------------------------------------------------------------------------+
50-
| 3 |
51-
+----------------------------------------------------------------------------+
39+
| Parameter | Description |
40+
|------------|----------------------------------------------------------------|
41+
| `<bitmap>` | One of the original BITMAPs whose intersection is being sought |
42+
43+
## Return Value
5244

53-
MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'));
45+
Returns an integer
46+
- If the parameter has a null value, it returns NULL
47+
48+
## Examples
49+
50+
```sql
51+
select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'));
52+
```
53+
54+
```text
5455
+----------------------------------------------------------------------------+
5556
| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) |
5657
+----------------------------------------------------------------------------+
5758
| 1 |
5859
+----------------------------------------------------------------------------+
60+
```
5961

60-
MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'));
62+
```sql
63+
select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'));
64+
```
65+
66+
```text
6167
+-------------------------------------------------------------------------------------------------------------+
6268
| (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
6369
+-------------------------------------------------------------------------------------------------------------+
6470
| 2 |
6571
+-------------------------------------------------------------------------------------------------------------+
72+
```
73+
74+
```sql
75+
select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty());
76+
```
6677

67-
MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty());
78+
```text
6879
+-----------------------------------------------------------------------------------------------------------------------------+
6980
| (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) |
7081
+-----------------------------------------------------------------------------------------------------------------------------+
7182
| 0 |
7283
+-----------------------------------------------------------------------------------------------------------------------------+
84+
```
85+
86+
```sql
87+
select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL);
88+
```
7389

74-
MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL);
90+
```text
7591
+-------------------------------------------------------------------------------------------------------------------+
7692
| (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) |
7793
+-------------------------------------------------------------------------------------------------------------------+
7894
| NULL |
7995
+-------------------------------------------------------------------------------------------------------------------+
8096
```
8197

82-
### keywords
83-
84-
BITMAP_AND_COUNT,BITMAP

docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,54 @@ specific language governing permissions and limitations
2424
under the License.
2525
-->
2626

27-
## bitmap_and_not_count,bitmap_andnot_count
28-
### description
29-
#### Syntax
27+
## Description
3028

31-
`BITMAP BITMAP_AND_NOT_COUNT(BITMAP lhs, BITMAP rhs)`
29+
Performs a NOT operation on two BITMAPs and returns the number of elements in the result set. The first input parameter is called `base BITMAP` and the second is called `exclusion BITMAP`.
3230

33-
Calculate the set after lhs minus intersection of two input bitmaps, return the new bitmap size.
31+
## Alias
3432

33+
- BITMAP_ANDNOT_COUNT
3534

36-
### example
35+
## Syntax
3736

37+
```sql
38+
BITMAP_AND_NOT_COUNT(<bitmap1>, <bitmap2>)
3839
```
39-
mysql> select bitmap_and_not_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')) cnt;
40+
41+
## Parameters
42+
43+
| Parameter | Description |
44+
|-------------|----------------------------------|
45+
| `<bitmap1>` | `Base BITMAP` to be negated |
46+
| `<bitmap2>` | `Exclusion BITMAP` to be negated |
47+
48+
## Return Value
49+
50+
Returns an integer.
51+
- If the parameter has a null value, returns NULL
52+
53+
## Examples
54+
55+
```sql
56+
select bitmap_and_not_count(null, bitmap_from_string('1,2,3')) banc1, bitmap_and_not_count(bitmap_from_string('1,2,3') ,null) banc2;
57+
```
58+
59+
```text
60+
+-------+-------+
61+
| banc1 | banc2 |
62+
+-------+-------+
63+
| 0 | 0 |
64+
+-------+-------+
65+
```
66+
67+
```sql
68+
select bitmap_and_not_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) banc;
69+
```
70+
71+
```text
4072
+------+
41-
| cnt |
73+
| banc |
4274
+------+
4375
| 2 |
4476
+------+
45-
```
46-
47-
### keywords
48-
49-
BITMAP_AND_NOT_COUNT,BITMAP_ANDNOT_COUNT,BITMAP
77+
```

docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,46 +24,78 @@ specific language governing permissions and limitations
2424
under the License.
2525
-->
2626

27-
## bitmap_and_not,bitmap_andnot
28-
### description
29-
#### Syntax
27+
## Description
3028

31-
`BITMAP BITMAP_AND_NOT(BITMAP lhs, BITMAP rhs)`
29+
Perform a NOT operation on two BITMAPs and return the result. The first input parameter is called `base BITMAP` and the second is called `exclude BITMAP`.
3230

33-
Calculate the set after lhs minus intersection of two input bitmaps, return the new bitmap.
31+
## Alias
3432

35-
### example
33+
- BITMAP_ANDNOT
3634

35+
## Syntax
36+
37+
```sql
38+
BITMAP_AND_NOT(<bitmap1>, <bitmap2>)
39+
```
40+
41+
## Parameters
42+
43+
| Parameter | Description |
44+
|-------------|----------------------------------|
45+
| `<bitmap1>` | `Base BITMAP` to be negated |
46+
| `<bitmap2>` | `Exclusion BITMAP` to be negated |
47+
48+
## Return Value
49+
50+
Returns a BITMAP.
51+
- If the parameter has a null value, returns NULL
52+
53+
## Examples
54+
55+
```sql
56+
select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt;
3757
```
38-
mysql> select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt;
58+
59+
```text
3960
+------+
4061
| cnt |
4162
+------+
4263
| 2 |
4364
+------+
65+
```
4466

45-
mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')));
67+
```sql
68+
select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')));
69+
```
70+
71+
```text
4672
+--------------------------------------------------------------------------------------------+
4773
| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'))) |
4874
+--------------------------------------------------------------------------------------------+
4975
| 1,2 |
5076
+--------------------------------------------------------------------------------------------+
77+
```
78+
79+
```sql
80+
select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty()));
81+
```
5182

52-
mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())) ;
83+
```text
5384
+-------------------------------------------------------------------------------+
5485
| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_empty())) |
5586
+-------------------------------------------------------------------------------+
5687
| 1,2,3 |
5788
+-------------------------------------------------------------------------------+
89+
```
90+
91+
```sql
92+
select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL));
93+
```
5894

59-
mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL));
95+
```text
6096
+---------------------------------------------------------------------+
6197
| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), NULL)) |
6298
+---------------------------------------------------------------------+
6399
| NULL |
64100
+---------------------------------------------------------------------+
65101
```
66-
67-
### keywords
68-
69-
BITMAP_AND_NOT,BITMAP_ANDNOT,BITMAP

docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,67 +24,61 @@ specific language governing permissions and limitations
2424
under the License.
2525
-->
2626

27-
## bitmap_and
28-
### description
29-
#### Syntax
27+
## Description
3028

31-
`BITMAP BITMAP_AND(BITMAP lhs, BITMAP rhs, ...)`
29+
Computes the intersection of two or more input BITMAPs and returns a new BITMAP.
3230

33-
Compute intersection of two or more input bitmaps, return the new bitmap.
31+
## Syntax
3432

35-
### example
33+
```sql
34+
BITMAP_AND(<bitmap>, <bitmap>,[, <bitmap>...])
35+
```
36+
37+
## Parameters
38+
39+
| Parameter | Description |
40+
|------------|----------------------------------------------------------------|
41+
| `<bitmap>` | One of the original BITMAPs whose intersection is being sought |
42+
43+
## Return Value
3644

45+
Returns a BITMAP
46+
- If the parameter has a null value, it returns NULL
47+
48+
## Examples
49+
50+
```sql
51+
select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
3752
```
38-
mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(2))) cnt;
39-
+------+
40-
| cnt |
41-
+------+
42-
| 0 |
43-
+------+
44-
45-
mysql> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2)));
46-
+----------------------------------------------------------+
47-
| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))) |
48-
+----------------------------------------------------------+
49-
| |
50-
+----------------------------------------------------------+
51-
52-
mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt;
53-
+------+
54-
| cnt |
55-
+------+
56-
| 1 |
57-
+------+
58-
59-
MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1)));
60-
+----------------------------------------------------------+
61-
| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) |
62-
+----------------------------------------------------------+
63-
| 1 |
64-
+----------------------------------------------------------+
65-
66-
MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
53+
54+
```text
6755
+-----------------------------------------------------------------------------------------------------------------------+
6856
| bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
6957
+-----------------------------------------------------------------------------------------------------------------------+
7058
| 1,2 |
7159
+-----------------------------------------------------------------------------------------------------------------------+
60+
```
7261

73-
MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()));
62+
```sql
63+
select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()));
64+
```
65+
66+
```text
7467
+---------------------------------------------------------------------------------------------------------------------------------------+
7568
| bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) |
7669
+---------------------------------------------------------------------------------------------------------------------------------------+
7770
| |
7871
+---------------------------------------------------------------------------------------------------------------------------------------+
72+
```
7973

80-
MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL));
74+
```sql
75+
select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL));
76+
```
77+
78+
```text
8179
+-----------------------------------------------------------------------------------------------------------------------------+
8280
| bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) |
8381
+-----------------------------------------------------------------------------------------------------------------------------+
8482
| NULL |
8583
+-----------------------------------------------------------------------------------------------------------------------------+
8684
```
87-
88-
### keywords
89-
90-
BITMAP_AND,BITMAP

0 commit comments

Comments
 (0)