コード例 #1
0
ファイル: test_bloom.c プロジェクト: carriercomm/bloomd
END_TEST

START_TEST(test_ideal_k_num)
{
    bloom_filter_params params;
    params.bytes = 2396265;
    params.capacity = 1e6;
    int res = bf_ideal_k_num(&params);
    fail_unless(res == 0);
    fail_unless(params.k_num == 13);
}
コード例 #2
0
ファイル: bloom.c プロジェクト: BillWangCS/bloomd
/*
 * Expects capacity and probability to be set,
 * and sets the bytes and k_num that should be used.
 * @return 0 on success, negative on error.
 */
int bf_params_for_capacity(bloom_filter_params *params) {
    // Sets the required size
    int res = bf_size_for_capacity_prob(params);
    if (res != 0) return res;

    // Sets the ideal k
    res = bf_ideal_k_num(params);
    if (res != 0) return res;

    // Adjust for the header size
    params->bytes += sizeof(bloom_filter_header);
    return 0;
}