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