cmph_uint32 chd_ph_search_packed(void *packed_mphf, const char *key, cmph_uint32 keylen) { register CMPH_HASH hl_type = *(cmph_uint32 *)packed_mphf; register cmph_uint8 *hl_ptr = (cmph_uint8 *)(packed_mphf) + 4; register cmph_uint32 * ptr = (cmph_uint32 *)(hl_ptr + hash_state_packed_size(hl_type)); register cmph_uint32 n = *ptr++; register cmph_uint32 nbuckets = *ptr++; cmph_uint32 hl[3]; register cmph_uint32 disp,position; register cmph_uint32 probe0_num,probe1_num; register cmph_uint32 f,g,h; hash_vector_packed(hl_ptr, hl_type, key, keylen, hl); g = hl[0] % nbuckets; f = hl[1] % n; h = hl[2] % (n-1) + 1; disp = compressed_seq_query_packed(ptr, g); probe0_num = disp % n; probe1_num = disp/n; position = (cmph_uint32)((f + ((cmph_uint64 )h)*probe0_num + probe1_num) % n); return position; }
static cmph_uint32 brz_fch_search_packed(cmph_uint32 *packed_mphf, const char *key, cmph_uint32 keylen, cmph_uint32 * fingerprint) { register CMPH_HASH h0_type = *packed_mphf++; register cmph_uint32 *h0_ptr = packed_mphf; packed_mphf = (cmph_uint32 *)(((cmph_uint8 *)packed_mphf) + hash_state_packed_size(h0_type)); register cmph_uint32 k = *packed_mphf++; register double c = (double)(*((cmph_uint64*)packed_mphf)); packed_mphf += 2; register CMPH_HASH h1_type = *packed_mphf++; register CMPH_HASH h2_type = *packed_mphf++; register cmph_uint8 * size = (cmph_uint8 *) packed_mphf; packed_mphf = (cmph_uint32 *)(size + k); register cmph_uint32 * offset = packed_mphf; packed_mphf += k; register cmph_uint32 h0; hash_vector_packed(h0_ptr, h0_type, key, keylen, fingerprint); h0 = fingerprint[2] % k; register cmph_uint32 m = size[h0]; register cmph_uint32 b = fch_calc_b(c, m); register double p1 = fch_calc_p1(m); register double p2 = fch_calc_p2(b); #if defined (__ia64) || defined (__x86_64__) register cmph_uint64 * g_is_ptr = (cmph_uint64 *)packed_mphf; #else register cmph_uint32 * g_is_ptr = packed_mphf; #endif register cmph_uint8 * h1_ptr = (cmph_uint8 *) g_is_ptr[h0]; register cmph_uint8 * h2_ptr = h1_ptr + hash_state_packed_size(h1_type); register cmph_uint8 * g = h2_ptr + hash_state_packed_size(h2_type); register cmph_uint32 h1 = hash_packed(h1_ptr, h1_type, key, keylen) % m; register cmph_uint32 h2 = hash_packed(h2_ptr, h2_type, key, keylen) % m; register cmph_uint8 mphf_bucket = 0; h1 = mixh10h11h12(b, p1, p2, h1); mphf_bucket = (cmph_uint8)((h2 + g[h1]) % m); return (mphf_bucket + offset[h0]); }
static cmph_uint32 brz_bmz8_search_packed(cmph_uint32 *packed_mphf, const char *key, cmph_uint32 keylen, cmph_uint32 * fingerprint) { register CMPH_HASH h0_type = *packed_mphf++; register cmph_uint32 *h0_ptr = packed_mphf; packed_mphf = (cmph_uint32 *)(((cmph_uint8 *)packed_mphf) + hash_state_packed_size(h0_type)); register cmph_uint32 k = *packed_mphf++; register double c = (double)(*((cmph_uint64*)packed_mphf)); packed_mphf += 2; register CMPH_HASH h1_type = *packed_mphf++; register CMPH_HASH h2_type = *packed_mphf++; register cmph_uint8 * size = (cmph_uint8 *) packed_mphf; packed_mphf = (cmph_uint32 *)(size + k); register cmph_uint32 * offset = packed_mphf; packed_mphf += k; register cmph_uint32 h0; hash_vector_packed(h0_ptr, h0_type, key, keylen, fingerprint); h0 = fingerprint[2] % k; register cmph_uint32 m = size[h0]; register cmph_uint32 n = (cmph_uint32)ceil(c * m); #if defined (__ia64) || defined (__x86_64__) register cmph_uint64 * g_is_ptr = (cmph_uint64 *)packed_mphf; #else register cmph_uint32 * g_is_ptr = packed_mphf; #endif register cmph_uint8 * h1_ptr = (cmph_uint8 *) g_is_ptr[h0]; register cmph_uint8 * h2_ptr = h1_ptr + hash_state_packed_size(h1_type); register cmph_uint8 * g = h2_ptr + hash_state_packed_size(h2_type); register cmph_uint32 h1 = hash_packed(h1_ptr, h1_type, key, keylen) % n; register cmph_uint32 h2 = hash_packed(h2_ptr, h2_type, key, keylen) % n; register cmph_uint8 mphf_bucket; if (h1 == h2 && ++h2 >= n) h2 = 0; mphf_bucket = (cmph_uint8)(g[h1] + g[h2]); DEBUGP("key: %s h1: %u h2: %u h0: %u\n", key, h1, h2, h0); DEBUGP("Address: %u\n", mphf_bucket + offset[h0]); return (mphf_bucket + offset[h0]); }