Skip to content

Instantly share code, notes, and snippets.

View cangyin's full-sized avatar

cangyin cangyin

View GitHub Profile
@cangyin
cangyin / bf_calculator.md
Created April 12, 2024 11:45
Bloom Filter Calculation Functions In ClickHouse

Formulas from https://hur.st/bloomfilter.

CREATE OR REPLACE FUNCTION bf_p_from_kr AS (k, r) -> pow(1 - exp((-k) / r), k);
CREATE OR REPLACE FUNCTION bf_k_from_r AS r -> round(log(2) * r);
CREATE OR REPLACE FUNCTION bf_r_from_pk AS (p, k) -> ((-k) / log(1 - exp(log(p) / k)));
CREATE OR REPLACE FUNCTION bf_r_from_mn AS (m, n) -> (m / n);

CREATE OR REPLACE FUNCTION bf_km_from_np AS (n, p) ->
    (
@cangyin
cangyin / storage_configurations.md
Last active April 12, 2024 13:43
ClickHouse Complete Storage Configurations

Complete Storage Configuration

<!--
    see https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-multiple-volumes
    see src/Disks/DiskFactory.h
    see src/Disks/StoragePolicy.cpp
-->
<clickhouse>
    <storage_configuration>