Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c0ba9ebe
Commit
c0ba9ebe
authored
Nov 08, 2011
by
antirez
Browse files
dict.c API names modified to be more coincise and consistent.
parent
71a50956
Changes
15
Hide whitespace changes
Inline
Side-by-side
src/aof.c
View file @
c0ba9ebe
...
...
@@ -443,8 +443,8 @@ int rewriteAppendOnlyFile(char *filename) {
robj
key
,
*
o
;
time_t
expiretime
;
keystr
=
dictGet
Entry
Key
(
de
);
o
=
dictGet
Entry
Val
(
de
);
keystr
=
dictGetKey
(
de
);
o
=
dictGetVal
(
de
);
initStaticStringObject
(
key
,
keystr
);
expiretime
=
getExpire
(
db
,
&
key
);
...
...
@@ -511,7 +511,7 @@ int rewriteAppendOnlyFile(char *filename) {
dictIterator
*
di
=
dictGetIterator
(
o
->
ptr
);
dictEntry
*
de
;
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
robj
*
eleobj
=
dictGet
Entry
Key
(
de
);
robj
*
eleobj
=
dictGetKey
(
de
);
if
(
rioWrite
(
&
aof
,
cmd
,
sizeof
(
cmd
)
-
1
)
==
0
)
goto
werr
;
if
(
rioWriteBulkObject
(
&
aof
,
&
key
)
==
0
)
goto
werr
;
if
(
rioWriteBulkObject
(
&
aof
,
eleobj
)
==
0
)
goto
werr
;
...
...
@@ -559,8 +559,8 @@ int rewriteAppendOnlyFile(char *filename) {
dictEntry
*
de
;
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
robj
*
eleobj
=
dictGet
Entry
Key
(
de
);
double
*
score
=
dictGet
Entry
Val
(
de
);
robj
*
eleobj
=
dictGetKey
(
de
);
double
*
score
=
dictGetVal
(
de
);
if
(
rioWrite
(
&
aof
,
cmd
,
sizeof
(
cmd
)
-
1
)
==
0
)
goto
werr
;
if
(
rioWriteBulkObject
(
&
aof
,
&
key
)
==
0
)
goto
werr
;
...
...
@@ -593,8 +593,8 @@ int rewriteAppendOnlyFile(char *filename) {
dictEntry
*
de
;
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
robj
*
field
=
dictGet
Entry
Key
(
de
);
robj
*
val
=
dictGet
Entry
Val
(
de
);
robj
*
field
=
dictGetKey
(
de
);
robj
*
val
=
dictGetVal
(
de
);
if
(
rioWrite
(
&
aof
,
cmd
,
sizeof
(
cmd
)
-
1
)
==
0
)
goto
werr
;
if
(
rioWriteBulkObject
(
&
aof
,
&
key
)
==
0
)
goto
werr
;
...
...
src/cluster.c
View file @
c0ba9ebe
...
...
@@ -377,7 +377,7 @@ clusterNode *clusterLookupNode(char *name) {
de
=
dictFind
(
server
.
cluster
.
nodes
,
s
);
sdsfree
(
s
);
if
(
de
==
NULL
)
return
NULL
;
return
dictGet
Entry
Val
(
de
);
return
dictGetVal
(
de
);
}
/* This is only used after the handshake. When we connect a given IP/PORT
...
...
@@ -793,7 +793,7 @@ void clusterBroadcastMessage(void *buf, size_t len) {
di
=
dictGetIterator
(
server
.
cluster
.
nodes
);
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
clusterNode
*
node
=
dictGet
Entry
Val
(
de
);
clusterNode
*
node
=
dictGetVal
(
de
);
if
(
!
node
->
link
)
continue
;
if
(
node
->
flags
&
(
REDIS_NODE_MYSELF
|
REDIS_NODE_NOADDR
))
continue
;
...
...
@@ -849,7 +849,7 @@ void clusterSendPing(clusterLink *link, int type) {
/* Populate the gossip fields */
while
(
freshnodes
>
0
&&
gossipcount
<
3
)
{
struct
dictEntry
*
de
=
dictGetRandomKey
(
server
.
cluster
.
nodes
);
clusterNode
*
this
=
dictGet
Entry
Val
(
de
);
clusterNode
*
this
=
dictGetVal
(
de
);
clusterMsgDataGossip
*
gossip
;
int
j
;
...
...
@@ -970,7 +970,7 @@ void clusterCron(void) {
/* Check if we have disconnected nodes and reestablish the connection. */
di
=
dictGetIterator
(
server
.
cluster
.
nodes
);
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
clusterNode
*
node
=
dictGet
Entry
Val
(
de
);
clusterNode
*
node
=
dictGetVal
(
de
);
if
(
node
->
flags
&
(
REDIS_NODE_MYSELF
|
REDIS_NODE_NOADDR
))
continue
;
if
(
node
->
link
==
NULL
)
{
...
...
@@ -1005,7 +1005,7 @@ void clusterCron(void) {
* the oldest ping_sent time */
for
(
j
=
0
;
j
<
5
;
j
++
)
{
de
=
dictGetRandomKey
(
server
.
cluster
.
nodes
);
clusterNode
*
this
=
dictGet
Entry
Val
(
de
);
clusterNode
*
this
=
dictGetVal
(
de
);
if
(
this
->
link
==
NULL
)
continue
;
if
(
this
->
flags
&
(
REDIS_NODE_MYSELF
|
REDIS_NODE_HANDSHAKE
))
continue
;
...
...
@@ -1022,7 +1022,7 @@ void clusterCron(void) {
/* Iterate nodes to check if we need to flag something as failing */
di
=
dictGetIterator
(
server
.
cluster
.
nodes
);
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
clusterNode
*
node
=
dictGet
Entry
Val
(
de
);
clusterNode
*
node
=
dictGetVal
(
de
);
int
delay
;
if
(
node
->
flags
&
...
...
@@ -1153,7 +1153,7 @@ sds clusterGenNodesDescription(void) {
di
=
dictGetIterator
(
server
.
cluster
.
nodes
);
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
clusterNode
*
node
=
dictGet
Entry
Val
(
de
);
clusterNode
*
node
=
dictGetVal
(
de
);
/* Node coordinates */
ci
=
sdscatprintf
(
ci
,
"%.40s %s:%d "
,
...
...
src/db.c
View file @
c0ba9ebe
...
...
@@ -34,7 +34,7 @@ void SlotToKeyDel(robj *key);
robj
*
lookupKey
(
redisDb
*
db
,
robj
*
key
)
{
dictEntry
*
de
=
dictFind
(
db
->
dict
,
key
->
ptr
);
if
(
de
)
{
robj
*
val
=
dictGet
Entry
Val
(
de
);
robj
*
val
=
dictGetVal
(
de
);
/* Update the access time for the aging algorithm.
* Don't do it if we have a saving child, as this will trigger
...
...
@@ -130,7 +130,7 @@ robj *dbRandomKey(redisDb *db) {
de
=
dictGetRandomKey
(
db
->
dict
);
if
(
de
==
NULL
)
return
NULL
;
key
=
dictGet
Entry
Key
(
de
);
key
=
dictGetKey
(
de
);
keyobj
=
createStringObject
(
key
,
sdslen
(
key
));
if
(
dictFind
(
db
->
expires
,
key
))
{
if
(
expireIfNeeded
(
db
,
keyobj
))
{
...
...
@@ -282,7 +282,7 @@ void keysCommand(redisClient *c) {
di
=
dictGetIterator
(
c
->
db
->
dict
);
allkeys
=
(
pattern
[
0
]
==
'*'
&&
pattern
[
1
]
==
'\0'
);
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
sds
key
=
dictGet
Entry
Key
(
de
);
sds
key
=
dictGetKey
(
de
);
robj
*
keyobj
;
if
(
allkeys
||
stringmatchlen
(
pattern
,
plen
,
key
,
sdslen
(
key
),
0
))
{
...
...
@@ -438,7 +438,7 @@ void setExpire(redisDb *db, robj *key, time_t when) {
/* Reuse the sds from the main dict in the expire dict */
de
=
dictFind
(
db
->
dict
,
key
->
ptr
);
redisAssertWithInfo
(
NULL
,
key
,
de
!=
NULL
);
dictReplace
(
db
->
expires
,
dictGet
Entry
Key
(
de
),(
void
*
)
when
);
dictReplace
(
db
->
expires
,
dictGetKey
(
de
),(
void
*
)
when
);
}
/* Return the expire time of the specified key, or -1 if no expire
...
...
@@ -453,7 +453,7 @@ time_t getExpire(redisDb *db, robj *key) {
/* The entry was found in the expire dict, this means it should also
* be present in the main dict (safety check). */
redisAssertWithInfo
(
NULL
,
key
,
dictFind
(
db
->
dict
,
key
->
ptr
)
!=
NULL
);
return
(
time_t
)
dictGet
Entry
Val
(
de
);
return
(
time_t
)
dictGetVal
(
de
);
}
/* Propagate expires into slaves and the AOF file.
...
...
src/debug.c
View file @
c0ba9ebe
...
...
@@ -94,13 +94,13 @@ void computeDatasetDigest(unsigned char *final) {
time_t
expiretime
;
memset
(
digest
,
0
,
20
);
/* This key-val digest */
key
=
dictGet
Entry
Key
(
de
);
key
=
dictGetKey
(
de
);
keyobj
=
createStringObject
(
key
,
sdslen
(
key
));
mixDigest
(
digest
,
key
,
sdslen
(
key
));
/* Make sure the key is loaded if VM is active */
o
=
dictGet
Entry
Val
(
de
);
o
=
dictGetVal
(
de
);
aux
=
htonl
(
o
->
type
);
mixDigest
(
digest
,
&
aux
,
sizeof
(
aux
));
...
...
@@ -165,8 +165,8 @@ void computeDatasetDigest(unsigned char *final) {
dictEntry
*
de
;
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
robj
*
eleobj
=
dictGet
Entry
Key
(
de
);
double
*
score
=
dictGet
Entry
Val
(
de
);
robj
*
eleobj
=
dictGetKey
(
de
);
double
*
score
=
dictGetVal
(
de
);
snprintf
(
buf
,
sizeof
(
buf
),
"%.17g"
,
*
score
);
memset
(
eledigest
,
0
,
20
);
...
...
@@ -244,7 +244,7 @@ void debugCommand(redisClient *c) {
addReply
(
c
,
shared
.
nokeyerr
);
return
;
}
val
=
dictGet
Entry
Val
(
de
);
val
=
dictGetVal
(
de
);
strenc
=
strEncoding
(
val
->
encoding
);
addReplyStatusFormat
(
c
,
...
...
src/dict.c
View file @
c0ba9ebe
...
...
@@ -262,7 +262,7 @@ int dictAdd(dict *d, void *key, void *val)
dictEntry
*
entry
=
dictAddRaw
(
d
,
key
);
if
(
!
entry
)
return
DICT_ERR
;
dictSet
Hash
Val
(
d
,
entry
,
val
);
dictSetVal
(
d
,
entry
,
val
);
return
DICT_OK
;
}
...
...
@@ -302,7 +302,7 @@ dictEntry *dictAddRaw(dict *d, void *key)
ht
->
used
++
;
/* Set the hash entry fields. */
dictSet
Hash
Key
(
d
,
entry
,
key
);
dictSetKey
(
d
,
entry
,
key
);
return
entry
;
}
...
...
@@ -326,8 +326,8 @@ int dictReplace(dict *d, void *key, void *val)
* you want to increment (set), and then decrement (free), and not the
* reverse. */
auxentry
=
*
entry
;
dictSet
Hash
Val
(
d
,
entry
,
val
);
dictFree
Entry
Val
(
d
,
&
auxentry
);
dictSetVal
(
d
,
entry
,
val
);
dictFreeVal
(
d
,
&
auxentry
);
return
0
;
}
...
...
@@ -359,15 +359,15 @@ static int dictGenericDelete(dict *d, const void *key, int nofree)
he
=
d
->
ht
[
table
].
table
[
idx
];
prevHe
=
NULL
;
while
(
he
)
{
if
(
dictCompare
Hash
Keys
(
d
,
key
,
he
->
key
))
{
if
(
dictCompareKeys
(
d
,
key
,
he
->
key
))
{
/* Unlink the element from the list */
if
(
prevHe
)
prevHe
->
next
=
he
->
next
;
else
d
->
ht
[
table
].
table
[
idx
]
=
he
->
next
;
if
(
!
nofree
)
{
dictFree
Entry
Key
(
d
,
he
);
dictFree
Entry
Val
(
d
,
he
);
dictFreeKey
(
d
,
he
);
dictFreeVal
(
d
,
he
);
}
zfree
(
he
);
d
->
ht
[
table
].
used
--
;
...
...
@@ -401,8 +401,8 @@ int _dictClear(dict *d, dictht *ht)
if
((
he
=
ht
->
table
[
i
])
==
NULL
)
continue
;
while
(
he
)
{
nextHe
=
he
->
next
;
dictFree
Entry
Key
(
d
,
he
);
dictFree
Entry
Val
(
d
,
he
);
dictFreeKey
(
d
,
he
);
dictFreeVal
(
d
,
he
);
zfree
(
he
);
ht
->
used
--
;
he
=
nextHe
;
...
...
@@ -435,7 +435,7 @@ dictEntry *dictFind(dict *d, const void *key)
idx
=
h
&
d
->
ht
[
table
].
sizemask
;
he
=
d
->
ht
[
table
].
table
[
idx
];
while
(
he
)
{
if
(
dictCompare
Hash
Keys
(
d
,
key
,
he
->
key
))
if
(
dictCompareKeys
(
d
,
key
,
he
->
key
))
return
he
;
he
=
he
->
next
;
}
...
...
@@ -448,7 +448,7 @@ void *dictFetchValue(dict *d, const void *key) {
dictEntry
*
he
;
he
=
dictFind
(
d
,
key
);
return
he
?
dictGet
Entry
Val
(
he
)
:
NULL
;
return
he
?
dictGetVal
(
he
)
:
NULL
;
}
dictIterator
*
dictGetIterator
(
dict
*
d
)
...
...
@@ -607,7 +607,7 @@ static int _dictKeyIndex(dict *d, const void *key)
/* Search if this slot does not already contain the given key */
he
=
d
->
ht
[
table
].
table
[
idx
];
while
(
he
)
{
if
(
dictCompare
Hash
Keys
(
d
,
key
,
he
->
key
))
if
(
dictCompareKeys
(
d
,
key
,
he
->
key
))
return
-
1
;
he
=
he
->
next
;
}
...
...
src/dict.h
View file @
c0ba9ebe
...
...
@@ -94,37 +94,36 @@ typedef struct dictIterator {
#define DICT_HT_INITIAL_SIZE 4
/* ------------------------------- Macros ------------------------------------*/
#define dictFree
Entry
Val(d, entry) \
#define dictFreeVal(d, entry) \
if ((d)->type->valDestructor) \
(d)->type->valDestructor((d)->privdata, (entry)->v.val)
#define dictSet
Hash
Val(d, entry, _val_) do { \
#define dictSetVal(d, entry, _val_) do { \
if ((d)->type->valDup) \
entry->v.val = (d)->type->valDup((d)->privdata, _val_); \
else \
entry->v.val = (_val_); \
} while(0)
#define dictFree
Entry
Key(d, entry) \
#define dictFreeKey(d, entry) \
if ((d)->type->keyDestructor) \
(d)->type->keyDestructor((d)->privdata, (entry)->key)
#define dictSet
Hash
Key(d, entry, _key_) do { \
#define dictSetKey(d, entry, _key_) do { \
if ((d)->type->keyDup) \
entry->key = (d)->type->keyDup((d)->privdata, _key_); \
else \
entry->key = (_key_); \
} while(0)
#define dictCompare
Hash
Keys(d, key1, key2) \
#define dictCompareKeys(d, key1, key2) \
(((d)->type->keyCompare) ? \
(d)->type->keyCompare((d)->privdata, key1, key2) : \
(key1) == (key2))
#define dictHashKey(d, key) (d)->type->hashFunction(key)
#define dictGetEntryKey(he) ((he)->key)
#define dictGetEntryVal(he) ((he)->v.val)
#define dictGetKey(he) ((he)->key)
#define dictGetVal(he) ((he)->v.val)
#define dictSlots(d) ((d)->ht[0].size+(d)->ht[1].size)
#define dictSize(d) ((d)->ht[0].used+(d)->ht[1].used)
#define dictIsRehashing(ht) ((ht)->rehashidx != -1)
...
...
src/object.c
View file @
c0ba9ebe
...
...
@@ -465,7 +465,7 @@ robj *objectCommandLookup(redisClient *c, robj *key) {
dictEntry
*
de
;
if
((
de
=
dictFind
(
c
->
db
->
dict
,
key
->
ptr
))
==
NULL
)
return
NULL
;
return
(
robj
*
)
dictGet
Entry
Val
(
de
);
return
(
robj
*
)
dictGetVal
(
de
);
}
robj
*
objectCommandLookupOrReply
(
redisClient
*
c
,
robj
*
key
,
robj
*
reply
)
{
...
...
src/pubsub.c
View file @
c0ba9ebe
...
...
@@ -36,7 +36,7 @@ int pubsubSubscribeChannel(redisClient *c, robj *channel) {
dictAdd
(
server
.
pubsub_channels
,
channel
,
clients
);
incrRefCount
(
channel
);
}
else
{
clients
=
dictGet
Entry
Val
(
de
);
clients
=
dictGetVal
(
de
);
}
listAddNodeTail
(
clients
,
c
);
}
...
...
@@ -64,7 +64,7 @@ int pubsubUnsubscribeChannel(redisClient *c, robj *channel, int notify) {
/* Remove the client from the channel -> clients list hash table */
de
=
dictFind
(
server
.
pubsub_channels
,
channel
);
redisAssertWithInfo
(
c
,
NULL
,
de
!=
NULL
);
clients
=
dictGet
Entry
Val
(
de
);
clients
=
dictGetVal
(
de
);
ln
=
listSearchKey
(
clients
,
c
);
redisAssertWithInfo
(
c
,
NULL
,
ln
!=
NULL
);
listDelNode
(
clients
,
ln
);
...
...
@@ -146,7 +146,7 @@ int pubsubUnsubscribeAllChannels(redisClient *c, int notify) {
int
count
=
0
;
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
robj
*
channel
=
dictGet
Entry
Key
(
de
);
robj
*
channel
=
dictGetKey
(
de
);
count
+=
pubsubUnsubscribeChannel
(
c
,
channel
,
notify
);
}
...
...
@@ -180,7 +180,7 @@ int pubsubPublishMessage(robj *channel, robj *message) {
/* Send to clients listening for that channel */
de
=
dictFind
(
server
.
pubsub_channels
,
channel
);
if
(
de
)
{
list
*
list
=
dictGet
Entry
Val
(
de
);
list
*
list
=
dictGetVal
(
de
);
listNode
*
ln
;
listIter
li
;
...
...
src/rdb.c
View file @
c0ba9ebe
...
...
@@ -476,7 +476,7 @@ int rdbSaveObject(rio *rdb, robj *o) {
nwritten
+=
n
;
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
robj
*
eleobj
=
dictGet
Entry
Key
(
de
);
robj
*
eleobj
=
dictGetKey
(
de
);
if
((
n
=
rdbSaveStringObject
(
rdb
,
eleobj
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
}
...
...
@@ -505,8 +505,8 @@ int rdbSaveObject(rio *rdb, robj *o) {
nwritten
+=
n
;
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
robj
*
eleobj
=
dictGet
Entry
Key
(
de
);
double
*
score
=
dictGet
Entry
Val
(
de
);
robj
*
eleobj
=
dictGetKey
(
de
);
double
*
score
=
dictGetVal
(
de
);
if
((
n
=
rdbSaveStringObject
(
rdb
,
eleobj
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
...
...
@@ -532,8 +532,8 @@ int rdbSaveObject(rio *rdb, robj *o) {
nwritten
+=
n
;
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
robj
*
key
=
dictGet
Entry
Key
(
de
);
robj
*
val
=
dictGet
Entry
Val
(
de
);
robj
*
key
=
dictGetKey
(
de
);
robj
*
val
=
dictGetVal
(
de
);
if
((
n
=
rdbSaveStringObject
(
rdb
,
key
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
...
...
@@ -617,8 +617,8 @@ int rdbSave(char *filename) {
/* Iterate this DB writing every entry */
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
sds
keystr
=
dictGet
Entry
Key
(
de
);
robj
key
,
*
o
=
dictGet
Entry
Val
(
de
);
sds
keystr
=
dictGetKey
(
de
);
robj
key
,
*
o
=
dictGetVal
(
de
);
time_t
expire
;
initStaticStringObject
(
key
,
keystr
);
...
...
src/redis.c
View file @
c0ba9ebe
...
...
@@ -563,9 +563,9 @@ void activeExpireCycle(void) {
time_t
t
;
if
((
de
=
dictGetRandomKey
(
db
->
expires
))
==
NULL
)
break
;
t
=
(
time_t
)
dictGet
Entry
Val
(
de
);
t
=
(
time_t
)
dictGetVal
(
de
);
if
(
now
>
t
)
{
sds
key
=
dictGet
Entry
Key
(
de
);
sds
key
=
dictGetKey
(
de
);
robj
*
keyobj
=
createStringObject
(
key
,
sdslen
(
key
));
propagateExpire
(
db
,
keyobj
);
...
...
@@ -1679,7 +1679,7 @@ void freeMemoryIfNeeded(void) {
server
.
maxmemory_policy
==
REDIS_MAXMEMORY_VOLATILE_RANDOM
)
{
de
=
dictGetRandomKey
(
dict
);
bestkey
=
dictGet
Entry
Key
(
de
);
bestkey
=
dictGetKey
(
de
);
}
/* volatile-lru and allkeys-lru policy */
...
...
@@ -1692,12 +1692,12 @@ void freeMemoryIfNeeded(void) {
robj
*
o
;
de
=
dictGetRandomKey
(
dict
);
thiskey
=
dictGet
Entry
Key
(
de
);
thiskey
=
dictGetKey
(
de
);
/* When policy is volatile-lru we need an additonal lookup
* to locate the real key, as dict is set to db->expires. */
if
(
server
.
maxmemory_policy
==
REDIS_MAXMEMORY_VOLATILE_LRU
)
de
=
dictFind
(
db
->
dict
,
thiskey
);
o
=
dictGet
Entry
Val
(
de
);
o
=
dictGetVal
(
de
);
thisval
=
estimateObjectIdleTime
(
o
);
/* Higher idle time is better candidate for deletion */
...
...
@@ -1715,8 +1715,8 @@ void freeMemoryIfNeeded(void) {
long
thisval
;
de
=
dictGetRandomKey
(
dict
);
thiskey
=
dictGet
Entry
Key
(
de
);
thisval
=
(
long
)
dictGet
Entry
Val
(
de
);
thiskey
=
dictGetKey
(
de
);
thisval
=
(
long
)
dictGetVal
(
de
);
/* Expire sooner (minor expire unix timestamp) is better
* candidate for deletion */
...
...
src/sort.c
View file @
c0ba9ebe
...
...
@@ -238,7 +238,7 @@ void sortCommand(redisClient *c) {
dictEntry
*
setele
;
di
=
dictGetIterator
(
set
);
while
((
setele
=
dictNext
(
di
))
!=
NULL
)
{
vector
[
j
].
obj
=
dictGet
Entry
Key
(
setele
);
vector
[
j
].
obj
=
dictGetKey
(
setele
);
vector
[
j
].
u
.
score
=
0
;
vector
[
j
].
u
.
cmpobj
=
NULL
;
j
++
;
...
...
src/t_hash.c
View file @
c0ba9ebe
...
...
@@ -55,7 +55,7 @@ int hashTypeGet(robj *o, robj *key, robj **objval, unsigned char **v,
}
else
{
dictEntry
*
de
=
dictFind
(
o
->
ptr
,
key
);
if
(
de
==
NULL
)
return
-
1
;
*
objval
=
dictGet
Entry
Val
(
de
);
*
objval
=
dictGetVal
(
de
);
}
return
o
->
encoding
;
}
...
...
@@ -206,9 +206,9 @@ int hashTypeCurrent(hashTypeIterator *hi, int what, robj **objval, unsigned char
}
}
else
{
if
(
what
&
REDIS_HASH_KEY
)
*
objval
=
dictGet
Entry
Key
(
hi
->
de
);
*
objval
=
dictGetKey
(
hi
->
de
);
else
*
objval
=
dictGet
Entry
Val
(
hi
->
de
);
*
objval
=
dictGetVal
(
hi
->
de
);
}
return
hi
->
encoding
;
}
...
...
src/t_list.c
View file @
c0ba9ebe
...
...
@@ -776,7 +776,7 @@ void blockForKeys(redisClient *c, robj **keys, int numkeys, time_t timeout, robj
incrRefCount
(
keys
[
j
]);
redisAssertWithInfo
(
c
,
keys
[
j
],
retval
==
DICT_OK
);
}
else
{
l
=
dictGet
Entry
Val
(
de
);
l
=
dictGetVal
(
de
);
}
listAddNodeTail
(
l
,
c
);
}
...
...
@@ -797,7 +797,7 @@ void unblockClientWaitingData(redisClient *c) {
/* Remove this client from the list of clients waiting for this key. */
de
=
dictFind
(
c
->
db
->
blocking_keys
,
c
->
bpop
.
keys
[
j
]);
redisAssertWithInfo
(
c
,
c
->
bpop
.
keys
[
j
],
de
!=
NULL
);
l
=
dictGet
Entry
Val
(
de
);
l
=
dictGetVal
(
de
);
listDelNode
(
l
,
listSearchKey
(
l
,
c
));
/* If the list is empty we need to remove it to avoid wasting memory */
if
(
listLength
(
l
)
==
0
)
...
...
@@ -836,7 +836,7 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) {
de
=
dictFind
(
c
->
db
->
blocking_keys
,
key
);
if
(
de
==
NULL
)
return
0
;
clients
=
dictGet
Entry
Val
(
de
);
clients
=
dictGetVal
(
de
);
numclients
=
listLength
(
clients
);
/* Try to handle the push as long as there are clients waiting for a push.
...
...
src/t_set.c
View file @
c0ba9ebe
...
...
@@ -115,7 +115,7 @@ int setTypeNext(setTypeIterator *si, robj **objele, int64_t *llele) {
if
(
si
->
encoding
==
REDIS_ENCODING_HT
)
{
dictEntry
*
de
=
dictNext
(
si
->
di
);
if
(
de
==
NULL
)
return
-
1
;
*
objele
=
dictGet
Entry
Key
(
de
);
*
objele
=
dictGetKey
(
de
);
}
else
if
(
si
->
encoding
==
REDIS_ENCODING_INTSET
)
{
if
(
!
intsetGet
(
si
->
subject
->
ptr
,
si
->
ii
++
,
llele
))
return
-
1
;
...
...
@@ -165,7 +165,7 @@ robj *setTypeNextObject(setTypeIterator *si) {
int
setTypeRandomElement
(
robj
*
setobj
,
robj
**
objele
,
int64_t
*
llele
)
{
if
(
setobj
->
encoding
==
REDIS_ENCODING_HT
)
{
dictEntry
*
de
=
dictGetRandomKey
(
setobj
->
ptr
);
*
objele
=
dictGet
Entry
Key
(
de
);
*
objele
=
dictGetKey
(
de
);
}
else
if
(
setobj
->
encoding
==
REDIS_ENCODING_INTSET
)
{
*
llele
=
intsetRandom
(
setobj
->
ptr
);
}
else
{
...
...
src/t_zset.c
View file @
c0ba9ebe
...
...
@@ -900,8 +900,8 @@ void zaddGenericCommand(redisClient *c, int incr) {
ele
=
c
->
argv
[
3
+
j
*
2
]
=
tryObjectEncoding
(
c
->
argv
[
3
+
j
*
2
]);
de
=
dictFind
(
zs
->
dict
,
ele
);
if
(
de
!=
NULL
)
{
curobj
=
dictGet
Entry
Key
(
de
);
curscore
=
*
(
double
*
)
dictGet
Entry
Val
(
de
);
curobj
=
dictGetKey
(
de
);
curscore
=
*
(
double
*
)
dictGetVal
(
de
);
if
(
incr
)
{
score
+=
curscore
;
...
...
@@ -921,7 +921,7 @@ void zaddGenericCommand(redisClient *c, int incr) {
redisAssertWithInfo
(
c
,
curobj
,
zslDelete
(
zs
->
zsl
,
curscore
,
curobj
));
znode
=
zslInsert
(
zs
->
zsl
,
score
,
curobj
);
incrRefCount
(
curobj
);
/* Re-inserted in skiplist. */
dictGet
Entry
Val
(
de
)
=
&
znode
->
score
;
/* Update score ptr. */
dictGetVal
(
de
)
=
&
znode
->
score
;
/* Update score ptr. */
signalModifiedKey
(
c
->
db
,
key
);
server
.
dirty
++
;
...
...
@@ -987,7 +987,7 @@ void zremCommand(redisClient *c) {
deleted
++
;
/* Delete from the skiplist */
score
=
*
(
double
*
)
dictGet
Entry
Val
(
de
);
score
=
*
(
double
*
)
dictGetVal
(
de
);
redisAssertWithInfo
(
c
,
c
->
argv
[
j
],
zslDelete
(
zs
->
zsl
,
score
,
c
->
argv
[
j
]));
/* Delete from the hash table */
...
...
@@ -1263,7 +1263,7 @@ int zuiNext(zsetopsrc *op, zsetopval *val) {
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_HT
)
{
if
(
it
->
ht
.
de
==
NULL
)
return
0
;
val
->
ele
=
dictGet
Entry
Key
(
it
->
ht
.
de
);
val
->
ele
=
dictGetKey
(
it
->
ht
.
de
);
val
->
score
=
1
.
0
;
/* Move to next element. */
...
...
@@ -1397,7 +1397,7 @@ int zuiFind(zsetopsrc *op, zsetopval *val, double *score) {
}
else
if
(
op
->
encoding
==
REDIS_ENCODING_SKIPLIST
)
{
dictEntry
*
de
;
if
((
de
=
dictFind
(
it
->
sl
.
zs
->
dict
,
val
->
ele
))
!=
NULL
)
{
*
score
=
*
(
double
*
)
dictGet
Entry
Val
(
de
);
*
score
=
*
(
double
*
)
dictGetVal
(
de
);
return
1
;
}
else
{
return
0
;
...
...
@@ -1417,7 +1417,7 @@ int zuiCompareByCardinality(const void *s1, const void *s2) {
#define REDIS_AGGR_SUM 1
#define REDIS_AGGR_MIN 2
#define REDIS_AGGR_MAX 3
#define zunionInterDictValue(_e) (dictGet
Entry
Val(_e) == NULL ? 1.0 : *(double*)dictGet
Entry
Val(_e))
#define zunionInterDictValue(_e) (dictGetVal(_e) == NULL ? 1.0 : *(double*)dictGetVal(_e))
inline
static
void
zunionInterAggregate
(
double
*
target
,
double
val
,
int
aggregate
)
{
if
(
aggregate
==
REDIS_AGGR_SUM
)
{
...
...
@@ -2058,7 +2058,7 @@ void zscoreCommand(redisClient *c) {
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
de
=
dictFind
(
zs
->
dict
,
c
->
argv
[
2
]);
if
(
de
!=
NULL
)
{
score
=
*
(
double
*
)
dictGet
Entry
Val
(
de
);
score
=
*
(
double
*
)
dictGetVal
(
de
);
addReplyDouble
(
c
,
score
);
}
else
{
addReply
(
c
,
shared
.
nullbulk
);
...
...
@@ -2114,7 +2114,7 @@ void zrankGenericCommand(redisClient *c, int reverse) {
ele
=
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
de
=
dictFind
(
zs
->
dict
,
ele
);
if
(
de
!=
NULL
)
{
score
=
*
(
double
*
)
dictGet
Entry
Val
(
de
);
score
=
*
(
double
*
)
dictGetVal
(
de
);
rank
=
zslGetRank
(
zsl
,
score
,
ele
);
redisAssertWithInfo
(
c
,
ele
,
rank
);
/* Existing elements always have a rank. */
if
(
reverse
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment