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
d1578a33
Commit
d1578a33
authored
Jun 04, 2010
by
Pieter Noordhuis
Browse files
renamed hash wrapper functions to match wrapper function naming convention: "<type>Type<func>"
parent
422cf21f
Changes
2
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
d1578a33
...
@@ -6790,7 +6790,7 @@ static void zrevrankCommand(redisClient *c) {
...
@@ -6790,7 +6790,7 @@ static void zrevrankCommand(redisClient *c) {
/* Check the length of a number of objects to see if we need to convert a
/* Check the length of a number of objects to see if we need to convert a
* zipmap to a real hash. Note that we only check string encoded objects
* zipmap to a real hash. Note that we only check string encoded objects
* as their string length can be queried in constant time. */
* as their string length can be queried in constant time. */
static
void
hashTryConversion
(
robj
*
subject
,
robj
**
argv
,
int
start
,
int
end
)
{
static
void
hashT
ypeT
ryConversion
(
robj
*
subject
,
robj
**
argv
,
int
start
,
int
end
)
{
int
i
;
int
i
;
if
(
subject
->
encoding
!=
REDIS_ENCODING_ZIPMAP
)
return
;
if
(
subject
->
encoding
!=
REDIS_ENCODING_ZIPMAP
)
return
;
...
@@ -6805,7 +6805,7 @@ static void hashTryConversion(robj *subject, robj **argv, int start, int end) {
...
@@ -6805,7 +6805,7 @@ static void hashTryConversion(robj *subject, robj **argv, int start, int end) {
}
}
/* Encode given objects in-place when the hash uses a dict. */
/* Encode given objects in-place when the hash uses a dict. */
static
void
hashTryObjectEncoding
(
robj
*
subject
,
robj
**
o1
,
robj
**
o2
)
{
static
void
hashT
ypeT
ryObjectEncoding
(
robj
*
subject
,
robj
**
o1
,
robj
**
o2
)
{
if
(
subject
->
encoding
==
REDIS_ENCODING_HT
)
{
if
(
subject
->
encoding
==
REDIS_ENCODING_HT
)
{
if
(
o1
)
*
o1
=
tryObjectEncoding
(
*
o1
);
if
(
o1
)
*
o1
=
tryObjectEncoding
(
*
o1
);
if
(
o2
)
*
o2
=
tryObjectEncoding
(
*
o2
);
if
(
o2
)
*
o2
=
tryObjectEncoding
(
*
o2
);
...
@@ -6815,7 +6815,7 @@ static void hashTryObjectEncoding(robj *subject, robj **o1, robj **o2) {
...
@@ -6815,7 +6815,7 @@ static void hashTryObjectEncoding(robj *subject, robj **o1, robj **o2) {
/* Get the value from a hash identified by key. Returns either a string
/* Get the value from a hash identified by key. Returns either a string
* object or NULL if the value cannot be found. The refcount of the object
* object or NULL if the value cannot be found. The refcount of the object
* is always increased by 1 when the value was found. */
* is always increased by 1 when the value was found. */
static
robj
*
hashGet
(
robj
*
o
,
robj
*
key
)
{
static
robj
*
hash
Type
Get
(
robj
*
o
,
robj
*
key
)
{
robj
*
value
=
NULL
;
robj
*
value
=
NULL
;
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
unsigned
char
*
v
;
unsigned
char
*
v
;
...
@@ -6837,7 +6837,7 @@ static robj *hashGet(robj *o, robj *key) {
...
@@ -6837,7 +6837,7 @@ static robj *hashGet(robj *o, robj *key) {
/* Test if the key exists in the given hash. Returns 1 if the key
/* Test if the key exists in the given hash. Returns 1 if the key
* exists and 0 when it doesn't. */
* exists and 0 when it doesn't. */
static
int
hashExists
(
robj
*
o
,
robj
*
key
)
{
static
int
hash
Type
Exists
(
robj
*
o
,
robj
*
key
)
{
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
key
=
getDecodedObject
(
key
);
key
=
getDecodedObject
(
key
);
if
(
zipmapExists
(
o
->
ptr
,
key
->
ptr
,
sdslen
(
key
->
ptr
)))
{
if
(
zipmapExists
(
o
->
ptr
,
key
->
ptr
,
sdslen
(
key
->
ptr
)))
{
...
@@ -6855,7 +6855,7 @@ static int hashExists(robj *o, robj *key) {
...
@@ -6855,7 +6855,7 @@ static int hashExists(robj *o, robj *key) {
/* Add an element, discard the old if the key already exists.
/* Add an element, discard the old if the key already exists.
* Return 0 on insert and 1 on update. */
* Return 0 on insert and 1 on update. */
static
int
hashSet
(
robj
*
o
,
robj
*
key
,
robj
*
value
)
{
static
int
hash
Type
Set
(
robj
*
o
,
robj
*
key
,
robj
*
value
)
{
int
update
=
0
;
int
update
=
0
;
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
key
=
getDecodedObject
(
key
);
key
=
getDecodedObject
(
key
);
...
@@ -6884,7 +6884,7 @@ static int hashSet(robj *o, robj *key, robj *value) {
...
@@ -6884,7 +6884,7 @@ static int hashSet(robj *o, robj *key, robj *value) {
/* Delete an element from a hash.
/* Delete an element from a hash.
* Return 1 on deleted and 0 on not found. */
* Return 1 on deleted and 0 on not found. */
static
int
hashDelete
(
robj
*
o
,
robj
*
key
)
{
static
int
hash
Type
Delete
(
robj
*
o
,
robj
*
key
)
{
int
deleted
=
0
;
int
deleted
=
0
;
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
key
=
getDecodedObject
(
key
);
key
=
getDecodedObject
(
key
);
...
@@ -6899,7 +6899,7 @@ static int hashDelete(robj *o, robj *key) {
...
@@ -6899,7 +6899,7 @@ static int hashDelete(robj *o, robj *key) {
}
}
/* Return the number of elements in a hash. */
/* Return the number of elements in a hash. */
static
unsigned
long
hashLength
(
robj
*
o
)
{
static
unsigned
long
hash
Type
Length
(
robj
*
o
)
{
return
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
?
return
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
?
zipmapLen
((
unsigned
char
*
)
o
->
ptr
)
:
dictSize
((
dict
*
)
o
->
ptr
);
zipmapLen
((
unsigned
char
*
)
o
->
ptr
)
:
dictSize
((
dict
*
)
o
->
ptr
);
}
}
...
@@ -6916,10 +6916,10 @@ typedef struct {
...
@@ -6916,10 +6916,10 @@ typedef struct {
dictIterator
*
di
;
dictIterator
*
di
;
dictEntry
*
de
;
dictEntry
*
de
;
}
hashIterator
;
}
hash
Type
Iterator
;
static
hashIterator
*
hashInitIterator
(
robj
*
subject
)
{
static
hash
Type
Iterator
*
hash
Type
InitIterator
(
robj
*
subject
)
{
hashIterator
*
hi
=
zmalloc
(
sizeof
(
hashIterator
));
hash
Type
Iterator
*
hi
=
zmalloc
(
sizeof
(
hash
Type
Iterator
));
hi
->
encoding
=
subject
->
encoding
;
hi
->
encoding
=
subject
->
encoding
;
if
(
hi
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
if
(
hi
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
hi
->
zi
=
zipmapRewind
(
subject
->
ptr
);
hi
->
zi
=
zipmapRewind
(
subject
->
ptr
);
...
@@ -6931,7 +6931,7 @@ static hashIterator *hashInitIterator(robj *subject) {
...
@@ -6931,7 +6931,7 @@ static hashIterator *hashInitIterator(robj *subject) {
return
hi
;
return
hi
;
}
}
static
void
hashReleaseIterator
(
hashIterator
*
hi
)
{
static
void
hash
Type
ReleaseIterator
(
hash
Type
Iterator
*
hi
)
{
if
(
hi
->
encoding
==
REDIS_ENCODING_HT
)
{
if
(
hi
->
encoding
==
REDIS_ENCODING_HT
)
{
dictReleaseIterator
(
hi
->
di
);
dictReleaseIterator
(
hi
->
di
);
}
}
...
@@ -6940,7 +6940,7 @@ static void hashReleaseIterator(hashIterator *hi) {
...
@@ -6940,7 +6940,7 @@ static void hashReleaseIterator(hashIterator *hi) {
/* Move to the next entry in the hash. Return REDIS_OK when the next entry
/* Move to the next entry in the hash. Return REDIS_OK when the next entry
* could be found and REDIS_ERR when the iterator reaches the end. */
* could be found and REDIS_ERR when the iterator reaches the end. */
static
int
hashNext
(
hashIterator
*
hi
)
{
static
int
hash
Type
Next
(
hash
Type
Iterator
*
hi
)
{
if
(
hi
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
if
(
hi
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
if
((
hi
->
zi
=
zipmapNext
(
hi
->
zi
,
&
hi
->
zk
,
&
hi
->
zklen
,
if
((
hi
->
zi
=
zipmapNext
(
hi
->
zi
,
&
hi
->
zk
,
&
hi
->
zklen
,
&
hi
->
zv
,
&
hi
->
zvlen
))
==
NULL
)
return
REDIS_ERR
;
&
hi
->
zv
,
&
hi
->
zvlen
))
==
NULL
)
return
REDIS_ERR
;
...
@@ -6952,7 +6952,7 @@ static int hashNext(hashIterator *hi) {
...
@@ -6952,7 +6952,7 @@ static int hashNext(hashIterator *hi) {
/* Get key or value object at current iteration position.
/* Get key or value object at current iteration position.
* This increases the refcount of the field object by 1. */
* This increases the refcount of the field object by 1. */
static
robj
*
hashCurrent
(
hashIterator
*
hi
,
int
what
)
{
static
robj
*
hash
Type
Current
(
hash
Type
Iterator
*
hi
,
int
what
)
{
robj
*
o
;
robj
*
o
;
if
(
hi
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
if
(
hi
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
if
(
what
&
REDIS_HASH_KEY
)
{
if
(
what
&
REDIS_HASH_KEY
)
{
...
@@ -6971,7 +6971,7 @@ static robj *hashCurrent(hashIterator *hi, int what) {
...
@@ -6971,7 +6971,7 @@ static robj *hashCurrent(hashIterator *hi, int what) {
return
o
;
return
o
;
}
}
static
robj
*
hashLookupWriteOrCreate
(
redisClient
*
c
,
robj
*
key
)
{
static
robj
*
hash
Type
LookupWriteOrCreate
(
redisClient
*
c
,
robj
*
key
)
{
robj
*
o
=
lookupKeyWrite
(
c
->
db
,
key
);
robj
*
o
=
lookupKeyWrite
(
c
->
db
,
key
);
if
(
o
==
NULL
)
{
if
(
o
==
NULL
)
{
o
=
createHashObject
();
o
=
createHashObject
();
...
@@ -6990,24 +6990,24 @@ static void hsetCommand(redisClient *c) {
...
@@ -6990,24 +6990,24 @@ static void hsetCommand(redisClient *c) {
int
update
;
int
update
;
robj
*
o
;
robj
*
o
;
if
((
o
=
hashLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
o
=
hash
Type
LookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
hashTryConversion
(
o
,
c
->
argv
,
2
,
3
);
hashT
ypeT
ryConversion
(
o
,
c
->
argv
,
2
,
3
);
hashTryObjectEncoding
(
o
,
&
c
->
argv
[
2
],
&
c
->
argv
[
3
]);
hashT
ypeT
ryObjectEncoding
(
o
,
&
c
->
argv
[
2
],
&
c
->
argv
[
3
]);
update
=
hashSet
(
o
,
c
->
argv
[
2
],
c
->
argv
[
3
]);
update
=
hash
Type
Set
(
o
,
c
->
argv
[
2
],
c
->
argv
[
3
]);
addReply
(
c
,
update
?
shared
.
czero
:
shared
.
cone
);
addReply
(
c
,
update
?
shared
.
czero
:
shared
.
cone
);
server
.
dirty
++
;
server
.
dirty
++
;
}
}
static
void
hsetnxCommand
(
redisClient
*
c
)
{
static
void
hsetnxCommand
(
redisClient
*
c
)
{
robj
*
o
;
robj
*
o
;
if
((
o
=
hashLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
o
=
hash
Type
LookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
hashTryConversion
(
o
,
c
->
argv
,
2
,
3
);
hashT
ypeT
ryConversion
(
o
,
c
->
argv
,
2
,
3
);
if
(
hashExists
(
o
,
c
->
argv
[
2
]))
{
if
(
hash
Type
Exists
(
o
,
c
->
argv
[
2
]))
{
addReply
(
c
,
shared
.
czero
);
addReply
(
c
,
shared
.
czero
);
}
else
{
}
else
{
hashTryObjectEncoding
(
o
,
&
c
->
argv
[
2
],
&
c
->
argv
[
3
]);
hashT
ypeT
ryObjectEncoding
(
o
,
&
c
->
argv
[
2
],
&
c
->
argv
[
3
]);
hashSet
(
o
,
c
->
argv
[
2
],
c
->
argv
[
3
]);
hash
Type
Set
(
o
,
c
->
argv
[
2
],
c
->
argv
[
3
]);
addReply
(
c
,
shared
.
cone
);
addReply
(
c
,
shared
.
cone
);
server
.
dirty
++
;
server
.
dirty
++
;
}
}
...
@@ -7022,11 +7022,11 @@ static void hmsetCommand(redisClient *c) {
...
@@ -7022,11 +7022,11 @@ static void hmsetCommand(redisClient *c) {
return
;
return
;
}
}
if
((
o
=
hashLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
o
=
hash
Type
LookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
hashTryConversion
(
o
,
c
->
argv
,
2
,
c
->
argc
-
1
);
hashT
ypeT
ryConversion
(
o
,
c
->
argv
,
2
,
c
->
argc
-
1
);
for
(
i
=
2
;
i
<
c
->
argc
;
i
+=
2
)
{
for
(
i
=
2
;
i
<
c
->
argc
;
i
+=
2
)
{
hashTryObjectEncoding
(
o
,
&
c
->
argv
[
i
],
&
c
->
argv
[
i
+
1
]);
hashT
ypeT
ryObjectEncoding
(
o
,
&
c
->
argv
[
i
],
&
c
->
argv
[
i
+
1
]);
hashSet
(
o
,
c
->
argv
[
i
],
c
->
argv
[
i
+
1
]);
hash
Type
Set
(
o
,
c
->
argv
[
i
],
c
->
argv
[
i
+
1
]);
}
}
addReply
(
c
,
shared
.
ok
);
addReply
(
c
,
shared
.
ok
);
server
.
dirty
++
;
server
.
dirty
++
;
...
@@ -7037,8 +7037,8 @@ static void hincrbyCommand(redisClient *c) {
...
@@ -7037,8 +7037,8 @@ static void hincrbyCommand(redisClient *c) {
robj
*
o
,
*
current
,
*
new
;
robj
*
o
,
*
current
,
*
new
;
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
3
],
&
incr
,
NULL
)
!=
REDIS_OK
)
return
;
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
3
],
&
incr
,
NULL
)
!=
REDIS_OK
)
return
;
if
((
o
=
hashLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
o
=
hash
Type
LookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
current
=
hashGet
(
o
,
c
->
argv
[
2
]))
!=
NULL
)
{
if
((
current
=
hash
Type
Get
(
o
,
c
->
argv
[
2
]))
!=
NULL
)
{
if
(
getLongLongFromObjectOrReply
(
c
,
current
,
&
value
,
if
(
getLongLongFromObjectOrReply
(
c
,
current
,
&
value
,
"hash value is not an integer"
)
!=
REDIS_OK
)
{
"hash value is not an integer"
)
!=
REDIS_OK
)
{
decrRefCount
(
current
);
decrRefCount
(
current
);
...
@@ -7051,8 +7051,8 @@ static void hincrbyCommand(redisClient *c) {
...
@@ -7051,8 +7051,8 @@ static void hincrbyCommand(redisClient *c) {
value
+=
incr
;
value
+=
incr
;
new
=
createStringObjectFromLongLong
(
value
);
new
=
createStringObjectFromLongLong
(
value
);
hashTryObjectEncoding
(
o
,
&
c
->
argv
[
2
],
NULL
);
hashT
ypeT
ryObjectEncoding
(
o
,
&
c
->
argv
[
2
],
NULL
);
hashSet
(
o
,
c
->
argv
[
2
],
new
);
hash
Type
Set
(
o
,
c
->
argv
[
2
],
new
);
decrRefCount
(
new
);
decrRefCount
(
new
);
addReplyLongLong
(
c
,
value
);
addReplyLongLong
(
c
,
value
);
server
.
dirty
++
;
server
.
dirty
++
;
...
@@ -7063,7 +7063,7 @@ static void hgetCommand(redisClient *c) {
...
@@ -7063,7 +7063,7 @@ static void hgetCommand(redisClient *c) {
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
))
==
NULL
||
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
if
((
value
=
hashGet
(
o
,
c
->
argv
[
2
]))
!=
NULL
)
{
if
((
value
=
hash
Type
Get
(
o
,
c
->
argv
[
2
]))
!=
NULL
)
{
addReplyBulk
(
c
,
value
);
addReplyBulk
(
c
,
value
);
decrRefCount
(
value
);
decrRefCount
(
value
);
}
else
{
}
else
{
...
@@ -7084,7 +7084,7 @@ static void hmgetCommand(redisClient *c) {
...
@@ -7084,7 +7084,7 @@ static void hmgetCommand(redisClient *c) {
* an empty hash. The reply should then be a series of NULLs. */
* an empty hash. The reply should then be a series of NULLs. */
addReplySds
(
c
,
sdscatprintf
(
sdsempty
(),
"*%d
\r\n
"
,
c
->
argc
-
2
));
addReplySds
(
c
,
sdscatprintf
(
sdsempty
(),
"*%d
\r\n
"
,
c
->
argc
-
2
));
for
(
i
=
2
;
i
<
c
->
argc
;
i
++
)
{
for
(
i
=
2
;
i
<
c
->
argc
;
i
++
)
{
if
(
o
!=
NULL
&&
(
value
=
hashGet
(
o
,
c
->
argv
[
i
]))
!=
NULL
)
{
if
(
o
!=
NULL
&&
(
value
=
hash
Type
Get
(
o
,
c
->
argv
[
i
]))
!=
NULL
)
{
addReplyBulk
(
c
,
value
);
addReplyBulk
(
c
,
value
);
decrRefCount
(
value
);
decrRefCount
(
value
);
}
else
{
}
else
{
...
@@ -7098,8 +7098,8 @@ static void hdelCommand(redisClient *c) {
...
@@ -7098,8 +7098,8 @@ static void hdelCommand(redisClient *c) {
if
((
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
if
(
hashDelete
(
o
,
c
->
argv
[
2
]))
{
if
(
hash
Type
Delete
(
o
,
c
->
argv
[
2
]))
{
if
(
hashLength
(
o
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
if
(
hash
Type
Length
(
o
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
addReply
(
c
,
shared
.
cone
);
addReply
(
c
,
shared
.
cone
);
server
.
dirty
++
;
server
.
dirty
++
;
}
else
{
}
else
{
...
@@ -7112,13 +7112,13 @@ static void hlenCommand(redisClient *c) {
...
@@ -7112,13 +7112,13 @@ static void hlenCommand(redisClient *c) {
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
addReplyUlong
(
c
,
hashLength
(
o
));
addReplyUlong
(
c
,
hash
Type
Length
(
o
));
}
}
static
void
genericHgetallCommand
(
redisClient
*
c
,
int
flags
)
{
static
void
genericHgetallCommand
(
redisClient
*
c
,
int
flags
)
{
robj
*
o
,
*
lenobj
,
*
obj
;
robj
*
o
,
*
lenobj
,
*
obj
;
unsigned
long
count
=
0
;
unsigned
long
count
=
0
;
hashIterator
*
hi
;
hash
Type
Iterator
*
hi
;
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
emptymultibulk
))
==
NULL
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
emptymultibulk
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
...
@@ -7127,22 +7127,22 @@ static void genericHgetallCommand(redisClient *c, int flags) {
...
@@ -7127,22 +7127,22 @@ static void genericHgetallCommand(redisClient *c, int flags) {
addReply
(
c
,
lenobj
);
addReply
(
c
,
lenobj
);
decrRefCount
(
lenobj
);
decrRefCount
(
lenobj
);
hi
=
hashInitIterator
(
o
);
hi
=
hash
Type
InitIterator
(
o
);
while
(
hashNext
(
hi
)
!=
REDIS_ERR
)
{
while
(
hash
Type
Next
(
hi
)
!=
REDIS_ERR
)
{
if
(
flags
&
REDIS_HASH_KEY
)
{
if
(
flags
&
REDIS_HASH_KEY
)
{
obj
=
hashCurrent
(
hi
,
REDIS_HASH_KEY
);
obj
=
hash
Type
Current
(
hi
,
REDIS_HASH_KEY
);
addReplyBulk
(
c
,
obj
);
addReplyBulk
(
c
,
obj
);
decrRefCount
(
obj
);
decrRefCount
(
obj
);
count
++
;
count
++
;
}
}
if
(
flags
&
REDIS_HASH_VALUE
)
{
if
(
flags
&
REDIS_HASH_VALUE
)
{
obj
=
hashCurrent
(
hi
,
REDIS_HASH_VALUE
);
obj
=
hash
Type
Current
(
hi
,
REDIS_HASH_VALUE
);
addReplyBulk
(
c
,
obj
);
addReplyBulk
(
c
,
obj
);
decrRefCount
(
obj
);
decrRefCount
(
obj
);
count
++
;
count
++
;
}
}
}
}
hashReleaseIterator
(
hi
);
hash
Type
ReleaseIterator
(
hi
);
lenobj
->
ptr
=
sdscatprintf
(
sdsempty
(),
"*%lu
\r\n
"
,
count
);
lenobj
->
ptr
=
sdscatprintf
(
sdsempty
(),
"*%lu
\r\n
"
,
count
);
}
}
...
@@ -7164,7 +7164,7 @@ static void hexistsCommand(redisClient *c) {
...
@@ -7164,7 +7164,7 @@ static void hexistsCommand(redisClient *c) {
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
addReply
(
c
,
hashExists
(
o
,
c
->
argv
[
2
])
?
shared
.
cone
:
shared
.
czero
);
addReply
(
c
,
hash
Type
Exists
(
o
,
c
->
argv
[
2
])
?
shared
.
cone
:
shared
.
czero
);
}
}
static
void
convertToRealHash
(
robj
*
o
)
{
static
void
convertToRealHash
(
robj
*
o
)
{
...
@@ -7285,7 +7285,7 @@ static robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
...
@@ -7285,7 +7285,7 @@ static robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
/* Retrieve value from hash by the field name. This operation
/* Retrieve value from hash by the field name. This operation
* already increases the refcount of the returned object. */
* already increases the refcount of the returned object. */
initStaticStringObject
(
fieldobj
,((
char
*
)
&
fieldname
)
+
(
sizeof
(
long
)
*
2
));
initStaticStringObject
(
fieldobj
,((
char
*
)
&
fieldname
)
+
(
sizeof
(
long
)
*
2
));
o
=
hashGet
(
o
,
&
fieldobj
);
o
=
hash
Type
Get
(
o
,
&
fieldobj
);
}
else
{
}
else
{
if
(
o
->
type
!=
REDIS_STRING
)
return
NULL
;
if
(
o
->
type
!=
REDIS_STRING
)
return
NULL
;
...
@@ -11115,23 +11115,23 @@ static void computeDatasetDigest(unsigned char *final) {
...
@@ -11115,23 +11115,23 @@ static void computeDatasetDigest(unsigned char *final) {
}
}
dictReleaseIterator
(
di
);
dictReleaseIterator
(
di
);
}
else
if
(
o
->
type
==
REDIS_HASH
)
{
}
else
if
(
o
->
type
==
REDIS_HASH
)
{
hashIterator
*
hi
;
hash
Type
Iterator
*
hi
;
robj
*
obj
;
robj
*
obj
;
hi
=
hashInitIterator
(
o
);
hi
=
hash
Type
InitIterator
(
o
);
while
(
hashNext
(
hi
)
!=
REDIS_ERR
)
{
while
(
hash
Type
Next
(
hi
)
!=
REDIS_ERR
)
{
unsigned
char
eledigest
[
20
];
unsigned
char
eledigest
[
20
];
memset
(
eledigest
,
0
,
20
);
memset
(
eledigest
,
0
,
20
);
obj
=
hashCurrent
(
hi
,
REDIS_HASH_KEY
);
obj
=
hash
Type
Current
(
hi
,
REDIS_HASH_KEY
);
mixObjectDigest
(
eledigest
,
obj
);
mixObjectDigest
(
eledigest
,
obj
);
decrRefCount
(
obj
);
decrRefCount
(
obj
);
obj
=
hashCurrent
(
hi
,
REDIS_HASH_VALUE
);
obj
=
hash
Type
Current
(
hi
,
REDIS_HASH_VALUE
);
mixObjectDigest
(
eledigest
,
obj
);
mixObjectDigest
(
eledigest
,
obj
);
decrRefCount
(
obj
);
decrRefCount
(
obj
);
xorDigest
(
digest
,
eledigest
,
20
);
xorDigest
(
digest
,
eledigest
,
20
);
}
}
hashReleaseIterator
(
hi
);
hash
Type
ReleaseIterator
(
hi
);
}
else
{
}
else
{
redisPanic
(
"Unknown object type"
);
redisPanic
(
"Unknown object type"
);
}
}
...
...
staticsymbols.h
View file @
d1578a33
...
@@ -120,17 +120,17 @@ static struct redisFunctionSym symsTable[] = {
...
@@ -120,17 +120,17 @@ static struct redisFunctionSym symsTable[] = {
{
"glueReplyBuffersIfNeeded"
,(
unsigned
long
)
glueReplyBuffersIfNeeded
},
{
"glueReplyBuffersIfNeeded"
,(
unsigned
long
)
glueReplyBuffersIfNeeded
},
{
"handleClientsBlockedOnSwappedKey"
,(
unsigned
long
)
handleClientsBlockedOnSwappedKey
},
{
"handleClientsBlockedOnSwappedKey"
,(
unsigned
long
)
handleClientsBlockedOnSwappedKey
},
{
"handleClientsWaitingListPush"
,(
unsigned
long
)
handleClientsWaitingListPush
},
{
"handleClientsWaitingListPush"
,(
unsigned
long
)
handleClientsWaitingListPush
},
{
"hashCurrent"
,(
unsigned
long
)
hashCurrent
},
{
"hash
Type
Current"
,(
unsigned
long
)
hash
Type
Current
},
{
"hashDelete"
,(
unsigned
long
)
hashDelete
},
{
"hash
Type
Delete"
,(
unsigned
long
)
hash
Type
Delete
},
{
"hashExists"
,(
unsigned
long
)
hashExists
},
{
"hash
Type
Exists"
,(
unsigned
long
)
hash
Type
Exists
},
{
"hashGet"
,(
unsigned
long
)
hashGet
},
{
"hash
Type
Get"
,(
unsigned
long
)
hash
Type
Get
},
{
"hashInitIterator"
,(
unsigned
long
)
hashInitIterator
},
{
"hash
Type
InitIterator"
,(
unsigned
long
)
hash
Type
InitIterator
},
{
"hashLookupWriteOrCreate"
,(
unsigned
long
)
hashLookupWriteOrCreate
},
{
"hash
Type
LookupWriteOrCreate"
,(
unsigned
long
)
hash
Type
LookupWriteOrCreate
},
{
"hashNext"
,(
unsigned
long
)
hashNext
},
{
"hash
Type
Next"
,(
unsigned
long
)
hash
Type
Next
},
{
"hashReleaseIterator"
,(
unsigned
long
)
hashReleaseIterator
},
{
"hash
Type
ReleaseIterator"
,(
unsigned
long
)
hash
Type
ReleaseIterator
},
{
"hashSet"
,(
unsigned
long
)
hashSet
},
{
"hash
Type
Set"
,(
unsigned
long
)
hash
Type
Set
},
{
"hashTryConversion"
,(
unsigned
long
)
hashTryConversion
},
{
"hashT
ypeT
ryConversion"
,(
unsigned
long
)
hashT
ypeT
ryConversion
},
{
"hashTryObjectEncoding"
,(
unsigned
long
)
hashTryObjectEncoding
},
{
"hashT
ypeT
ryObjectEncoding"
,(
unsigned
long
)
hashT
ypeT
ryObjectEncoding
},
{
"hdelCommand"
,(
unsigned
long
)
hdelCommand
},
{
"hdelCommand"
,(
unsigned
long
)
hdelCommand
},
{
"hexistsCommand"
,(
unsigned
long
)
hexistsCommand
},
{
"hexistsCommand"
,(
unsigned
long
)
hexistsCommand
},
{
"hgetCommand"
,(
unsigned
long
)
hgetCommand
},
{
"hgetCommand"
,(
unsigned
long
)
hgetCommand
},
...
...
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