Beispiel #1
0
unsigned long BloomFilter::hash2(const Key& key) {
    unsigned long hash = 0;
    for (unsigned i = 0; i < key.length(); i++) {
        hash = key.c_str()[i] + (hash << 6) + (hash << 16) - hash;
    }
    long double d_hash = (long double)hash;

    d_hash *= (0.5 * (sqrtl(5) - 1));
    d_hash = d_hash / 10.0 - floorl(d_hash / 10.0);
    d_hash *= (double)m_length;

    return (unsigned long)floorl(d_hash);
}
Beispiel #2
0
unsigned long BloomFilter::hash1(const Key& key) {
    unsigned long hash = 5381;
    for (unsigned i = 0; i < key.length(); i++) {
        hash = ((hash << 5) + hash) + key.c_str()[i];  // hash * 33 + c
    }
    double d_hash = (double)hash;

    d_hash *= (0.5 * (sqrt(5) - 1));
    d_hash -= floor(d_hash);
    d_hash *= (double)m_length;

    return (unsigned long)floor(d_hash);
}
unsigned long BloomFilter::hash2(const Key& key) {
	unsigned long hash = 0;
	unsigned int i=0;
	for (i=0; i< key.length(); i++) {
		hash = key.c_str()[i] + (hash << 6) + (hash << 16) - hash;
	}
	double d_hash = (double) hash;

	d_hash *= (0.5*(sqrt(5)-1));
	d_hash -= floor(d_hash);
	d_hash *= (double)m_length;

	return (unsigned long)floor(d_hash);
}
Beispiel #4
0
Value::Value(const Key & key) :
   Value()
{
   impl = new (clone_storage()) BSON::Type (Types::Utf8(key.c_str()));
}
inline int bind_key(sqlite3_stmt* stmt, const Key& key){
  return sqlite3_bind_int64(stmt, 1, MurmurHash64A(key.c_str(), (int) key.length()));
  //return sqlite3_bind_text(stmt, 1, key.c_str(), (int) key.length(), SQLITE_STATIC);
}