Changeset 317

Show
Ignore:
Timestamp:
02/27/08 21:36:42 (9 months ago)
Author:
rm
Message:

use the new Hashing stuff in thrucommon

Location:
trunk/thrudoc/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/thrudoc/src/MySQLBackend.cpp

    r226 r317  
    382382} 
    383383 
    384 // copied from libmemcached_hash until it's librarizied 
    385 static uint32_t FNV_32_INIT= 2166136261UL; 
    386 static uint32_t FNV_32_PRIME= 16777619; 
    387  
    388384FindReturn MySQLBackend::find_and_checkout (const string & bucket, 
    389385                                            const string & key) 
    390386{ 
    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); 
    405388 
    406389    if (logger->isDebugEnabled()) 
  • trunk/thrudoc/src/MySQLBackend.h

    r226 r317  
    88#if HAVE_LIBMYSQLCLIENT_R 
    99 
    10 #include <string> 
    11 #include <set> 
    12 #include <log4cxx/logger.h> 
    1310#include "Thrudoc.h" 
    1411#include "ThrudocBackend.h" 
    1512#include "mysql_glue.h" 
     13 
     14#include <Hashing.h> 
     15#include <log4cxx/logger.h> 
     16#include <set> 
     17#include <string> 
    1618 
    1719struct FindReturn 
     
    7274        int max_value_size; 
    7375 
     76        FNV32Hashing hashing; 
     77 
    7478        std::set<Partition*, bool(*)(Partition*, Partition*)> * 
    7579            load_partitions (const std::string & bucket);