Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmake/Modules/SourceFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(VALKEY_SERVER_SRCS
${CMAKE_SOURCE_DIR}/src/hashtable.c
${CMAKE_SOURCE_DIR}/src/kvstore.c
${CMAKE_SOURCE_DIR}/src/sds.c
${CMAKE_SOURCE_DIR}/src/dict_ht.c
${CMAKE_SOURCE_DIR}/src/zmalloc.c
${CMAKE_SOURCE_DIR}/src/lzf_c.c
${CMAKE_SOURCE_DIR}/src/lzf_d.c
Expand Down Expand Up @@ -130,6 +131,7 @@ set(VALKEY_CLI_SRCS
${CMAKE_SOURCE_DIR}/src/adlist.c
${CMAKE_SOURCE_DIR}/src/hashtable.c
${CMAKE_SOURCE_DIR}/src/sds.c
${CMAKE_SOURCE_DIR}/src/dict_ht.c
${CMAKE_SOURCE_DIR}/src/sha256.c
${CMAKE_SOURCE_DIR}/src/util.c
${CMAKE_SOURCE_DIR}/src/valkey-cli.c
Expand All @@ -154,6 +156,7 @@ set(VALKEY_BENCHMARK_SRCS
${CMAKE_SOURCE_DIR}/src/ae.c
${CMAKE_SOURCE_DIR}/src/anet.c
${CMAKE_SOURCE_DIR}/src/sds.c
${CMAKE_SOURCE_DIR}/src/dict_ht.c
${CMAKE_SOURCE_DIR}/src/sha256.c
${CMAKE_SOURCE_DIR}/src/util.c
${CMAKE_SOURCE_DIR}/src/valkey-benchmark.c
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ ENGINE_SERVER_OBJ = \
db.o \
debug.o \
defrag.o \
dict_ht.o \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't mix spaces and tabs.

entry.o \
eval.o \
evict.o \
Expand Down Expand Up @@ -594,6 +595,7 @@ ENGINE_CLI_OBJ = \
crc64.o \
crccombine.o \
crcspeed.o \
dict_ht.o \
hashtable.o \
monotonic.o \
mt19937-64.o \
Expand All @@ -618,6 +620,7 @@ ENGINE_BENCHMARK_OBJ = \
crc64.o \
crccombine.o \
crcspeed.o \
dict_ht.o \
fuzzer_client.o \
fuzzer_command_generator.o \
hashtable.o \
Expand Down
4 changes: 0 additions & 4 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ static_assert(offsetof(clusterMsg, type) + sizeof(uint16_t) == RCVBUF_MIN_READ_L
/* Cluster nodes hash table, mapping nodes addresses 1.2.3.4:6379 to
* clusterNode structures. */
dictType clusterNodesDictType = {
.entryGetKey = dictEntryGetKey,
.hashFunction = dictSdsHash,
.keyCompare = dictSdsKeyCompare,
.entryDestructor = dictEntryDestructorSdsKey,
Expand All @@ -257,15 +256,13 @@ dictType clusterNodesDictType = {
* we can re-add this node. The goal is to avoid reading a removed
* node for some time. */
dictType clusterNodesBlackListDictType = {
.entryGetKey = dictEntryGetKey,
.hashFunction = dictSdsCaseHash,
.keyCompare = dictSdsKeyCaseCompare,
.entryDestructor = dictEntryDestructorSdsKey,
};

/* Cluster shards hash table, mapping shard id to list of nodes */
dictType clusterSdsToListType = {
.entryGetKey = dictEntryGetKey,
.hashFunction = dictSdsHash,
.keyCompare = dictSdsKeyCompare,
.entryDestructor = dictEntryDestructorSdsKeyListValue,
Expand All @@ -283,7 +280,6 @@ static int dictPtrCompare(const void *key1, const void *key2) {
/* Dictionary type for mapping hash slots to cluster nodes.
* Keys are slot numbers encoded directly as pointer values, values are clusterNode pointers. */
dictType clusterSlotDictType = {
.entryGetKey = dictEntryGetKey,
.hashFunction = dictPtrHash,
.keyCompare = dictPtrCompare,
.entryDestructor = zfree,
Expand Down
2 changes: 0 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,14 +1047,12 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state);
* like "maxmemory" -> list of line numbers (first line is zero).
*/
dictType optionToLineDictType = {
.entryGetKey = dictEntryGetKey,
.hashFunction = dictSdsCaseHash,
.keyCompare = dictSdsKeyCaseCompare,
.entryDestructor = dictEntryDestructorSdsKeyListValue,
};

dictType optionSetDictType = {
.entryGetKey = dictEntryGetKey,
.hashFunction = dictSdsCaseHash,
.keyCompare = dictSdsKeyCaseCompare,
.entryDestructor = dictEntryDestructorSdsKey,
Expand Down
27 changes: 2 additions & 25 deletions src/defrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,41 +299,18 @@ static void activeDefragZsetNode(void *privdata, void *entry_ref) {
#define DEFRAG_SDS_DICT_VAL_VOID_PTR 3
#define DEFRAG_SDS_DICT_VAL_LUA_SCRIPT 4

typedef void *(dictDefragAllocFunction)(void *ptr);
typedef struct {
dictDefragAllocFunction *defragKey;
dictDefragAllocFunction *defragVal;
} dictDefragFunctions;

static void activeDefragDictCallback(void *privdata, void *entry_ref) {
dictDefragFunctions *defragfns = privdata;
dictEntry **de_ref = (dictEntry **)entry_ref;
dictEntry *de = *de_ref;

/* Defrag the entry itself */
dictEntry *newentry = activeDefragAlloc(de);
if (newentry) {
de = newentry;
*de_ref = newentry;
}

/* Defrag the key */
if (defragfns->defragKey) {
void *newkey = defragfns->defragKey(de->key);
if (newkey) de->key = newkey;
}

/* Defrag the value */
if (defragfns->defragVal) {
void *newval = defragfns->defragVal(de->v.val);
if (newval) de->v.val = newval;
}
htdictDefragEntry(de_ref, defragfns);
}

/* Defrag a dict with sds key and optional value (either ptr, sds or robj string) */
static void activeDefragSdsDict(dict *d, int val_type) {
unsigned long cursor = 0;
dictDefragFunctions defragfns = {
.defragAlloc = activeDefragAlloc,
.defragKey = (dictDefragAllocFunction *)activeDefragSds,
.defragVal = (val_type == DEFRAG_SDS_DICT_VAL_IS_SDS ? (dictDefragAllocFunction *)activeDefragSds
: val_type == DEFRAG_SDS_DICT_VAL_IS_STROB ? (dictDefragAllocFunction *)activeDefragStringOb
Expand Down
Loading
Loading