Categories:

Aggregate functions (Counting Distinct Values)

BITMAP_ABSOLUTE_POSITION

Computes the absolute bit position from a bucket number and a relative bit position. This is the inverse of the BITMAP_BUCKET_NUMBER and BITMAP_BIT_POSITION functions.

See also:

Using Bitmaps to Compute Distinct Values for Hierarchical Aggregations

Syntax

BITMAP_ABSOLUTE_POSITION( <bucket_number> , <relative_position> )

Arguments

bucket_number

The bucket number (returned by BITMAP_BUCKET_NUMBER).

relative_position

The relative bit position within the bucket (returned by BITMAP_BIT_POSITION).

Returns

An INTEGER representing the original absolute position (value).

Examples

See Using Bitmaps to Compute Distinct Values for Hierarchical Aggregations.

SELECT
  $1 pos,
  BITMAP_BUCKET_NUMBER(pos) bucket,
  BITMAP_BIT_POSITION(pos) bit_pos,
  BITMAP_ABSOLUTE_POSITION(bucket, bit_pos)
FROM VALUES (1), (123), (123456), (1234567);
+---------+--------+---------+-------------------------------------------+
| POS     | BUCKET | BIT_POS | BITMAP_ABSOLUTE_POSITION(BUCKET, BIT_POS) |
+---------+--------+---------+-------------------------------------------+
| 1       | 1      | 0       | 1                                         |
| 123     | 1      | 122     | 123                                       |
| 123456  | 4      | 25151   | 123456                                    |
| 1234567 | 38     | 22150   | 1234567                                   |
+---------+--------+---------+-------------------------------------------+