ClickHouse/docs/ja/sql-reference/functions/bitmap-functions.md
Ivan Blinkov cd14f9ebcb
SQL reference refactoring (#10857)
* split up select.md

* array-join.md basic refactoring

* distinct.md basic refactoring

* format.md basic refactoring

* from.md basic refactoring

* group-by.md basic refactoring

* having.md basic refactoring

* additional index.md refactoring

* into-outfile.md basic refactoring

* join.md basic refactoring

* limit.md basic refactoring

* limit-by.md basic refactoring

* order-by.md basic refactoring

* prewhere.md basic refactoring

* adjust operators/index.md links

* adjust sample.md links

* adjust more links

* adjust operatots links

* fix some links

* adjust aggregate function article titles

* basic refactor of remaining select clauses

* absolute paths in make_links.sh

* run make_links.sh

* remove old select.md locations

* translate docs/es

* translate docs/fr

* translate docs/fa

* remove old operators.md location

* change operators.md links

* adjust links in docs/es

* adjust links in docs/es

* minor texts adjustments

* wip

* update machine translations to use new links

* fix changelog

* es build fixes

* get rid of some select.md links

* temporary adjust ru links

* temporary adjust more ru links

* improve curly brace handling

* adjust ru as well

* fa build fix

* ru link fixes

* zh link fixes

* temporary disable part of anchor checks
2020-05-15 07:34:54 +03:00

11 KiB
Raw Blame History

machine_translated machine_translated_rev toc_priority toc_title
true 72537a2d52 49 ビットマ

ビットマップ関数

And、or、xor、notなどの数式の計算を使用しながら、新しいビットマップまたは基数を返すことです。

ビットマップオブジェクトの構築方法には2種類あります。 一つは-Stateを持つ集計関数groupBitmapによって構築され、もう一つはArray Objectによって構築されます。 でも変換するビットマップオブジェクト配列のオブジェクトです。

RoaringBitmapは、ビットマップオブジェクトの実際の格納中にデータ構造にラップされます。 基数が32以下の場合、Set objetが使用されます。 基数が32より大きい場合は、RoaringBitmapオブジェクトを使用します。 そのため、低基数セットの保存が高速になります。

RoaringBitmapの詳細については、以下を参照してください: クロアリング.

bitmapBuild

符号なし整数配列からビットマップを作成します。

bitmapBuild(array)

パラメータ

  • array unsigned integer array.

SELECT bitmapBuild([1, 2, 3, 4, 5]) AS res, toTypeName(res)
┌─res─┬─toTypeName(bitmapBuild([1, 2, 3, 4, 5]))─────┐
│     │ AggregateFunction(groupBitmap, UInt8)    │
└─────┴──────────────────────────────────────────────┘

bitmapToArray

ビットマップを整数配列に変換します。

bitmapToArray(bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapToArray(bitmapBuild([1, 2, 3, 4, 5])) AS res
┌─res─────────┐
│ [1,2,3,4,5] │
└─────────────┘

bitmapSubsetInRange

指定された範囲のサブセットを返します(range_endは含まれません)。

bitmapSubsetInRange(bitmap, range_start, range_end)

パラメータ

SELECT bitmapToArray(bitmapSubsetInRange(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res
┌─res───────────────┐
│ [30,31,32,33,100] │
└───────────────────┘

bitmapSubsetLimit

ビットマップのサブセットを作成します。 range_startcardinality_limit.

構文

bitmapSubsetLimit(bitmap, range_start, cardinality_limit)

パラメータ

  • bitmap ビットマップ.
  • range_start The subset starting point. Type: UInt32.
  • cardinality_limit The subset cardinality upper limit. Type: UInt32.

戻り値

サブセット。

タイプ: Bitmap object.

クエリ:

SELECT bitmapToArray(bitmapSubsetLimit(bitmapBuild([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500]), toUInt32(30), toUInt32(200))) AS res

結果:

┌─res───────────────────────┐
│ [30,31,32,33,100,200,500] │
└───────────────────────────┘

bitmapContains

かどうかをチェックしますビットマップを含む要素になります。

bitmapContains(haystack, needle)

パラメータ

  • haystack ビットマップ、関数が検索する場所。
  • needle Value that the function searches. Type: UInt32.

戻り値

  • 0 — If haystack 含まない needle.
  • 1 — If haystack 含む needle.

タイプ: UInt8.

SELECT bitmapContains(bitmapBuild([1,5,7,9]), toUInt32(9)) AS res
┌─res─┐
│  1  │
└─────┘

bitmapHasAny

るかどうかを判二つのビットマップしていることで交差点にある。

bitmapHasAny(bitmap1, bitmap2)

あなたがそれを確信している場合 bitmap2 厳密に一つの要素が含まれています。 bitmapContains 機能。 これは、より効率的に動作します。

パラメータ

  • bitmap* bitmap object.

戻り値

  • 1,if bitmap1bitmap2 少なくとも一つの同様の要素があります。
  • 0 そうでなければ

SELECT bitmapHasAny(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res
┌─res─┐
│  1  │
└─────┘

bitmapHasAll

類似する hasAll(array, array) 返り値が1の場合は最初のビットマップを含むすべての要素は、0です。 二番目の引数が空のビットマップの場合は、1を返します。

bitmapHasAll(bitmap,bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapHasAll(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res
┌─res─┐
│  0  │
└─────┘

bitmapCardinality

UInt64型のビットマップ基数を再実行します。

bitmapCardinality(bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapCardinality(bitmapBuild([1, 2, 3, 4, 5])) AS res
┌─res─┐
│   5 │
└─────┘

bitmapMin

セット内のUInt64型の最小値を再実行し、セットが空の場合はUINT32_MAX。

bitmapMin(bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapMin(bitmapBuild([1, 2, 3, 4, 5])) AS res
┌─res─┐
│   1 │
└─────┘

bitmapMax

セット内のUInt64型の最大値を再試行し、セットが空の場合は0を再試行します。

bitmapMax(bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapMax(bitmapBuild([1, 2, 3, 4, 5])) AS res
┌─res─┐
│   5 │
└─────┘

bitmapTransform

ビットマップ内の値の配列を別の値の配列に変換すると、結果は新しいビットマップになります。

bitmapTransform(bitmap, from_array, to_array)

パラメータ

  • bitmap bitmap object.
  • from_array UInt32 array. For idx in range [0, from_array.size()), if bitmap contains from_array[idx], then replace it with to_array[idx]. Note that the result depends on array ordering if there are common elements between from_array and to_array.
  • to_array UInt32 array, its size shall be the same to from_array.

SELECT bitmapToArray(bitmapTransform(bitmapBuild([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), cast([5,999,2] as Array(UInt32)), cast([2,888,20] as Array(UInt32)))) AS res
┌─res───────────────────┐
│ [1,3,4,6,7,8,9,10,20] │
└───────────────────────┘

bitmapAnd

二つのビットマップと計算、結果は新しいビットマップです。

bitmapAnd(bitmap,bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapToArray(bitmapAnd(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res
┌─res─┐
│ [3] │
└─────┘

bitmapOr

結果は新しいビットマップです。

bitmapOr(bitmap,bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapToArray(bitmapOr(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res
┌─res─────────┐
│ [1,2,3,4,5] │
└─────────────┘

bitmapXor

二つのビットマップxorの計算は、結果は新しいビットマップです。

bitmapXor(bitmap,bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapToArray(bitmapXor(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res
┌─res───────┐
│ [1,2,4,5] │
└───────────┘

bitmapAndnot

二つのビットマップandnot計算、結果は新しいビットマップです。

bitmapAndnot(bitmap,bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapToArray(bitmapAndnot(bitmapBuild([1,2,3]),bitmapBuild([3,4,5]))) AS res
┌─res───┐
│ [1,2] │
└───────┘

bitmapAndCardinality

Uint64型の基数を返します。

bitmapAndCardinality(bitmap,bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapAndCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res;
┌─res─┐
│   1 │
└─────┘

bitmapOrCardinality

Uint64型の基数を返します。

bitmapOrCardinality(bitmap,bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapOrCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res;
┌─res─┐
│   5 │
└─────┘

bitmapXorCardinality

Uint64型の基数を返します。

bitmapXorCardinality(bitmap,bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapXorCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res;
┌─res─┐
│   4 │
└─────┘

bitmapAndnotCardinality

Uint64型の基数を返します。

bitmapAndnotCardinality(bitmap,bitmap)

パラメータ

  • bitmap bitmap object.

SELECT bitmapAndnotCardinality(bitmapBuild([1,2,3]),bitmapBuild([3,4,5])) AS res;
┌─res─┐
│   2 │
└─────┘

元の記事