END_TEST START_TEST(test_size_for_capacity_prob) { bloom_filter_params params; params.capacity = 1e6; params.fp_probability = 1e-4; int res = bf_size_for_capacity_prob(¶ms); fail_unless(res == 0); fail_unless(params.bytes == 2396265); }
/* * 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; }