bus-bloom.c | bus-bloom.c | |||
---|---|---|---|---|
skipping to change at line 51 | skipping to change at line 51 | |||
static void bloom_add_data( | static void bloom_add_data( | |||
uint64_t filter[], /* The filter bits */ | uint64_t filter[], /* The filter bits */ | |||
size_t size, /* Size of the filter in bytes */ | size_t size, /* Size of the filter in bytes */ | |||
unsigned k, /* Number of hash functions */ | unsigned k, /* Number of hash functions */ | |||
const void *data, /* Data to hash */ | const void *data, /* Data to hash */ | |||
size_t n) { /* Size of data to hash in bytes */ | size_t n) { /* Size of data to hash in bytes */ | |||
uint8_t h[8]; | uint8_t h[8]; | |||
uint64_t m; | uint64_t m; | |||
unsigned w, i, c = 0; | unsigned w, i, c = 0; | |||
unsigned hash_index; | ||||
assert(size > 0); | assert(size > 0); | |||
assert(k > 0); | assert(k > 0); | |||
/* Determine bits in filter */ | /* Determine bits in filter */ | |||
m = size * 8; | m = size * 8; | |||
/* Determine how many bytes we need to generate a bit index 0..m fo r this filter */ | /* Determine how many bytes we need to generate a bit index 0..m fo r this filter */ | |||
w = (u64log2(m) + 7) / 8; | w = (u64log2(m) + 7) / 8; | |||
assert(w <= sizeof(uint64_t)); | assert(w <= sizeof(uint64_t)); | |||
/* Make sure we have enough hash keys to generate m * k bits | /* Make sure we have enough hash keys to generate m * k bits | |||
* of hash value. Note that SipHash24 generates 64 bits of | * of hash value. Note that SipHash24 generates 64 bits of | |||
* hash value for each 128 bits of hash key. */ | * hash value for each 128 bits of hash key. */ | |||
assert(k * w <= ELEMENTSOF(hash_keys) * 8); | assert(k * w <= ELEMENTSOF(hash_keys) * 8); | |||
for (i = 0; i < k; i++) { | for (i = 0, hash_index = 0; i < k; i++) { | |||
uint64_t p = 0; | uint64_t p = 0; | |||
unsigned d; | unsigned d; | |||
for (d = 0; d < w; d++) { | for (d = 0; d < w; d++) { | |||
if (c <= 0) { | if (c <= 0) { | |||
siphash24(h, data, n, hash_keys[i++].bytes) ; | siphash24(h, data, n, hash_keys[hash_index+ +].bytes); | |||
c += 8; | c += 8; | |||
} | } | |||
p = (p << 8ULL) | (uint64_t) h[8 - c]; | p = (p << 8ULL) | (uint64_t) h[8 - c]; | |||
c--; | c--; | |||
} | } | |||
p &= m - 1; | p &= m - 1; | |||
set_bit(filter, p); | set_bit(filter, p); | |||
} | } | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 3 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |