fix: a stupid bug in database

This commit is contained in:
2023-12-13 10:27:53 +00:00
parent 158de68975
commit e620762102
5 changed files with 32 additions and 8 deletions

View File

@ -22,7 +22,7 @@ class String2Index {
/* Reference: http://xorshift.di.unimi.it/splitmix64.c */
str = salt1 + str + salt2;
hash_t ret = 0;
int i;
int i = 0;
for (; i + 8 <= str.length(); i += 8) {
ret ^= *reinterpret_cast<const hash_t *>(str.c_str() + i);
ret ^= *reinterpret_cast<const hash_t *>(inner_salt + (i & 15));
@ -46,10 +46,11 @@ class String2Index {
hash_t main_hash, sub_hash;
int val, nxt_idx = 0;
Node() = default;
Node(std::string str, int _val)
: main_hash(Hash(str)),
sub_hash(Hash(sub_salt1 + str + sub_salt2)),
val(_val) {}
Node(std::string str, int _val) {
main_hash = Hash(str);
sub_hash = Hash(sub_salt1 + str + sub_salt2);
val = _val;
}
};
DriveArray<Node, kBucketSize, 100> mem;