CREATE DICTIONARY ... LAYOUT Hashed
CREATE DICTIONARY ... LAYOUT Hashed
hashed 레이아웃은 딕셔너리를 해시 테이블 형태로 완전히 메모리에 저장해요.
출처: 문서
본문
hashed
딕셔너리는 해시 테이블 형태로 완전히 메모리에 저장돼요. 딕셔너리는 어떤 식별자를 가진 원하는 만큼의 요소를 포함할 수 있어요. 실제로 키 수는 수천만 개에 이를 수 있습니다.
딕셔너리 키는 UInt64 타입이에요.
모든 종류의 소스가 지원됩니다. 업데이트 시 데이터(파일 또는 테이블에서)가 전체적으로 읽혀요.
구성 예시:
- DDL
- Configuration file
LAYOUT(HASHED())
<layout>
<hashed />
</layout>
설정이 있는 구성 예시:
- DDL
- Configuration file
LAYOUT(HASHED([SHARDS 1] [SHARD_LOAD_QUEUE_BACKLOG 10000] [MAX_LOAD_FACTOR 0.5]))
<layout>
<hashed>
<!-- If shards greater then 1 (default is `1`) the dictionary will load
data in parallel, useful if you have huge amount of elements in one
dictionary. -->
<shards>10</shards>
<!-- Size of the backlog for blocks in parallel queue.
Since the bottleneck in parallel loading is rehash, and so to avoid
stalling because of thread is doing rehash, you need to have some
backlog.
10000 is good balance between memory and speed.
Even for 10e10 elements and can handle all the load without starvation. -->
<shard_load_queue_backlog>10000</shard_load_queue_backlog>
<!-- Maximum load factor of the hash table, with greater values, the memory
is utilized more efficiently (less memory is wasted) but read/performance
may deteriorate.
Valid values: [0.5, 0.99]
Default: 0.5 -->
<max_load_factor>0.5</max_load_factor>
</hashed>
</layout>
sparse_hashed
hashed와 유사하지만 더 많은 CPU 사용을 대가로 더 적은 메모리를 사용해요.
딕셔너리 키는 UInt64 타입이에요.
구성 예시:
- DDL
- Configuration file
LAYOUT(SPARSE_HASHED([SHARDS 1] [SHARD_LOAD_QUEUE_BACKLOG 10000] [MAX_LOAD_FACTOR 0.5]))
<layout>
<sparse_hashed>
<!-- <shards>1</shards> -->
<!-- <shard_load_queue_backlog>10000</shard_load_queue_backlog> -->
<!-- <max_load_factor>0.5</max_load_factor> -->
</sparse_hashed>
</layout>
이 딕셔너리 타입에도 shards를 사용할 수 있어요. sparse_hashed는 hashed보다 느리므로 sparse_hashed에서 더 중요합니다.
complex_key_hashed
이 저장 타입은 복합 keys와 함께 사용하기 위한 것이에요. hashed와 유사합니다.
구성 예시:
- DDL
- Configuration file
LAYOUT(COMPLEX_KEY_HASHED([SHARDS 1] [SHARD_LOAD_QUEUE_BACKLOG 10000] [MAX_LOAD_FACTOR 0.5]))
<layout>
<complex_key_hashed>
<!-- <shards>1</shards> -->
<!-- <shard_load_queue_backlog>10000</shard_load_queue_backlog> -->
<!-- <max_load_factor>0.5</max_load_factor> -->
</complex_key_hashed>
</layout>
complex_key_sparse_hashed
이 저장 타입은 복합 keys와 함께 사용하기 위한 것이에요. sparse_hashed와 유사합니다.
구성 예시:
- DDL
- Configuration file
LAYOUT(COMPLEX_KEY_SPARSE_HASHED([SHARDS 1] [SHARD_LOAD_QUEUE_BACKLOG 10000] [MAX_LOAD_FACTOR 0.5]))
<layout>
<complex_key_sparse_hashed>
<!-- <shards>1</shards> -->
<!-- <shard_load_queue_backlog>10000</shard_load_queue_backlog> -->
<!-- <max_load_factor>0.5</max_load_factor> -->
</complex_key_sparse_hashed>
</layout>