提交 003f0840 编写于 作者: P Pieter Noordhuis

renamed list wrapper functions to be more verbose

上级 d0686e07
...@@ -650,7 +650,7 @@ static struct redisCommand *lookupCommand(char *name); ...@@ -650,7 +650,7 @@ static struct redisCommand *lookupCommand(char *name);
static void call(redisClient *c, struct redisCommand *cmd); static void call(redisClient *c, struct redisCommand *cmd);
static void resetClient(redisClient *c); static void resetClient(redisClient *c);
static void convertToRealHash(robj *o); static void convertToRealHash(robj *o);
static void convertList(robj *o, int enc); static void listTypeConvert(robj *o, int enc);
static int pubsubUnsubscribeAllChannels(redisClient *c, int notify); static int pubsubUnsubscribeAllChannels(redisClient *c, int notify);
static int pubsubUnsubscribeAllPatterns(redisClient *c, int notify); static int pubsubUnsubscribeAllPatterns(redisClient *c, int notify);
static void freePubsubPattern(void *p); static void freePubsubPattern(void *p);
...@@ -4181,7 +4181,7 @@ static robj *rdbLoadObject(int type, FILE *fp) { ...@@ -4181,7 +4181,7 @@ static robj *rdbLoadObject(int type, FILE *fp) {
if (o->encoding == REDIS_ENCODING_ZIPLIST && if (o->encoding == REDIS_ENCODING_ZIPLIST &&
ele->encoding == REDIS_ENCODING_RAW && ele->encoding == REDIS_ENCODING_RAW &&
sdslen(ele->ptr) > server.list_max_ziplist_value) sdslen(ele->ptr) > server.list_max_ziplist_value)
convertList(o,REDIS_ENCODING_LIST); listTypeConvert(o,REDIS_ENCODING_LIST);
if (o->encoding == REDIS_ENCODING_ZIPLIST) { if (o->encoding == REDIS_ENCODING_ZIPLIST) {
dec = getDecodedObject(ele); dec = getDecodedObject(ele);
...@@ -4910,19 +4910,19 @@ static void moveCommand(redisClient *c) { ...@@ -4910,19 +4910,19 @@ static void moveCommand(redisClient *c) {
/* Check the argument length to see if it requires us to convert the ziplist /* Check the argument length to see if it requires us to convert the ziplist
* to a real list. Only check raw-encoded objects because integer encoded * to a real list. Only check raw-encoded objects because integer encoded
* objects are never too long. */ * objects are never too long. */
static void listTryConversion(robj *subject, robj *value) { static void listTypeTryConversion(robj *subject, robj *value) {
if (subject->encoding != REDIS_ENCODING_ZIPLIST) return; if (subject->encoding != REDIS_ENCODING_ZIPLIST) return;
if (value->encoding == REDIS_ENCODING_RAW && if (value->encoding == REDIS_ENCODING_RAW &&
sdslen(value->ptr) > server.list_max_ziplist_value) sdslen(value->ptr) > server.list_max_ziplist_value)
convertList(subject,REDIS_ENCODING_LIST); listTypeConvert(subject,REDIS_ENCODING_LIST);
} }
static void lPush(robj *subject, robj *value, int where) { static void listTypePush(robj *subject, robj *value, int where) {
/* Check if we need to convert the ziplist */ /* Check if we need to convert the ziplist */
listTryConversion(subject,value); listTypeTryConversion(subject,value);
if (subject->encoding == REDIS_ENCODING_ZIPLIST && if (subject->encoding == REDIS_ENCODING_ZIPLIST &&
ziplistLen(subject->ptr) > server.list_max_ziplist_entries) ziplistLen(subject->ptr) > server.list_max_ziplist_entries)
convertList(subject,REDIS_ENCODING_LIST); listTypeConvert(subject,REDIS_ENCODING_LIST);
if (subject->encoding == REDIS_ENCODING_ZIPLIST) { if (subject->encoding == REDIS_ENCODING_ZIPLIST) {
int pos = (where == REDIS_HEAD) ? ZIPLIST_HEAD : ZIPLIST_TAIL; int pos = (where == REDIS_HEAD) ? ZIPLIST_HEAD : ZIPLIST_TAIL;
...@@ -4941,7 +4941,7 @@ static void lPush(robj *subject, robj *value, int where) { ...@@ -4941,7 +4941,7 @@ static void lPush(robj *subject, robj *value, int where) {
} }
} }
static robj *lPop(robj *subject, int where) { static robj *listTypePop(robj *subject, int where) {
robj *value = NULL; robj *value = NULL;
if (subject->encoding == REDIS_ENCODING_ZIPLIST) { if (subject->encoding == REDIS_ENCODING_ZIPLIST) {
unsigned char *p; unsigned char *p;
...@@ -4978,7 +4978,7 @@ static robj *lPop(robj *subject, int where) { ...@@ -4978,7 +4978,7 @@ static robj *lPop(robj *subject, int where) {
return value; return value;
} }
static unsigned long lLength(robj *subject) { static unsigned long listTypeLength(robj *subject) {
if (subject->encoding == REDIS_ENCODING_ZIPLIST) { if (subject->encoding == REDIS_ENCODING_ZIPLIST) {
return ziplistLen(subject->ptr); return ziplistLen(subject->ptr);
} else if (subject->encoding == REDIS_ENCODING_LIST) { } else if (subject->encoding == REDIS_ENCODING_LIST) {
...@@ -4995,18 +4995,18 @@ typedef struct { ...@@ -4995,18 +4995,18 @@ typedef struct {
unsigned char direction; /* Iteration direction */ unsigned char direction; /* Iteration direction */
unsigned char *zi; unsigned char *zi;
listNode *ln; listNode *ln;
} lIterator; } listTypeIterator;
/* Structure for an entry while iterating over a list. */ /* Structure for an entry while iterating over a list. */
typedef struct { typedef struct {
lIterator *li; listTypeIterator *li;
unsigned char *zi; /* Entry in ziplist */ unsigned char *zi; /* Entry in ziplist */
listNode *ln; /* Entry in linked list */ listNode *ln; /* Entry in linked list */
} lEntry; } listTypeEntry;
/* Initialize an iterator at the specified index. */ /* Initialize an iterator at the specified index. */
static lIterator *lInitIterator(robj *subject, int index, unsigned char direction) { static listTypeIterator *listTypeInitIterator(robj *subject, int index, unsigned char direction) {
lIterator *li = zmalloc(sizeof(lIterator)); listTypeIterator *li = zmalloc(sizeof(listTypeIterator));
li->subject = subject; li->subject = subject;
li->encoding = subject->encoding; li->encoding = subject->encoding;
li->direction = direction; li->direction = direction;
...@@ -5021,14 +5021,14 @@ static lIterator *lInitIterator(robj *subject, int index, unsigned char directio ...@@ -5021,14 +5021,14 @@ static lIterator *lInitIterator(robj *subject, int index, unsigned char directio
} }
/* Clean up the iterator. */ /* Clean up the iterator. */
static void lReleaseIterator(lIterator *li) { static void listTypeReleaseIterator(listTypeIterator *li) {
zfree(li); zfree(li);
} }
/* Stores pointer to current the entry in the provided entry structure /* Stores pointer to current the entry in the provided entry structure
* and advances the position of the iterator. Returns 1 when the current * and advances the position of the iterator. Returns 1 when the current
* entry is in fact an entry, 0 otherwise. */ * entry is in fact an entry, 0 otherwise. */
static int lNext(lIterator *li, lEntry *entry) { static int listTypeNext(listTypeIterator *li, listTypeEntry *entry) {
entry->li = li; entry->li = li;
if (li->encoding == REDIS_ENCODING_ZIPLIST) { if (li->encoding == REDIS_ENCODING_ZIPLIST) {
entry->zi = li->zi; entry->zi = li->zi;
...@@ -5055,8 +5055,8 @@ static int lNext(lIterator *li, lEntry *entry) { ...@@ -5055,8 +5055,8 @@ static int lNext(lIterator *li, lEntry *entry) {
} }
/* Return entry or NULL at the current position of the iterator. */ /* Return entry or NULL at the current position of the iterator. */
static robj *lGet(lEntry *entry) { static robj *listTypeGet(listTypeEntry *entry) {
lIterator *li = entry->li; listTypeIterator *li = entry->li;
robj *value = NULL; robj *value = NULL;
if (li->encoding == REDIS_ENCODING_ZIPLIST) { if (li->encoding == REDIS_ENCODING_ZIPLIST) {
unsigned char *vstr; unsigned char *vstr;
...@@ -5081,8 +5081,8 @@ static robj *lGet(lEntry *entry) { ...@@ -5081,8 +5081,8 @@ static robj *lGet(lEntry *entry) {
} }
/* Compare the given object with the entry at the current position. */ /* Compare the given object with the entry at the current position. */
static int lEqual(lEntry *entry, robj *o) { static int listTypeEqual(listTypeEntry *entry, robj *o) {
lIterator *li = entry->li; listTypeIterator *li = entry->li;
if (li->encoding == REDIS_ENCODING_ZIPLIST) { if (li->encoding == REDIS_ENCODING_ZIPLIST) {
redisAssert(o->encoding == REDIS_ENCODING_RAW); redisAssert(o->encoding == REDIS_ENCODING_RAW);
return ziplistCompare(entry->zi,o->ptr,sdslen(o->ptr)); return ziplistCompare(entry->zi,o->ptr,sdslen(o->ptr));
...@@ -5094,8 +5094,8 @@ static int lEqual(lEntry *entry, robj *o) { ...@@ -5094,8 +5094,8 @@ static int lEqual(lEntry *entry, robj *o) {
} }
/* Delete the element pointed to. */ /* Delete the element pointed to. */
static void lDelete(lEntry *entry) { static void listTypeDelete(listTypeEntry *entry) {
lIterator *li = entry->li; listTypeIterator *li = entry->li;
if (li->encoding == REDIS_ENCODING_ZIPLIST) { if (li->encoding == REDIS_ENCODING_ZIPLIST) {
unsigned char *p = entry->zi; unsigned char *p = entry->zi;
li->subject->ptr = ziplistDelete(li->subject->ptr,&p); li->subject->ptr = ziplistDelete(li->subject->ptr,&p);
...@@ -5118,18 +5118,18 @@ static void lDelete(lEntry *entry) { ...@@ -5118,18 +5118,18 @@ static void lDelete(lEntry *entry) {
} }
} }
static void convertList(robj *subject, int enc) { static void listTypeConvert(robj *subject, int enc) {
lIterator *li; listTypeIterator *li;
lEntry entry; listTypeEntry entry;
redisAssert(subject->type == REDIS_LIST); redisAssert(subject->type == REDIS_LIST);
if (enc == REDIS_ENCODING_LIST) { if (enc == REDIS_ENCODING_LIST) {
list *l = listCreate(); list *l = listCreate();
/* lGet returns a robj with incremented refcount */ /* listTypeGet returns a robj with incremented refcount */
li = lInitIterator(subject,0,REDIS_TAIL); li = listTypeInitIterator(subject,0,REDIS_TAIL);
while (lNext(li,&entry)) listAddNodeTail(l,lGet(&entry)); while (listTypeNext(li,&entry)) listAddNodeTail(l,listTypeGet(&entry));
lReleaseIterator(li); listTypeReleaseIterator(li);
subject->encoding = REDIS_ENCODING_LIST; subject->encoding = REDIS_ENCODING_LIST;
zfree(subject->ptr); zfree(subject->ptr);
...@@ -5158,8 +5158,8 @@ static void pushGenericCommand(redisClient *c, int where) { ...@@ -5158,8 +5158,8 @@ static void pushGenericCommand(redisClient *c, int where) {
return; return;
} }
} }
lPush(lobj,c->argv[2],where); listTypePush(lobj,c->argv[2],where);
addReplyLongLong(c,lLength(lobj)); addReplyLongLong(c,listTypeLength(lobj));
server.dirty++; server.dirty++;
} }
...@@ -5174,7 +5174,7 @@ static void rpushCommand(redisClient *c) { ...@@ -5174,7 +5174,7 @@ static void rpushCommand(redisClient *c) {
static void llenCommand(redisClient *c) { static void llenCommand(redisClient *c) {
robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.czero); robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.czero);
if (o == NULL || checkType(c,o,REDIS_LIST)) return; if (o == NULL || checkType(c,o,REDIS_LIST)) return;
addReplyUlong(c,lLength(o)); addReplyUlong(c,listTypeLength(o));
} }
static void lindexCommand(redisClient *c) { static void lindexCommand(redisClient *c) {
...@@ -5219,7 +5219,7 @@ static void lsetCommand(redisClient *c) { ...@@ -5219,7 +5219,7 @@ static void lsetCommand(redisClient *c) {
int index = atoi(c->argv[2]->ptr); int index = atoi(c->argv[2]->ptr);
robj *value = c->argv[3]; robj *value = c->argv[3];
listTryConversion(o,value); listTypeTryConversion(o,value);
if (o->encoding == REDIS_ENCODING_ZIPLIST) { if (o->encoding == REDIS_ENCODING_ZIPLIST) {
unsigned char *p, *zl = o->ptr; unsigned char *p, *zl = o->ptr;
p = ziplistIndex(zl,index); p = ziplistIndex(zl,index);
...@@ -5253,13 +5253,13 @@ static void popGenericCommand(redisClient *c, int where) { ...@@ -5253,13 +5253,13 @@ static void popGenericCommand(redisClient *c, int where) {
robj *o = lookupKeyWriteOrReply(c,c->argv[1],shared.nullbulk); robj *o = lookupKeyWriteOrReply(c,c->argv[1],shared.nullbulk);
if (o == NULL || checkType(c,o,REDIS_LIST)) return; if (o == NULL || checkType(c,o,REDIS_LIST)) return;
robj *value = lPop(o,where); robj *value = listTypePop(o,where);
if (value == NULL) { if (value == NULL) {
addReply(c,shared.nullbulk); addReply(c,shared.nullbulk);
} else { } else {
addReplyBulk(c,value); addReplyBulk(c,value);
decrRefCount(value); decrRefCount(value);
if (lLength(o) == 0) dbDelete(c->db,c->argv[1]); if (listTypeLength(o) == 0) dbDelete(c->db,c->argv[1]);
server.dirty++; server.dirty++;
} }
} }
...@@ -5278,11 +5278,11 @@ static void lrangeCommand(redisClient *c) { ...@@ -5278,11 +5278,11 @@ static void lrangeCommand(redisClient *c) {
int end = atoi(c->argv[3]->ptr); int end = atoi(c->argv[3]->ptr);
int llen; int llen;
int rangelen, j; int rangelen, j;
lEntry entry; listTypeEntry entry;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptymultibulk)) == NULL if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptymultibulk)) == NULL
|| checkType(c,o,REDIS_LIST)) return; || checkType(c,o,REDIS_LIST)) return;
llen = lLength(o); llen = listTypeLength(o);
/* convert negative indexes */ /* convert negative indexes */
if (start < 0) start = llen+start; if (start < 0) start = llen+start;
...@@ -5301,14 +5301,14 @@ static void lrangeCommand(redisClient *c) { ...@@ -5301,14 +5301,14 @@ static void lrangeCommand(redisClient *c) {
/* Return the result in form of a multi-bulk reply */ /* Return the result in form of a multi-bulk reply */
addReplySds(c,sdscatprintf(sdsempty(),"*%d\r\n",rangelen)); addReplySds(c,sdscatprintf(sdsempty(),"*%d\r\n",rangelen));
lIterator *li = lInitIterator(o,start,REDIS_TAIL); listTypeIterator *li = listTypeInitIterator(o,start,REDIS_TAIL);
for (j = 0; j < rangelen; j++) { for (j = 0; j < rangelen; j++) {
redisAssert(lNext(li,&entry)); redisAssert(listTypeNext(li,&entry));
value = lGet(&entry); value = listTypeGet(&entry);
addReplyBulk(c,value); addReplyBulk(c,value);
decrRefCount(value); decrRefCount(value);
} }
lReleaseIterator(li); listTypeReleaseIterator(li);
} }
static void ltrimCommand(redisClient *c) { static void ltrimCommand(redisClient *c) {
...@@ -5322,7 +5322,7 @@ static void ltrimCommand(redisClient *c) { ...@@ -5322,7 +5322,7 @@ static void ltrimCommand(redisClient *c) {
if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.ok)) == NULL || if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.ok)) == NULL ||
checkType(c,o,REDIS_LIST)) return; checkType(c,o,REDIS_LIST)) return;
llen = lLength(o); llen = listTypeLength(o);
/* convert negative indexes */ /* convert negative indexes */
if (start < 0) start = llen+start; if (start < 0) start = llen+start;
...@@ -5358,7 +5358,7 @@ static void ltrimCommand(redisClient *c) { ...@@ -5358,7 +5358,7 @@ static void ltrimCommand(redisClient *c) {
} else { } else {
redisPanic("Unknown list encoding"); redisPanic("Unknown list encoding");
} }
if (lLength(o) == 0) dbDelete(c->db,c->argv[1]); if (listTypeLength(o) == 0) dbDelete(c->db,c->argv[1]);
server.dirty++; server.dirty++;
addReply(c,shared.ok); addReply(c,shared.ok);
} }
...@@ -5367,7 +5367,7 @@ static void lremCommand(redisClient *c) { ...@@ -5367,7 +5367,7 @@ static void lremCommand(redisClient *c) {
robj *subject, *obj = c->argv[3]; robj *subject, *obj = c->argv[3];
int toremove = atoi(c->argv[2]->ptr); int toremove = atoi(c->argv[2]->ptr);
int removed = 0; int removed = 0;
lEntry entry; listTypeEntry entry;
subject = lookupKeyWriteOrReply(c,c->argv[1],shared.czero); subject = lookupKeyWriteOrReply(c,c->argv[1],shared.czero);
if (subject == NULL || checkType(c,subject,REDIS_LIST)) return; if (subject == NULL || checkType(c,subject,REDIS_LIST)) return;
...@@ -5376,29 +5376,29 @@ static void lremCommand(redisClient *c) { ...@@ -5376,29 +5376,29 @@ static void lremCommand(redisClient *c) {
if (subject->encoding == REDIS_ENCODING_ZIPLIST) if (subject->encoding == REDIS_ENCODING_ZIPLIST)
obj = getDecodedObject(obj); obj = getDecodedObject(obj);
lIterator *li; listTypeIterator *li;
if (toremove < 0) { if (toremove < 0) {
toremove = -toremove; toremove = -toremove;
li = lInitIterator(subject,-1,REDIS_HEAD); li = listTypeInitIterator(subject,-1,REDIS_HEAD);
} else { } else {
li = lInitIterator(subject,0,REDIS_TAIL); li = listTypeInitIterator(subject,0,REDIS_TAIL);
} }
while (lNext(li,&entry)) { while (listTypeNext(li,&entry)) {
if (lEqual(&entry,obj)) { if (listTypeEqual(&entry,obj)) {
lDelete(&entry); listTypeDelete(&entry);
server.dirty++; server.dirty++;
removed++; removed++;
if (toremove && removed == toremove) break; if (toremove && removed == toremove) break;
} }
} }
lReleaseIterator(li); listTypeReleaseIterator(li);
/* Clean up raw encoded object */ /* Clean up raw encoded object */
if (subject->encoding == REDIS_ENCODING_ZIPLIST) if (subject->encoding == REDIS_ENCODING_ZIPLIST)
decrRefCount(obj); decrRefCount(obj);
if (lLength(subject) == 0) dbDelete(c->db,c->argv[1]); if (listTypeLength(subject) == 0) dbDelete(c->db,c->argv[1]);
addReplySds(c,sdscatprintf(sdsempty(),":%d\r\n",removed)); addReplySds(c,sdscatprintf(sdsempty(),":%d\r\n",removed));
} }
...@@ -5422,12 +5422,12 @@ static void rpoplpushcommand(redisClient *c) { ...@@ -5422,12 +5422,12 @@ static void rpoplpushcommand(redisClient *c) {
if ((sobj = lookupKeyWriteOrReply(c,c->argv[1],shared.nullbulk)) == NULL || if ((sobj = lookupKeyWriteOrReply(c,c->argv[1],shared.nullbulk)) == NULL ||
checkType(c,sobj,REDIS_LIST)) return; checkType(c,sobj,REDIS_LIST)) return;
if (lLength(sobj) == 0) { if (listTypeLength(sobj) == 0) {
addReply(c,shared.nullbulk); addReply(c,shared.nullbulk);
} else { } else {
robj *dobj = lookupKeyWrite(c->db,c->argv[2]); robj *dobj = lookupKeyWrite(c->db,c->argv[2]);
if (dobj && checkType(c,dobj,REDIS_LIST)) return; if (dobj && checkType(c,dobj,REDIS_LIST)) return;
value = lPop(sobj,REDIS_TAIL); value = listTypePop(sobj,REDIS_TAIL);
/* Add the element to the target list (unless it's directly /* Add the element to the target list (unless it's directly
* passed to some BLPOP-ing client */ * passed to some BLPOP-ing client */
...@@ -5437,17 +5437,17 @@ static void rpoplpushcommand(redisClient *c) { ...@@ -5437,17 +5437,17 @@ static void rpoplpushcommand(redisClient *c) {
dobj = createZiplistObject(); dobj = createZiplistObject();
dbAdd(c->db,c->argv[2],dobj); dbAdd(c->db,c->argv[2],dobj);
} }
lPush(dobj,value,REDIS_HEAD); listTypePush(dobj,value,REDIS_HEAD);
} }
/* Send the element to the client as reply as well */ /* Send the element to the client as reply as well */
addReplyBulk(c,value); addReplyBulk(c,value);
/* lPop returns an object with its refcount incremented */ /* listTypePop returns an object with its refcount incremented */
decrRefCount(value); decrRefCount(value);
/* Delete the source list when it is empty */ /* Delete the source list when it is empty */
if (lLength(sobj) == 0) dbDelete(c->db,c->argv[1]); if (listTypeLength(sobj) == 0) dbDelete(c->db,c->argv[1]);
server.dirty++; server.dirty++;
} }
} }
...@@ -6070,7 +6070,7 @@ static zskiplistNode *zslFirstWithScore(zskiplist *zsl, double score) { ...@@ -6070,7 +6070,7 @@ static zskiplistNode *zslFirstWithScore(zskiplist *zsl, double score) {
* Returns 0 when the element cannot be found, rank otherwise. * Returns 0 when the element cannot be found, rank otherwise.
* Note that the rank is 1-based due to the span of zsl->header to the * Note that the rank is 1-based due to the span of zsl->header to the
* first element. */ * first element. */
static unsigned long zslGetRank(zskiplist *zsl, double score, robj *o) { static unsigned long zslistTypeGetRank(zskiplist *zsl, double score, robj *o) {
zskiplistNode *x; zskiplistNode *x;
unsigned long rank = 0; unsigned long rank = 0;
int i; int i;
...@@ -6094,7 +6094,7 @@ static unsigned long zslGetRank(zskiplist *zsl, double score, robj *o) { ...@@ -6094,7 +6094,7 @@ static unsigned long zslGetRank(zskiplist *zsl, double score, robj *o) {
} }
/* Finds an element by its rank. The rank argument needs to be 1-based. */ /* Finds an element by its rank. The rank argument needs to be 1-based. */
zskiplistNode* zslGetElementByRank(zskiplist *zsl, unsigned long rank) { zskiplistNode* zslistTypeGetElementByRank(zskiplist *zsl, unsigned long rank) {
zskiplistNode *x; zskiplistNode *x;
unsigned long traversed = 0; unsigned long traversed = 0;
int i; int i;
...@@ -6560,10 +6560,10 @@ static void zrangeGenericCommand(redisClient *c, int reverse) { ...@@ -6560,10 +6560,10 @@ static void zrangeGenericCommand(redisClient *c, int reverse) {
/* check if starting point is trivial, before searching /* check if starting point is trivial, before searching
* the element in log(N) time */ * the element in log(N) time */
if (reverse) { if (reverse) {
ln = start == 0 ? zsl->tail : zslGetElementByRank(zsl, llen-start); ln = start == 0 ? zsl->tail : zslistTypeGetElementByRank(zsl, llen-start);
} else { } else {
ln = start == 0 ? ln = start == 0 ?
zsl->header->forward[0] : zslGetElementByRank(zsl, start+1); zsl->header->forward[0] : zslistTypeGetElementByRank(zsl, start+1);
} }
/* Return the result in form of a multi-bulk reply */ /* Return the result in form of a multi-bulk reply */
...@@ -6760,7 +6760,7 @@ static void zrankGenericCommand(redisClient *c, int reverse) { ...@@ -6760,7 +6760,7 @@ static void zrankGenericCommand(redisClient *c, int reverse) {
} }
score = dictGetEntryVal(de); score = dictGetEntryVal(de);
rank = zslGetRank(zsl, *score, c->argv[2]); rank = zslistTypeGetRank(zsl, *score, c->argv[2]);
if (rank) { if (rank) {
if (reverse) { if (reverse) {
addReplyLongLong(c, zsl->length - rank); addReplyLongLong(c, zsl->length - rank);
...@@ -7407,7 +7407,7 @@ static void sortCommand(redisClient *c) { ...@@ -7407,7 +7407,7 @@ static void sortCommand(redisClient *c) {
/* Load the sorting vector with all the objects to sort */ /* Load the sorting vector with all the objects to sort */
switch(sortval->type) { switch(sortval->type) {
case REDIS_LIST: vectorlen = lLength(sortval); break; case REDIS_LIST: vectorlen = listTypeLength(sortval); break;
case REDIS_SET: vectorlen = dictSize((dict*)sortval->ptr); break; case REDIS_SET: vectorlen = dictSize((dict*)sortval->ptr); break;
case REDIS_ZSET: vectorlen = dictSize(((zset*)sortval->ptr)->dict); break; case REDIS_ZSET: vectorlen = dictSize(((zset*)sortval->ptr)->dict); break;
default: vectorlen = 0; redisPanic("Bad SORT type"); /* Avoid GCC warning */ default: vectorlen = 0; redisPanic("Bad SORT type"); /* Avoid GCC warning */
...@@ -7416,15 +7416,15 @@ static void sortCommand(redisClient *c) { ...@@ -7416,15 +7416,15 @@ static void sortCommand(redisClient *c) {
j = 0; j = 0;
if (sortval->type == REDIS_LIST) { if (sortval->type == REDIS_LIST) {
lIterator *li = lInitIterator(sortval,0,REDIS_TAIL); listTypeIterator *li = listTypeInitIterator(sortval,0,REDIS_TAIL);
lEntry entry; listTypeEntry entry;
while(lNext(li,&entry)) { while(listTypeNext(li,&entry)) {
vector[j].obj = lGet(&entry); vector[j].obj = listTypeGet(&entry);
vector[j].u.score = 0; vector[j].u.score = 0;
vector[j].u.cmpobj = NULL; vector[j].u.cmpobj = NULL;
j++; j++;
} }
lReleaseIterator(li); listTypeReleaseIterator(li);
} else { } else {
dict *set; dict *set;
dictIterator *di; dictIterator *di;
...@@ -7542,7 +7542,7 @@ static void sortCommand(redisClient *c) { ...@@ -7542,7 +7542,7 @@ static void sortCommand(redisClient *c) {
listIter li; listIter li;
if (!getop) { if (!getop) {
lPush(sobj,vector[j].obj,REDIS_TAIL); listTypePush(sobj,vector[j].obj,REDIS_TAIL);
} else { } else {
listRewind(operations,&li); listRewind(operations,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
...@@ -7553,10 +7553,10 @@ static void sortCommand(redisClient *c) { ...@@ -7553,10 +7553,10 @@ static void sortCommand(redisClient *c) {
if (sop->type == REDIS_SORT_GET) { if (sop->type == REDIS_SORT_GET) {
if (!val) val = createStringObject("",0); if (!val) val = createStringObject("",0);
/* lPush does an incrRefCount, so we should take care /* listTypePush does an incrRefCount, so we should take care
* care of the incremented refcount caused by either * care of the incremented refcount caused by either
* lookupKeyByPattern or createStringObject("",0) */ * lookupKeyByPattern or createStringObject("",0) */
lPush(sobj,val,REDIS_TAIL); listTypePush(sobj,val,REDIS_TAIL);
decrRefCount(val); decrRefCount(val);
} else { } else {
/* always fails */ /* always fails */
...@@ -11075,14 +11075,14 @@ static void computeDatasetDigest(unsigned char *final) { ...@@ -11075,14 +11075,14 @@ static void computeDatasetDigest(unsigned char *final) {
if (o->type == REDIS_STRING) { if (o->type == REDIS_STRING) {
mixObjectDigest(digest,o); mixObjectDigest(digest,o);
} else if (o->type == REDIS_LIST) { } else if (o->type == REDIS_LIST) {
lIterator *li = lInitIterator(o,0,REDIS_TAIL); listTypeIterator *li = listTypeInitIterator(o,0,REDIS_TAIL);
lEntry entry; listTypeEntry entry;
while(lNext(li,&entry)) { while(listTypeNext(li,&entry)) {
robj *eleobj = lGet(&entry); robj *eleobj = listTypeGet(&entry);
mixObjectDigest(digest,eleobj); mixObjectDigest(digest,eleobj);
decrRefCount(eleobj); decrRefCount(eleobj);
} }
lReleaseIterator(li); listTypeReleaseIterator(li);
} else if (o->type == REDIS_SET) { } else if (o->type == REDIS_SET) {
dict *set = o->ptr; dict *set = o->ptr;
dictIterator *di = dictGetIterator(set); dictIterator *di = dictGetIterator(set);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册