Commit 25b392f9 authored by antirez's avatar antirez
Browse files

Set dictGetFairRandomKey() samples to 20 for final version.

Distribution improves dramatically: tests show it clearly. Better to
have a slower implementation than a wrong one, because random member
extraction should be correct or tends to be useless for a number of
tasks.
parent f284e37f
...@@ -750,7 +750,7 @@ unsigned int dictGetSomeKeys(dict *d, dictEntry **des, unsigned int count) { ...@@ -750,7 +750,7 @@ unsigned int dictGetSomeKeys(dict *d, dictEntry **des, unsigned int count) {
* that may be constituted of N buckets with chains of different lengths * that may be constituted of N buckets with chains of different lengths
* appearing one after the other. Then we report a random element in the range. * appearing one after the other. Then we report a random element in the range.
* In this way we smooth away the problem of different chain lenghts. */ * In this way we smooth away the problem of different chain lenghts. */
#define GETFAIR_NUM_ENTRIES 10 #define GETFAIR_NUM_ENTRIES 15
dictEntry *dictGetFairRandomKey(dict *d) { dictEntry *dictGetFairRandomKey(dict *d) {
dictEntry *entries[GETFAIR_NUM_ENTRIES]; dictEntry *entries[GETFAIR_NUM_ENTRIES];
unsigned int count = dictGetSomeKeys(d,entries,GETFAIR_NUM_ENTRIES); unsigned int count = dictGetSomeKeys(d,entries,GETFAIR_NUM_ENTRIES);
......
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