Changeset 317
- Timestamp:
- 02/27/08 21:36:42 (9 months ago)
- Location:
- trunk/thrudoc/src
- Files:
-
- 2 modified
-
MySQLBackend.cpp (modified) (1 diff)
-
MySQLBackend.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thrudoc/src/MySQLBackend.cpp
r226 r317 382 382 } 383 383 384 // copied from libmemcached_hash until it's librarizied385 static uint32_t FNV_32_INIT= 2166136261UL;386 static uint32_t FNV_32_PRIME= 16777619;387 388 384 FindReturn MySQLBackend::find_and_checkout (const string & bucket, 389 385 const string & key) 390 386 { 391 double point; 392 { 393 uint32_t hash; 394 /* this is a modified fvn algorithm, i'm seeing much better behavior 395 * with small keys when i do the xor before and after the multiply */ 396 hash= FNV_32_INIT; 397 for (unsigned int x = 0; x < key.length (); x++) 398 { 399 hash ^= key[x]; 400 hash *= FNV_32_PRIME; 401 hash ^= key[x]; 402 } 403 point = hash / (double)UINT_MAX; 404 } 387 double point = hashing.get_point (key); 405 388 406 389 if (logger->isDebugEnabled()) -
trunk/thrudoc/src/MySQLBackend.h
r226 r317 8 8 #if HAVE_LIBMYSQLCLIENT_R 9 9 10 #include <string>11 #include <set>12 #include <log4cxx/logger.h>13 10 #include "Thrudoc.h" 14 11 #include "ThrudocBackend.h" 15 12 #include "mysql_glue.h" 13 14 #include <Hashing.h> 15 #include <log4cxx/logger.h> 16 #include <set> 17 #include <string> 16 18 17 19 struct FindReturn … … 72 74 int max_value_size; 73 75 76 FNV32Hashing hashing; 77 74 78 std::set<Partition*, bool(*)(Partition*, Partition*)> * 75 79 load_partitions (const std::string & bucket);
