/**
 * Hash a normalized key.
 * @param key       the key to hash
 * @param type      whether the key is a normal key or a "stripped" key
 * @param seed      the seed value for the hash function
 */
uint32_t castle_norm_key_hash(const struct castle_norm_key *key,
                              c_btree_hash_enum_t type,
                              uint32_t seed)
{
    const unsigned char *data, *boundary;
    size_t len = castle_norm_key_len_get(key, &data), n_dim;
    unsigned int dim;

    switch (type)
    {
        case HASH_WHOLE_KEY:
            return murmur_hash_32(data, len, seed);
        case HASH_STRIPPED_KEYS:
            n_dim = castle_norm_key_dim_get(&data);
            BUG_ON(n_dim < HASH_STRIPPED_DIMS);
            for (dim = 0, boundary = data; dim < HASH_STRIPPED_DIMS; ++dim)
                boundary = castle_norm_key_dim_next(boundary);
            return murmur_hash_32(data, boundary - data, seed);
        default:
            BUG();
    }
}
示例#2
0
static PyObject * murmur_hash2_aligned(PyObject *self, PyObject *args)
{
    return murmur_hash_32(self, args, MurmurHashAligned2);
}
示例#3
0
static PyObject * murmur_hash2_neutral(PyObject *self, PyObject *args)
{
    return murmur_hash_32(self, args, MurmurHashNeutral2);
}
示例#4
0
static PyObject * murmur_hash2a(PyObject *self, PyObject *args)
{
    return murmur_hash_32(self, args, MurmurHash2A);
}