Commit ff6aeca9 authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

changed hashing function for products

parent 50184891
...@@ -260,7 +260,7 @@ class DataStoreImpl { ...@@ -260,7 +260,7 @@ class DataStoreImpl {
// hash the name to get the provider id // hash the name to get the provider id
long unsigned db_idx = 0; long unsigned db_idx = 0;
uint64_t hash; uint64_t hash;
hash = hashString(productID.m_key); hash = hashString(productID.m_key.c_str(), sizeof(ItemDescriptor));
ch_placement_find_closest(m_product_dbs.chi, hash, 1, &db_idx); ch_placement_find_closest(m_product_dbs.chi, hash, 1, &db_idx);
return m_product_dbs.dbs[db_idx]; return m_product_dbs.dbs[db_idx];
} }
...@@ -386,7 +386,7 @@ class DataStoreImpl { ...@@ -386,7 +386,7 @@ class DataStoreImpl {
// hash the name to get the provider id // hash the name to get the provider id
long unsigned db_idx = 0; long unsigned db_idx = 0;
uint64_t hash; uint64_t hash;
hash = hashString(containerName); hash = hashString(containerName.c_str(), containerName.size());
ch_placement_find_closest(m_dataset_dbs.chi, hash, 1, &db_idx); ch_placement_find_closest(m_dataset_dbs.chi, hash, 1, &db_idx);
return m_dataset_dbs.dbs[db_idx]; return m_dataset_dbs.dbs[db_idx];
} }
......
...@@ -8,10 +8,11 @@ ...@@ -8,10 +8,11 @@
namespace hepnos { namespace hepnos {
inline size_t hashString(const std::string& str) { inline size_t hashString(const char* str, size_t size) {
size_t hash = 14695981039346656037ULL; size_t hash = 14695981039346656037ULL;
size_t prime = 1099511628211ULL; size_t prime = 1099511628211ULL;
for(const auto& c : str) { for(size_t i = 0; i < size; i++) {
char c = str[i];
hash = hash ^ c; hash = hash ^ c;
hash *= prime; hash *= prime;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment