Lines Matching refs:zobj
1156 unsigned long zsetLength(const robj *zobj) { in zsetLength() argument
1158 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in zsetLength()
1159 length = zzlLength(zobj->ptr); in zsetLength()
1160 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in zsetLength()
1161 length = ((const zset*)zobj->ptr)->zsl->length; in zsetLength()
1168 void zsetConvert(robj *zobj, int encoding) { in zsetConvert() argument
1174 if (zobj->encoding == encoding) return; in zsetConvert()
1175 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in zsetConvert()
1176 unsigned char *zl = zobj->ptr; in zsetConvert()
1190 serverAssertWithInfo(NULL,zobj,eptr != NULL); in zsetConvert()
1192 serverAssertWithInfo(NULL,zobj,sptr != NULL); in zsetConvert()
1196 serverAssertWithInfo(NULL,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong)); in zsetConvert()
1207 zfree(zobj->ptr); in zsetConvert()
1208 zobj->ptr = zs; in zsetConvert()
1209 zobj->encoding = OBJ_ENCODING_SKIPLIST; in zsetConvert()
1210 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in zsetConvert()
1218 zs = zobj->ptr; in zsetConvert()
1232 zobj->ptr = zl; in zsetConvert()
1233 zobj->encoding = OBJ_ENCODING_ZIPLIST; in zsetConvert()
1242 void zsetConvertToZiplistIfNeeded(robj *zobj, size_t maxelelen) { in zsetConvertToZiplistIfNeeded() argument
1243 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) return; in zsetConvertToZiplistIfNeeded()
1244 zset *zset = zobj->ptr; in zsetConvertToZiplistIfNeeded()
1248 zsetConvert(zobj,OBJ_ENCODING_ZIPLIST); in zsetConvertToZiplistIfNeeded()
1255 int zsetScore(robj *zobj, sds member, double *score) { in zsetScore() argument
1256 if (!zobj || !member) return C_ERR; in zsetScore()
1258 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in zsetScore()
1259 if (zzlFind(zobj->ptr, member, score) == NULL) return C_ERR; in zsetScore()
1260 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in zsetScore()
1261 zset *zs = zobj->ptr; in zsetScore()
1314 int zsetAdd(robj *zobj, double score, sds ele, int *flags, double *newscore) { in zsetAdd() argument
1329 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in zsetAdd()
1332 if ((eptr = zzlFind(zobj->ptr,ele,&curscore)) != NULL) { in zsetAdd()
1351 zobj->ptr = zzlDelete(zobj->ptr,eptr); in zsetAdd()
1352 zobj->ptr = zzlInsert(zobj->ptr,ele,score); in zsetAdd()
1359 zobj->ptr = zzlInsert(zobj->ptr,ele,score); in zsetAdd()
1360 if (zzlLength(zobj->ptr) > server.zset_max_ziplist_entries) in zsetAdd()
1361 zsetConvert(zobj,OBJ_ENCODING_SKIPLIST); in zsetAdd()
1363 zsetConvert(zobj,OBJ_ENCODING_SKIPLIST); in zsetAdd()
1371 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in zsetAdd()
1372 zset *zs = zobj->ptr; in zsetAdd()
1424 int zsetDel(robj *zobj, sds ele) { in zsetDel() argument
1425 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in zsetDel()
1428 if ((eptr = zzlFind(zobj->ptr,ele,NULL)) != NULL) { in zsetDel()
1429 zobj->ptr = zzlDelete(zobj->ptr,eptr); in zsetDel()
1432 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in zsetDel()
1433 zset *zs = zobj->ptr; in zsetDel()
1473 long zsetRank(robj *zobj, sds ele, int reverse) { in zsetRank() argument
1477 llen = zsetLength(zobj); in zsetRank()
1479 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in zsetRank()
1480 unsigned char *zl = zobj->ptr; in zsetRank()
1504 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in zsetRank()
1505 zset *zs = zobj->ptr; in zsetRank()
1536 robj *zobj; in zaddGenericCommand() local
1600 zobj = lookupKeyWrite(c->db,key); in zaddGenericCommand()
1601 if (zobj == NULL) { in zaddGenericCommand()
1606 zobj = createZsetObject(); in zaddGenericCommand()
1608 zobj = createZsetZiplistObject(); in zaddGenericCommand()
1610 dbAdd(c->db,key,zobj); in zaddGenericCommand()
1612 if (zobj->type != OBJ_ZSET) { in zaddGenericCommand()
1624 int retval = zsetAdd(zobj, score, ele, &retflags, &newscore); in zaddGenericCommand()
1665 robj *zobj; in zremCommand() local
1668 if ((zobj = lookupKeyWriteOrReply(c,key,shared.czero)) == NULL || in zremCommand()
1669 checkType(c,zobj,OBJ_ZSET)) return; in zremCommand()
1672 if (zsetDel(zobj,c->argv[j]->ptr)) deleted++; in zremCommand()
1673 if (zsetLength(zobj) == 0) { in zremCommand()
1696 robj *zobj; in zremrangeGenericCommand() local
1721 if ((zobj = lookupKeyWriteOrReply(c,key,shared.czero)) == NULL || in zremrangeGenericCommand()
1722 checkType(c,zobj,OBJ_ZSET)) goto cleanup; in zremrangeGenericCommand()
1726 llen = zsetLength(zobj); in zremrangeGenericCommand()
1741 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in zremrangeGenericCommand()
1744 zobj->ptr = zzlDeleteRangeByRank(zobj->ptr,start+1,end+1,&deleted); in zremrangeGenericCommand()
1747 zobj->ptr = zzlDeleteRangeByScore(zobj->ptr,&range,&deleted); in zremrangeGenericCommand()
1750 zobj->ptr = zzlDeleteRangeByLex(zobj->ptr,&lexrange,&deleted); in zremrangeGenericCommand()
1753 if (zzlLength(zobj->ptr) == 0) { in zremrangeGenericCommand()
1757 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in zremrangeGenericCommand()
1758 zset *zs = zobj->ptr; in zremrangeGenericCommand()
2413 robj *zobj; in zrangeGenericCommand() local
2430 if ((zobj = lookupKeyReadOrReply(c,key,shared.emptymultibulk)) == NULL in zrangeGenericCommand()
2431 || checkType(c,zobj,OBJ_ZSET)) return; in zrangeGenericCommand()
2434 llen = zsetLength(zobj); in zrangeGenericCommand()
2451 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in zrangeGenericCommand()
2452 unsigned char *zl = zobj->ptr; in zrangeGenericCommand()
2463 serverAssertWithInfo(c,zobj,eptr != NULL); in zrangeGenericCommand()
2467 serverAssertWithInfo(c,zobj,eptr != NULL && sptr != NULL); in zrangeGenericCommand()
2468 serverAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong)); in zrangeGenericCommand()
2483 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in zrangeGenericCommand()
2484 zset *zs = zobj->ptr; in zrangeGenericCommand()
2501 serverAssertWithInfo(c,zobj,ln != NULL); in zrangeGenericCommand()
2525 robj *zobj; in genericZrangebyscoreCommand() local
2573 if ((zobj = lookupKeyReadOrReply(c,key,shared.emptymultibulk)) == NULL || in genericZrangebyscoreCommand()
2574 checkType(c,zobj,OBJ_ZSET)) return; in genericZrangebyscoreCommand()
2576 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in genericZrangebyscoreCommand()
2577 unsigned char *zl = zobj->ptr; in genericZrangebyscoreCommand()
2598 serverAssertWithInfo(c,zobj,eptr != NULL); in genericZrangebyscoreCommand()
2627 serverAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong)); in genericZrangebyscoreCommand()
2647 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in genericZrangebyscoreCommand()
2648 zset *zs = zobj->ptr; in genericZrangebyscoreCommand()
2723 robj *zobj; in zcountCommand() local
2734 if ((zobj = lookupKeyReadOrReply(c, key, shared.czero)) == NULL || in zcountCommand()
2735 checkType(c, zobj, OBJ_ZSET)) return; in zcountCommand()
2737 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in zcountCommand()
2738 unsigned char *zl = zobj->ptr; in zcountCommand()
2754 serverAssertWithInfo(c,zobj,zslValueLteMax(score,&range)); in zcountCommand()
2768 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in zcountCommand()
2769 zset *zs = zobj->ptr; in zcountCommand()
2800 robj *zobj; in zlexcountCommand() local
2811 if ((zobj = lookupKeyReadOrReply(c, key, shared.czero)) == NULL || in zlexcountCommand()
2812 checkType(c, zobj, OBJ_ZSET)) in zlexcountCommand()
2818 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in zlexcountCommand()
2819 unsigned char *zl = zobj->ptr; in zlexcountCommand()
2834 serverAssertWithInfo(c,zobj,zzlLexValueLteMax(eptr,&range)); in zlexcountCommand()
2846 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in zlexcountCommand()
2847 zset *zs = zobj->ptr; in zlexcountCommand()
2881 robj *zobj; in genericZrangebylexCommand() local
2924 if ((zobj = lookupKeyReadOrReply(c,key,shared.emptymultibulk)) == NULL || in genericZrangebylexCommand()
2925 checkType(c,zobj,OBJ_ZSET)) in genericZrangebylexCommand()
2931 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in genericZrangebylexCommand()
2932 unsigned char *zl = zobj->ptr; in genericZrangebylexCommand()
2953 serverAssertWithInfo(c,zobj,eptr != NULL); in genericZrangebylexCommand()
2981 serverAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong)); in genericZrangebylexCommand()
2997 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in genericZrangebylexCommand()
2998 zset *zs = zobj->ptr; in genericZrangebylexCommand()
3067 robj *zobj; in zcardCommand() local
3069 if ((zobj = lookupKeyReadOrReply(c,key,shared.czero)) == NULL || in zcardCommand()
3070 checkType(c,zobj,OBJ_ZSET)) return; in zcardCommand()
3072 addReplyLongLong(c,zsetLength(zobj)); in zcardCommand()
3077 robj *zobj; in zscoreCommand() local
3080 if ((zobj = lookupKeyReadOrReply(c,key,shared.nullbulk)) == NULL || in zscoreCommand()
3081 checkType(c,zobj,OBJ_ZSET)) return; in zscoreCommand()
3083 if (zsetScore(zobj,c->argv[2]->ptr,&score) == C_ERR) { in zscoreCommand()
3093 robj *zobj; in zrankGenericCommand() local
3096 if ((zobj = lookupKeyReadOrReply(c,key,shared.nullbulk)) == NULL || in zrankGenericCommand()
3097 checkType(c,zobj,OBJ_ZSET)) return; in zrankGenericCommand()
3100 rank = zsetRank(zobj,ele->ptr,reverse); in zrankGenericCommand()
3138 robj *zobj = NULL; in genericZpopCommand() local
3157 zobj = lookupKeyWrite(c->db,key); in genericZpopCommand()
3158 if (!zobj) continue; in genericZpopCommand()
3159 if (checkType(c,zobj,OBJ_ZSET)) return; in genericZpopCommand()
3164 if (!zobj) { in genericZpopCommand()
3177 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { in genericZpopCommand()
3178 unsigned char *zl = zobj->ptr; in genericZpopCommand()
3186 serverAssertWithInfo(c,zobj,eptr != NULL); in genericZpopCommand()
3187 serverAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong)); in genericZpopCommand()
3195 serverAssertWithInfo(c,zobj,sptr != NULL); in genericZpopCommand()
3197 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { in genericZpopCommand()
3198 zset *zs = zobj->ptr; in genericZpopCommand()
3207 serverAssertWithInfo(c,zobj,zln != NULL); in genericZpopCommand()
3214 serverAssertWithInfo(c,zobj,zsetDel(zobj,ele)); in genericZpopCommand()
3229 if (zsetLength(zobj) == 0) { in genericZpopCommand()