Skip to content

Commit

Permalink
CLEANUP: remove the VARIABLE_SIZED_ROOTTABLE code tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpark816 committed Jul 12, 2019
1 parent 45fe4b9 commit cb9cd9a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 23 deletions.
21 changes: 1 addition & 20 deletions engines/default/assoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
#define DEFAULT_PREFIX_HASHPOWER 10
#define DEFAULT_PREFIX_MAX_DEPTH 1

#ifdef VARIABLE_SIZED_ROOTTABLE
#define DEFAULT_ROOTSIZE 512
#endif

typedef struct {
prefix_t *pt;
Expand All @@ -59,41 +57,29 @@ ENGINE_ERROR_CODE assoc_init(struct default_engine *engine)
assoc->hashsize = hashsize(assoc->hashpower);
assoc->hashmask = hashmask(assoc->hashpower);
assoc->rootpower = 0;
#ifdef VARIABLE_SIZED_ROOTTABLE
assoc->rootsize = DEFAULT_ROOTSIZE;
assoc->roottable = calloc(assoc->rootsize, sizeof(void *));
#else
assoc->roottable = calloc(assoc->hashsize * 2, sizeof(void *));
#endif

assoc->roottable = calloc(assoc->rootsize, sizeof(void *));
if (assoc->roottable == NULL) {
return ENGINE_ENOMEM;
}

#ifdef VARIABLE_SIZED_ROOTTABLE
assoc->roottable[0].hashtable = calloc(assoc->hashsize, sizeof(void*));
if (assoc->roottable[0].hashtable == NULL) {
free(assoc->roottable);
return ENGINE_ENOMEM;
}
#else
assoc->roottable[0].hashtable = (hash_item**)&assoc->roottable[assoc->hashsize];
#endif

assoc->infotable = calloc(assoc->hashsize, sizeof(struct bucket_info));
if (assoc->infotable == NULL) {
#ifdef VARIABLE_SIZED_ROOTTABLE
free(assoc->roottable[0].hashtable);
#endif
free(assoc->roottable);
return ENGINE_ENOMEM;
}

assoc->prefix_hashtable = calloc(hashsize(DEFAULT_PREFIX_HASHPOWER), sizeof(void *));
if (assoc->prefix_hashtable == NULL) {
#ifdef VARIABLE_SIZED_ROOTTABLE
free(assoc->roottable[0].hashtable);
#endif
free(assoc->roottable);
free(assoc->infotable);
return ENGINE_ENOMEM;
Expand All @@ -112,10 +98,7 @@ void assoc_final(struct default_engine *engine)
struct assoc *assoc = &engine->assoc;
int ii, table_count;

#ifdef VARIABLE_SIZED_ROOTTABLE
free(assoc->roottable[0].hashtable);
#endif

for (ii=0; ii < assoc->rootpower; ++ii) {
table_count = hashsize(ii); //2 ^ n
free(assoc->roottable[table_count].hashtable);
Expand Down Expand Up @@ -198,7 +181,6 @@ static void assoc_expand(struct default_engine *engine)
hash_item** new_hashtable;
uint32_t ii, table_count = hashsize(assoc->rootpower); // 2 ^ n

#ifdef VARIABLE_SIZED_ROOTTABLE
if (table_count * 2 > assoc->rootsize) {
struct table *reallocated_roottable = realloc(assoc->roottable, sizeof(void*) * assoc->rootsize * 2);
if (reallocated_roottable == NULL) {
Expand All @@ -207,7 +189,6 @@ static void assoc_expand(struct default_engine *engine)
assoc->roottable = reallocated_roottable;
assoc->rootsize *= 2;
}
#endif
new_hashtable = calloc(assoc->hashsize * table_count, sizeof(void *));
if (new_hashtable) {
for (ii=0; ii < table_count; ++ii) {
Expand Down
2 changes: 0 additions & 2 deletions engines/default/assoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ struct assoc {
uint32_t hashsize; /* hash table size */
uint32_t hashmask; /* hash bucket mask */
uint32_t rootpower; /* how many hash tables we use ? (power of 2) */
#ifdef VARIABLE_SIZED_ROOTTABLE
uint32_t rootsize;
#endif

/* cache item hash table : an array of hash tables */
struct table {
Expand Down
1 change: 0 additions & 1 deletion include/memcached/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ struct iovec {
#define SUPPORT_BOP_MGET
#define SUPPORT_BOP_SMGET
#define JHPARK_OLD_SMGET_INTERFACE
#define VARIABLE_SIZED_ROOTTABLE
#define MAX_EFLAG_COMPARE_COUNT 100


Expand Down

0 comments on commit cb9cd9a

Please sign in to comment.