int64_t ObNewRange::hash() const { uint32_t hash_val = 0; int8_t flag = border_flag_.get_data(); /** * if it's max value, the border flag maybe is right close, * ignore it. */ if (end_key_.is_max_row()) { flag = ObBorderFlag::MAX_VALUE; } hash_val = murmurhash2(&table_id_, sizeof(uint64_t), 0); hash_val = murmurhash2(&flag, sizeof(int8_t), hash_val); if (NULL != start_key_.ptr() && start_key_.length() > 0) { hash_val = start_key_.murmurhash2(hash_val); } if (NULL != end_key_.ptr() && end_key_.length() > 0) { hash_val = end_key_.murmurhash2(hash_val); } return hash_val; };
static int s_hash_item(lv_t *item) { assert(item); if(item->type == l_str) return murmurhash2(L_STR(item), strlen(L_STR(item)), 0); if(item->type == l_sym) return murmurhash2(L_SYM(item), strlen(L_SYM(item)), 0); assert(0); }
void BloomFilter::add(string s) { store.insert(s); for (int i = 0; i < nHashFunc; i++) { // length of hashCode is 32bit. unsigned int hashCode = murmurhash2(s.c_str(), s.length(), seedsForHash[i]); // set the bit of input string. bitVec |= hashCode; } }
bool BloomFilter::contains(string s) { int bitCur = bitVec; for (int i = 0; i < nHashFunc; i++) { unsigned int hashCode = murmurhash2(s.c_str(), s.length(), seedsForHash[i]); // if some of bits in hashCode is not in bitCur, the string is not in the set. unsigned int test = bitCur & hashCode; if (test != hashCode) { return false; } } return true; }
static unsigned int hashfromkey(void *k) { return murmurhash2(k, strlen(k), 0); }
std::size_t operator()(KeyType const& x) const { assert(x.rg != 0); char const* p = x.rg; std::size_t seed = murmurhash2(p, strlen(p), x.len); return seed; }
std::size_t operator()(KeyType const& x) const { assert(x.rg != 0); char const* p = x.rg; return murmurhash2(p, strlen(p), 40); }
template <typename T> INLINE u32 murmurhash2(const T &x) { return murmurhash2(&x, sizeof(T)); }