예제 #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);
}
예제 #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);
}
예제 #3
0
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);
}
예제 #4
0
Value::Value(const Key & key) :
   Value()
{
   impl = new (clone_storage()) BSON::Type (Types::Utf8(key.c_str()));
}
예제 #5
0
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);
}