DOCAPI-7063: Formatting of the bitmapContains function docs. (#5664)

* DOCAPI-7063: Formatting of the bitmapContains function.
This commit is contained in:
BayoNet 2019-06-19 16:14:05 +03:00 committed by GitHub
parent 41302c9910
commit 5e6806f64e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ RoaringBitmap is wrapped into a data structure while actual storage of Bitmap ob
For more information on RoaringBitmap, see: [CRoaring](https://github.com/RoaringBitmap/CRoaring).
## bitmapBuild
## bitmapBuild {#bitmap_functions-bitmapbuild}
Build a bitmap from unsigned integer array.
@ -56,6 +56,37 @@ SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res
└─────────────┘
```
## bitmapContains {#bitmap_functions-bitmapcontains}
Checks whether the bitmap contains an element.
```
bitmapContains(haystack, needle)
```
**Parameters**
- `haystack` [Bitmap object](#bitmap_functions-bitmapbuild), where the functions searches.
- `needle` Value that the function searches. Type: [UInt32](../../data_types/int_uint.md).
**Returned value**
- 0 — If `haystack` doesn't contain `needle`.
- 1 — If `haystack` contains `needle`.
Type: `UInt8`.
**Example**
``` sql
SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res
```
```text
┌─res─┐
│ 1 │
└─────┘
```
## bitmapHasAny
Checks whether two bitmaps have intersection by some elements.
@ -64,6 +95,8 @@ Checks whether two bitmaps have intersection by some elements.
bitmapHasAny(bitmap1, bitmap2)
```
If you are sure that `bitmap2` contains strictly one element, consider using the [bitmapContains](#bitmap_functions-bitmapcontains) function. It works more efficiently.
**Parameters**
- `bitmap*` bitmap object.
@ -332,31 +365,5 @@ SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res
└─────┘
```
## bitmapContains
Returns 1 if bitmap contains the given element, 0 otherwise.
For empty bitmaps returns 0.
```
bitmapContains(bitmap,element)
```
**Parameters**
- `bitmap` bitmap object.
- `element` UInt32 integer.
**Example**
``` sql
select bitmapContains(bitmapBuild([1,5,7,9]),CAST(9, 'UInt32')) AS res;
```
```
┌─res─┐
│ 1 │
└─────┘
```
[Original article](https://clickhouse.yandex/docs/en/query_language/functions/bitmap_functions/) <!--hide-->