mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 15:21:03 +00:00
Merge remote-tracking branch 'origin/unstable' into unstable
This commit is contained in:
commit
92cc20ecfe
16
src/dict.c
16
src/dict.c
@ -116,8 +116,8 @@ unsigned int dictGenCaseHashFunction(const unsigned char *buf, int len) {
|
|||||||
|
|
||||||
/* ----------------------------- API implementation ------------------------- */
|
/* ----------------------------- API implementation ------------------------- */
|
||||||
|
|
||||||
/* Reset an hashtable already initialized with ht_init().
|
/* Reset a hash table already initialized with ht_init().
|
||||||
* NOTE: This function should only called by ht_destroy(). */
|
* NOTE: This function should only be called by ht_destroy(). */
|
||||||
static void _dictReset(dictht *ht)
|
static void _dictReset(dictht *ht)
|
||||||
{
|
{
|
||||||
ht->table = NULL;
|
ht->table = NULL;
|
||||||
@ -162,18 +162,18 @@ int dictResize(dict *d)
|
|||||||
return dictExpand(d, minimal);
|
return dictExpand(d, minimal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expand or create the hashtable */
|
/* Expand or create the hash table */
|
||||||
int dictExpand(dict *d, unsigned long size)
|
int dictExpand(dict *d, unsigned long size)
|
||||||
{
|
{
|
||||||
dictht n; /* the new hashtable */
|
dictht n; /* the new hash table */
|
||||||
unsigned long realsize = _dictNextPower(size);
|
unsigned long realsize = _dictNextPower(size);
|
||||||
|
|
||||||
/* the size is invalid if it is smaller than the number of
|
/* the size is invalid if it is smaller than the number of
|
||||||
* elements already inside the hashtable */
|
* elements already inside the hash table */
|
||||||
if (dictIsRehashing(d) || d->ht[0].used > size)
|
if (dictIsRehashing(d) || d->ht[0].used > size)
|
||||||
return DICT_ERR;
|
return DICT_ERR;
|
||||||
|
|
||||||
/* Allocate the new hashtable and initialize all pointers to NULL */
|
/* Allocate the new hash table and initialize all pointers to NULL */
|
||||||
n.size = realsize;
|
n.size = realsize;
|
||||||
n.sizemask = realsize-1;
|
n.sizemask = realsize-1;
|
||||||
n.table = zcalloc(realsize*sizeof(dictEntry*));
|
n.table = zcalloc(realsize*sizeof(dictEntry*));
|
||||||
@ -280,7 +280,7 @@ int dictAdd(dict *d, void *key, void *val)
|
|||||||
* a value returns the dictEntry structure to the user, that will make
|
* a value returns the dictEntry structure to the user, that will make
|
||||||
* sure to fill the value field as he wishes.
|
* sure to fill the value field as he wishes.
|
||||||
*
|
*
|
||||||
* This function is also directly expoed to user API to be called
|
* This function is also directly exposed to the user API to be called
|
||||||
* mainly in order to store non-pointers inside the hash value, example:
|
* mainly in order to store non-pointers inside the hash value, example:
|
||||||
*
|
*
|
||||||
* entry = dictAddRaw(dict,mykey);
|
* entry = dictAddRaw(dict,mykey);
|
||||||
@ -607,7 +607,7 @@ static int _dictKeyIndex(dict *d, const void *key)
|
|||||||
unsigned int h, idx, table;
|
unsigned int h, idx, table;
|
||||||
dictEntry *he;
|
dictEntry *he;
|
||||||
|
|
||||||
/* Expand the hashtable if needed */
|
/* Expand the hash table if needed */
|
||||||
if (_dictExpandIfNeeded(d) == DICT_ERR)
|
if (_dictExpandIfNeeded(d) == DICT_ERR)
|
||||||
return -1;
|
return -1;
|
||||||
/* Compute the key hash value */
|
/* Compute the key hash value */
|
||||||
|
@ -798,7 +798,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This will also be called when the set was just converted
|
/* This will also be called when the set was just converted
|
||||||
* to regular hashtable encoded set */
|
* to a regular hash table encoded set */
|
||||||
if (o->encoding == REDIS_ENCODING_HT) {
|
if (o->encoding == REDIS_ENCODING_HT) {
|
||||||
dictAdd((dict*)o->ptr,ele,NULL);
|
dictAdd((dict*)o->ptr,ele,NULL);
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,7 +185,7 @@ unsigned long setTypeSize(robj *subject) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the set to specified encoding. The resulting dict (when converting
|
/* Convert the set to specified encoding. The resulting dict (when converting
|
||||||
* to a hashtable) is presized to hold the number of elements in the original
|
* to a hash table) is presized to hold the number of elements in the original
|
||||||
* set. */
|
* set. */
|
||||||
void setTypeConvert(robj *setobj, int enc) {
|
void setTypeConvert(robj *setobj, int enc) {
|
||||||
setTypeIterator *si;
|
setTypeIterator *si;
|
||||||
|
12
src/zipmap.c
12
src/zipmap.c
@ -52,15 +52,15 @@
|
|||||||
* <len> lengths are encoded in a single value or in a 5 bytes value.
|
* <len> lengths are encoded in a single value or in a 5 bytes value.
|
||||||
* If the first byte value (as an unsigned 8 bit value) is between 0 and
|
* If the first byte value (as an unsigned 8 bit value) is between 0 and
|
||||||
* 252, it's a single-byte length. If it is 253 then a four bytes unsigned
|
* 252, it's a single-byte length. If it is 253 then a four bytes unsigned
|
||||||
* integer follows (in the host byte ordering). A value fo 255 is used to
|
* integer follows (in the host byte ordering). A value of 255 is used to
|
||||||
* signal the end of the hash. The special value 254 is used to mark
|
* signal the end of the hash. The special value 254 is used to mark
|
||||||
* empty space that can be used to add new key/value pairs.
|
* empty space that can be used to add new key/value pairs.
|
||||||
*
|
*
|
||||||
* <free> is the number of free unused bytes
|
* <free> is the number of free unused bytes after the string, resulting
|
||||||
* after the string, resulting from modification of values associated to a
|
* from modification of values associated to a key. For instance if "foo"
|
||||||
* key (for instance if "foo" is set to "bar', and later "foo" will be se to
|
* is set to "bar", and later "foo" will be set to "hi", it will have a
|
||||||
* "hi", I'll have a free byte to use if the value will enlarge again later,
|
* free byte to use if the value will enlarge again later, or even in
|
||||||
* or even in order to add a key/value pair if it fits.
|
* order to add a key/value pair if it fits.
|
||||||
*
|
*
|
||||||
* <free> is always an unsigned 8 bit number, because if after an
|
* <free> is always an unsigned 8 bit number, because if after an
|
||||||
* update operation there are more than a few free bytes, the zipmap will be
|
* update operation there are more than a few free bytes, the zipmap will be
|
||||||
|
@ -294,7 +294,7 @@ no-appendfsync-on-rewrite no
|
|||||||
############################### ADVANCED CONFIG ###############################
|
############################### ADVANCED CONFIG ###############################
|
||||||
|
|
||||||
# Hashes are encoded in a special way (much more memory efficient) when they
|
# Hashes are encoded in a special way (much more memory efficient) when they
|
||||||
# have at max a given numer of elements, and the biggest element does not
|
# have at max a given number of elements, and the biggest element does not
|
||||||
# exceed a given threshold. You can configure this limits with the following
|
# exceed a given threshold. You can configure this limits with the following
|
||||||
# configuration directives.
|
# configuration directives.
|
||||||
hash-max-ziplist-entries 64
|
hash-max-ziplist-entries 64
|
||||||
@ -317,7 +317,7 @@ set-max-intset-entries 512
|
|||||||
# order to help rehashing the main Redis hash table (the one mapping top-level
|
# order to help rehashing the main Redis hash table (the one mapping top-level
|
||||||
# keys to values). The hash table implementation redis uses (see dict.c)
|
# keys to values). The hash table implementation redis uses (see dict.c)
|
||||||
# performs a lazy rehashing: the more operation you run into an hash table
|
# performs a lazy rehashing: the more operation you run into an hash table
|
||||||
# that is rhashing, the more rehashing "steps" are performed, so if the
|
# that is rehashing, the more rehashing "steps" are performed, so if the
|
||||||
# server is idle the rehashing is never complete and some more memory is used
|
# server is idle the rehashing is never complete and some more memory is used
|
||||||
# by the hash table.
|
# by the hash table.
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user