ENABLE_UTILLIB
SETSOCKOPT_SANITY
ENABLE_HSIEH_HASH
+ENABLE_MURMUR_HASH
PROTOCOL_BINARY_TEST
WITH_MEMCACHED
ENABLE_DEPRECATED
}
#endif
+#ifdef HAVE_MURMUR_HASH
uint32_t libhashkit_murmur(const char *key, size_t key_length)
{
return hashkit_murmur(key, key_length, NULL);
}
+#endif
uint32_t libhashkit_jenkins(const char *key, size_t key_length)
{
uint32_t libhashkit_hsieh(const char *key, size_t key_length);
#endif
+#ifdef HAVE_MURMUR_HASH
HASHKIT_API
uint32_t libhashkit_murmur(const char *key, size_t key_length);
+#endif
HASHKIT_API
uint32_t libhashkit_jenkins(const char *key, size_t key_length);
uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context);
#endif
+#ifdef HAVE_MURMUR_HASH
HASHKIT_LOCAL
uint32_t hashkit_murmur(const char *key, size_t key_length, void *context);
+#endif
HASHKIT_LOCAL
uint32_t hashkit_jenkins(const char *key, size_t key_length, void *context);
return 1;
#endif
case HASHKIT_HASH_MURMUR:
+#ifdef HAVE_MURMUR_HASH
return libhashkit_murmur(key, key_length);
+#else
+ return 1;
+#endif
case HASHKIT_HASH_JENKINS:
return libhashkit_jenkins(key, key_length);
case HASHKIT_HASH_CUSTOM:
return HASHKIT_FAILURE;
#endif
case HASHKIT_HASH_MURMUR:
+#ifdef HAVE_MURMUR_HASH
self->function= hashkit_murmur;
break;
+#else
+ return HASHKIT_FAILURE;
+#endif
case HASHKIT_HASH_JENKINS:
self->function= hashkit_jenkins;
break;
return HASHKIT_HASH_HSIEH;
}
#endif
+#ifdef HAVE_MURMUR_HASH
else if (function == hashkit_murmur)
{
return HASHKIT_HASH_MURMUR;
}
+#endif
else if (function == hashkit_jenkins)
{
return HASHKIT_HASH_JENKINS;
libhashkit/jenkins.c \
libhashkit/ketama.c \
libhashkit/md5.c \
- libhashkit/murmur.c \
libhashkit/one_at_a_time.c \
libhashkit/strerror.c
libhashkit_libhashkit_la_SOURCES+= libhashkit/hsieh.c
endif
+if INCLUDE_MURMUR_SRC
+libhashkit_libhashkit_la_SOURCES+= libhashkit/murmur.c
+endif
+
libhashkit_libhashkit_la_CFLAGS= \
${AM_CFLAGS} \
-DBUILDING_HASHKIT
AC_DEFUN([ENABLE_HSIEH_HASH],
[AC_ARG_ENABLE([hsieh_hash],
[AS_HELP_STRING([--enable-hsieh_hash],
- [build with support for hsieh hashing. @<:default=off@:>@])],
+ [build with support for hsieh hashing. @<:@default=off@:>@])],
[ac_cv_enable_hsieh_hash=yes],
[ac_cv_enable_hsieh_hash=no])
--- /dev/null
+dnl ---------------------------------------------------------------------------
+dnl Macro: ENABLE_MURMUR_HASH
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([ENABLE_MURMUR_HASH],
+ [AC_ARG_ENABLE([murmur_hash],
+ [AS_HELP_STRING([--disable-murmur_hash],
+ [build with support for murmur hashing. @<:@default=on@:>@])],
+ [ac_cv_enable_murmur_hash=no],
+ [ac_cv_enable_murmur_hash=yes])
+
+ AS_IF([test "$ac_cv_enable_murmur_hash" = "yes"],
+ [AC_DEFINE([HAVE_MURMUR_HASH], [1], [Enables murmur hashing support])])
+
+ AM_CONDITIONAL([INCLUDE_MURMUR_SRC], [test "$ac_cv_enable_murmur_hash" = "yes"])
+])
+dnl ---------------------------------------------------------------------------
+dnl End Macro: ENABLE_MURMUR_HASH
+dnl ---------------------------------------------------------------------------
static uint32_t hsieh_values[]= { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
#endif
+#ifdef HAVE_MURMUR_HASH
static uint32_t murmur_values[]= { 4142305122U, 734504955U, 3802834688U, 4076891445U,
387802650U, 560515427U, 3274673488U, 3150339524U,
1527441970U, 2728642900U, 3613992239U, 2938419259U,
264013145U, 3995512858U, 2400956718U, 2346666219U,
926327338U, 442757446U, 1770805201U, 560483147U,
3902279934U };
+#else
+static uint32_t murmur_values[]= { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
+#endif
static uint32_t jenkins_values[]= { 1442444624U, 4253821186U, 1885058256U, 2120131735U,
3261968576U, 3515188778U, 4232909173U, 4288625128U,
static test_return_t murmur_run (hashkit_st *hashk __attribute__((unused)))
{
#ifdef WORDS_BIGENDIAN
+ (void)murmur_values;
return TEST_SKIPPED;
#else
uint32_t x;
{
uint32_t hash_val;
+#ifdef HAVE_MURMUR_HASH
hash_val= libhashkit_murmur(*ptr, strlen(*ptr));
+#else
+ hash_val= 1;
+#endif
assert(murmur_values[x] == hash_val);
}
rc= hashkit_set_function(hashk, algo);
/* Hsieh is disabled most of the time for patent issues */
+#ifndef HAVE_HSIEH_HASH
if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_HSIEH)
continue;
+#endif
+
+#ifndef HAVE_MURMUR_HASH
+ if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_MURMUR)
+ continue;
+#endif
if (rc == HASHKIT_FAILURE && algo == HASHKIT_HASH_CUSTOM)
continue;
static test_return_t pre_murmur(memcached_st *memc)
{
+#ifdef HAVE_MURMUR_HASH
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR);
-
return TEST_SUCCESS;
+#else
+ (void) memc;
+ return TEST_SKIPPED;
+#endif
}
static test_return_t pre_jenkins(memcached_st *memc)
return TEST_SUCCESS;
}
+static test_return_t murmur_avaibility_test (memcached_st *memc)
+{
+ memcached_return_t expected_rc= MEMCACHED_FAILURE;
+#ifdef HAVE_MURMUR_HASH
+ expected_rc= MEMCACHED_SUCCESS;
+#endif
+ memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH,
+ (uint64_t)MEMCACHED_HASH_MURMUR);
+ test_true(rc == expected_rc);
+
+ return TEST_SUCCESS;
+}
+
static test_return_t one_at_a_time_run (memcached_st *memc __attribute__((unused)))
{
uint32_t x;
static test_return_t murmur_run (memcached_st *memc __attribute__((unused)))
{
#ifdef WORDS_BIGENDIAN
+ (void)murmur_values;
return TEST_SKIPPED;
#else
uint32_t x;
{0, 0, (test_callback_fn)0}
};
+test_st murmur_availability[] ={
+ {"murmur_avaibility_test", 0, (test_callback_fn)murmur_avaibility_test},
+ {0, 0, (test_callback_fn)0}
+};
+
#if 0
test_st hash_sanity[] ={
{"hash sanity", 0, (test_callback_fn)hash_sanity_test},
{"hash_sanity", 0, 0, hash_sanity},
#endif
{"hsieh_availability", 0, 0, hsieh_availability},
+ {"murmur_availability", 0, 0, murmur_availability},
{"block", 0, 0, tests},
{"binary", (test_callback_fn)pre_binary, 0, tests},
{"nonblock", (test_callback_fn)pre_nonblock, 0, tests},