Commit 6a49e97e authored by Vitaly Arbuzov's avatar Vitaly Arbuzov
Browse files

Approximate number of keys in each slot.

parent 852ec0ab
...@@ -3066,7 +3066,11 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin ...@@ -3066,7 +3066,11 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin
goto eoferr; goto eoferr;
if ((expires_size = rdbLoadLen(rdb,NULL)) == RDB_LENERR) if ((expires_size = rdbLoadLen(rdb,NULL)) == RDB_LENERR)
goto eoferr; goto eoferr;
// dictExpand(db->dict,db_size); // FIXME (vitarb) potentially approximate number of keys per slot in cluster mode https://sim.amazon.com/issues/ELMO-63800 clusterNode *myself = server.cluster->myself;
for (int i = 0; i < db->dict_count; i++) {
/* We don't exact number of keys that would fall into each slot, but we can approximate it, assuming even distribution. */
if (clusterNodeGetSlotBit(myself, i)) dictExpand(db->dict[i], (db_size / myself->numslots));
}
dictExpand(db->expires,expires_size); dictExpand(db->expires,expires_size);
continue; /* Read next opcode. */ continue; /* Read next opcode. */
} else if (type == RDB_OPCODE_AUX) { } else if (type == RDB_OPCODE_AUX) {
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
/* TBD: include only necessary headers. */ /* TBD: include only necessary headers. */
#include "server.h" #include "server.h"
#include "cluster.h"
/* The current RDB version. When the format changes in a way that is no longer /* The current RDB version. When the format changes in a way that is no longer
* backward compatible this number gets incremented. */ * backward compatible this number gets incremented. */
...@@ -179,5 +180,6 @@ int rdbFunctionLoad(rio *rdb, int ver, functionsLibCtx* lib_ctx, int rdbflags, s ...@@ -179,5 +180,6 @@ int rdbFunctionLoad(rio *rdb, int ver, functionsLibCtx* lib_ctx, int rdbflags, s
int rdbSaveRio(int req, rio *rdb, int *error, int rdbflags, rdbSaveInfo *rsi); int rdbSaveRio(int req, rio *rdb, int *error, int rdbflags, rdbSaveInfo *rsi);
ssize_t rdbSaveFunctions(rio *rdb); ssize_t rdbSaveFunctions(rio *rdb);
rdbSaveInfo *rdbPopulateSaveInfo(rdbSaveInfo *rsi); rdbSaveInfo *rdbPopulateSaveInfo(rdbSaveInfo *rsi);
int clusterNodeGetSlotBit(clusterNode *n, int slot);
#endif #endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment