Bitmap Functions
Bitmaps can be constructed in two ways. The first way is constructed by aggregation function groupBitmap with -State, the other way is to constructed a bitmap from an Array object.
bitmapAnd
Introduced in: v20.1
Syntax
Arguments
bitmap1— First bitmap object.AggregateFunction(groupBitmap, T).bitmap2— Second bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns a bitmap containing bits present in both input bitmaps. AggregateFunction(groupBitmap, T)
Examples
Usage example
bitmapAndCardinality
Introduced in: v20.1
Syntax
Arguments
bitmap1— First bitmap object.AggregateFunction(groupBitmap, T).bitmap2— Second bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns the number of set bits in the intersection of the two bitmaps. UInt64.
Examples
Usage example
bitmapAndnot
Introduced in: v20.1
Syntax
Arguments
bitmap1— First bitmap object.AggregateFunction(groupBitmap, T).bitmap2— Second bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns a bitmap containing set bits present in the first bitmap but not in the second. AggregateFunction(groupBitmap, T)
Examples
Usage example
bitmapAndnotCardinality
Introduced in: v20.1
Syntax
Arguments
bitmap1— First bitmap object.AggregateFunction(groupBitmap, T).bitmap2— Second bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns the number of set bits in the result of bitmap1 AND-NOT bitmap2. UInt64.
Examples
Usage example
bitmapBuild
Introduced in: v20.1
Syntax
Arguments
array— Unsigned integer array.Array(UInt*).
Returned value
Returns a bitmap from the provided array. AggregateFunction(groupBitmap, T)
Examples
Usage example
bitmapCardinality
Introduced in: v20.1
Syntax
Arguments
bitmap— Bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns the number of bits set in the bitmap. UInt64
Examples
Usage example
bitmapContains
Introduced in: v20.1
Syntax
Arguments
bitmap— Bitmap object.AggregateFunction(groupBitmap, T).value— Element to check for. (U)Int8/16/32/64
Returned value
Returns 1 if the bitmap contains the specified value, otherwise 0. UInt8
Examples
Usage example
bitmapHasAll
Introduced in: v20.1
Syntax
Arguments
bitmap1— First bitmap object.AggregateFunction(groupBitmap, T).bitmap2— Second bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns 1 if all set bits of the second bitmap are present in the first bitmap, otherwise 0. UInt8
Examples
Usage example
bitmapHasAny
Introduced in: v20.1
Syntax
Arguments
bitmap1— First bitmap object.AggregateFunction(groupBitmap, T).bitmap2— Second bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns 1 if any bits of the second bitmap are present in the first bitmap, otherwise 0. UInt8
Examples
Usage example
bitmapMax
Introduced in: v20.1
Syntax
Arguments
bitmap— Bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns the position of the greatest bit set in the bitmap, otherwise 0. UInt64.
Examples
Usage example
bitmapMin
Introduced in: v20.1
Syntax
Arguments
bitmap— Bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns the position of the smallest bit set in the bitmap, or UINT32_MAX/UINT64_MAX. UInt64.
Examples
Usage example
bitmapOr
Introduced in: v20.1
Syntax
Arguments
bitmap1— First bitmap object.AggregateFunction(groupBitmap, T).bitmap2— Second bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns a bitmap containing set bits present in either input bitmap. AggregateFunction(groupBitmap, T)
Examples
Usage example
bitmapOrCardinality
Introduced in: v20.1
Syntax
Arguments
bitmap1— First bitmap object.AggregateFunction(groupBitmap, T).bitmap2— Second bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns the number of set bits in the union of the two bitmaps. UInt64.
Examples
Usage example
bitmapSubsetInRange
Introduced in: v20.1
Syntax
Arguments
bitmap— Bitmap to extract the subset from.AggregateFunction(groupBitmap, T).start— Start of the range (inclusive).UInt*end— End of the range (exclusive).UInt*
Returned value
Returns a bitmap containing only the set bits in the specified range. AggregateFunction(groupBitmap, T)
Examples
Usage example
bitmapSubsetLimit
Introduced in: v20.1
Syntax
Arguments
bitmap— Bitmap object.AggregateFunction(groupBitmap, T).range_start— Start of the range (inclusive).UInt32cardinality_limit— Maximum cardinality of the subset.UInt32
Returned value
Returns a bitmap containing at most cardinality_limit set bits, starting from range_start. AggregateFunction(groupBitmap, T)
Examples
Usage example
bitmapToArray
Introduced in: v20.1
Syntax
Arguments
bitmap— Bitmap to convert.AggregateFunction(groupBitmap, T).
Returned value
Returns an array of unsigned integers contained in the bitmap. Array(UInt*)
Examples
Usage example
bitmapTransform
Introduced in: v20.1
Syntax
Arguments
bitmap— Bitmap object.AggregateFunction(groupBitmap, T).from_array— Array of original set bits to be replaced.Array(T).to_array— Array of new set bits to replace with.Array(T).
Returned value
Returns a bitmap with elements transformed according to the given mapping. AggregateFunction(groupBitmap, T).
Examples
Usage example
bitmapXor
Introduced in: v20.1
Syntax
Arguments
bitmap1— First bitmap object.AggregateFunction(groupBitmap, T).bitmap2— Second bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns a bitmap containing set bits present in either input bitmap, but not in both. AggregateFunction(groupBitmap, T)
Examples
Usage example
bitmapXorCardinality
Introduced in: v20.1
Syntax
Arguments
bitmap1— First bitmap object.AggregateFunction(groupBitmap, T).bitmap2— Second bitmap object.AggregateFunction(groupBitmap, T).
Returned value
Returns the number of set bits in the symmetric difference of the two bitmaps. UInt64.
Examples
Usage example
subBitmap
Introduced in: v21.9
Syntax
Arguments
bitmap— Bitmap object.AggregateFunction(groupBitmap, T).offset— Number of set bits to skip from the beginning (zero-based).UInt32cardinality_limit— Maximum number of set bits to include in the subset.UInt32
Returned value
Returns a bitmap containing at most limit set bits, starting after skipping offset set bits in ascending order. AggregateFunction(groupBitmap, T)
Examples
Usage example