본문으로 바로가기
본문으로 바로가기

groupBitmapXor

groupBitmapXor

도입 버전: v20.1

비트맵 컬럼의 XOR을 계산하고, 그 결과 비트맵의 기수성(cardinality)을 반환합니다. 접미사 조합자 -State를 추가하면 비트맵 객체를 반환합니다.

문법

groupBitmapXor(expr)
groupBitmapXorState(expr)

인수

반환 값

UInt64 타입의 개수(count)를 반환하거나, -State를 사용하는 경우 비트맵 객체를 반환합니다. UInt64

예시

사용 예시

CREATE TABLE bitmap_column_expr_test2
(
    tag_id String,
    z AggregateFunction(groupBitmap, UInt32)
)
ENGINE = MergeTree
ORDER BY tag_id;

INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] AS Array(UInt32))));
INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] AS Array(UInt32))));
INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] AS Array(UInt32))));

SELECT groupBitmapXor(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%');
┌─groupBitmapXor(z)─┐
│              10   │
└───────────────────┘

-State 콤비네이터 사용

SELECT arraySort(bitmapToArray(groupBitmapXorState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%');
┌─arraySort(bitmapToArray(groupBitmapXorState(z)))─┐
│ [1, 3, 5, 6, 8, 10, 11, 13, 14, 15]              │
└──────────────────────────────────────────────────┘