projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Committing work for next release (got to do something over lunch aye?)
[m6w6/libmemcached]
/
lib
/
memcached_hash.c
diff --git
a/lib/memcached_hash.c
b/lib/memcached_hash.c
index 961c794b58a686f6c1d28eb3a8f946d67c47842e..87c59d510ae55cbc32cff6def7d1817acd8104b6 100644
(file)
--- a/
lib/memcached_hash.c
+++ b/
lib/memcached_hash.c
@@
-1,10
+1,10
@@
#include "common.h"
/* Defines */
#include "common.h"
/* Defines */
-static uint64_t FNV_64_INIT= 0xcbf29ce484222325L;
-static uint64_t FNV_64_PRIME= 0x100000001b3L;
+static uint64_t FNV_64_INIT= 0xcbf29ce484222325L
L
;
+static uint64_t FNV_64_PRIME= 0x100000001b3L
L
;
-static uint32_t FNV_32_INIT= 2166136261L;
+static uint32_t FNV_32_INIT= 2166136261
U
L;
static uint32_t FNV_32_PRIME= 16777619;
/* Prototypes */
static uint32_t FNV_32_PRIME= 16777619;
/* Prototypes */
@@
-17,6
+17,8
@@
unsigned int memcached_generate_hash(memcached_st *ptr, char *key, size_t key_le
uint64_t hash= 1; /* Just here to remove compile warning */
unsigned int x;
uint64_t hash= 1; /* Just here to remove compile warning */
unsigned int x;
+ WATCHPOINT_ASSERT(ptr->number_of_hosts);
+
switch (ptr->hash)
{
case MEMCACHED_HASH_DEFAULT:
switch (ptr->hash)
{
case MEMCACHED_HASH_DEFAULT:
@@
-75,16
+77,27
@@
unsigned int memcached_generate_hash(memcached_st *ptr, char *key, size_t key_le
hash= internal_generate_ketama_md5(key, key_length);
break;
}
hash= internal_generate_ketama_md5(key, key_length);
break;
}
+ case MEMCACHED_HASH_HSIEH:
+ {
+ hash= hsieh_hash(key, key_length);
+ break;
+ }
}
WATCHPOINT_ASSERT(hash);
}
WATCHPOINT_ASSERT(hash);
- if (ptr->flags & MEM_USE_KETAMA)
+
+ if (ptr->distribution == MEMCACHED_DISTRIBUTION_MODULA)
{
{
- WATCHPOINT_ASSERT(0);
- return 0;
+ return hash % ptr->number_of_hosts;
}
else
}
else
- return hash % ptr->number_of_hosts;
+ {
+ unsigned int server_key;
+
+ server_key= hash % MEMCACHED_WHEEL_SIZE;
+
+ return ptr->wheel[server_key];
+ }
}
static uint64_t internal_generate_hash(char *key, size_t key_length)
}
static uint64_t internal_generate_hash(char *key, size_t key_length)