END_TEST START_TEST(test_ideal_k_num) { bloom_filter_params params; params.bytes = 2396265; params.capacity = 1e6; int res = bf_ideal_k_num(¶ms); fail_unless(res == 0); fail_unless(params.k_num == 13); }
/* * 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; }