Lines Matching refs:zsl

67     zskiplist *zsl;  in zslCreate()  local
69 zsl = zmalloc(sizeof(*zsl)); in zslCreate()
70 zsl->level = 1; in zslCreate()
71 zsl->length = 0; in zslCreate()
72 zsl->header = zslCreateNode(ZSKIPLIST_MAXLEVEL,0,NULL); in zslCreate()
74 zsl->header->level[j].forward = NULL; in zslCreate()
75 zsl->header->level[j].span = 0; in zslCreate()
77 zsl->header->backward = NULL; in zslCreate()
78 zsl->tail = NULL; in zslCreate()
79 return zsl; in zslCreate()
87 void zslFree(zskiplist *zsl) { in zslFree() argument
88 zskiplistNode *node = zsl->header->level[0].forward, *next; in zslFree()
90 zfree(zsl->header); in zslFree()
96 zfree(zsl); in zslFree()
110 zskiplistNode *zslInsert(zskiplist *zsl, double score, robj *obj) { in zslInsert() argument
116 x = zsl->header; in zslInsert()
117 for (i = zsl->level-1; i >= 0; i--) { in zslInsert()
119 rank[i] = i == (zsl->level-1) ? 0 : rank[i+1]; in zslInsert()
134 if (level > zsl->level) { in zslInsert()
135 for (i = zsl->level; i < level; i++) { in zslInsert()
137 update[i] = zsl->header; in zslInsert()
138 update[i]->level[i].span = zsl->length; in zslInsert()
140 zsl->level = level; in zslInsert()
153 for (i = level; i < zsl->level; i++) { in zslInsert()
157 x->backward = (update[0] == zsl->header) ? NULL : update[0]; in zslInsert()
161 zsl->tail = x; in zslInsert()
162 zsl->length++; in zslInsert()
167 void zslDeleteNode(zskiplist *zsl, zskiplistNode *x, zskiplistNode **update) { in zslDeleteNode() argument
169 for (i = 0; i < zsl->level; i++) { in zslDeleteNode()
180 zsl->tail = x->backward; in zslDeleteNode()
182 while(zsl->level > 1 && zsl->header->level[zsl->level-1].forward == NULL) in zslDeleteNode()
183 zsl->level--; in zslDeleteNode()
184 zsl->length--; in zslDeleteNode()
188 int zslDelete(zskiplist *zsl, double score, robj *obj) { in zslDelete() argument
192 x = zsl->header; in zslDelete()
193 for (i = zsl->level-1; i >= 0; i--) { in zslDelete()
205 zslDeleteNode(zsl, x, update); in zslDelete()
221 int zslIsInRange(zskiplist *zsl, zrangespec *range) { in zslIsInRange() argument
228 x = zsl->tail; in zslIsInRange()
231 x = zsl->header->level[0].forward; in zslIsInRange()
239 zskiplistNode *zslFirstInRange(zskiplist *zsl, zrangespec *range) { in zslFirstInRange() argument
244 if (!zslIsInRange(zsl,range)) return NULL; in zslFirstInRange()
246 x = zsl->header; in zslFirstInRange()
247 for (i = zsl->level-1; i >= 0; i--) { in zslFirstInRange()
265 zskiplistNode *zslLastInRange(zskiplist *zsl, zrangespec *range) { in zslLastInRange() argument
270 if (!zslIsInRange(zsl,range)) return NULL; in zslLastInRange()
272 x = zsl->header; in zslLastInRange()
273 for (i = zsl->level-1; i >= 0; i--) { in zslLastInRange()
292 unsigned long zslDeleteRangeByScore(zskiplist *zsl, zrangespec *range, dict *dict) { in zslDeleteRangeByScore() argument
297 x = zsl->header; in zslDeleteRangeByScore()
298 for (i = zsl->level-1; i >= 0; i--) { in zslDeleteRangeByScore()
314 zslDeleteNode(zsl,x,update); in zslDeleteRangeByScore()
323 unsigned long zslDeleteRangeByLex(zskiplist *zsl, zlexrangespec *range, dict *dict) { in zslDeleteRangeByLex() argument
329 x = zsl->header; in zslDeleteRangeByLex()
330 for (i = zsl->level-1; i >= 0; i--) { in zslDeleteRangeByLex()
343 zslDeleteNode(zsl,x,update); in zslDeleteRangeByLex()
354 unsigned long zslDeleteRangeByRank(zskiplist *zsl, unsigned int start, unsigned int end, dict *dict… in zslDeleteRangeByRank() argument
359 x = zsl->header; in zslDeleteRangeByRank()
360 for (i = zsl->level-1; i >= 0; i--) { in zslDeleteRangeByRank()
372 zslDeleteNode(zsl,x,update); in zslDeleteRangeByRank()
386 unsigned long zslGetRank(zskiplist *zsl, double score, robj *o) { in zslGetRank() argument
391 x = zsl->header; in zslGetRank()
392 for (i = zsl->level-1; i >= 0; i--) { in zslGetRank()
410 zskiplistNode* zslGetElementByRank(zskiplist *zsl, unsigned long rank) { in zslGetElementByRank() argument
415 x = zsl->header; in zslGetElementByRank()
416 for (i = zsl->level-1; i >= 0; i--) { in zslGetElementByRank()
563 int zslIsInLexRange(zskiplist *zsl, zlexrangespec *range) { in zslIsInLexRange() argument
571 x = zsl->tail; in zslIsInLexRange()
574 x = zsl->header->level[0].forward; in zslIsInLexRange()
582 zskiplistNode *zslFirstInLexRange(zskiplist *zsl, zlexrangespec *range) { in zslFirstInLexRange() argument
587 if (!zslIsInLexRange(zsl,range)) return NULL; in zslFirstInLexRange()
589 x = zsl->header; in zslFirstInLexRange()
590 for (i = zsl->level-1; i >= 0; i--) { in zslFirstInLexRange()
608 zskiplistNode *zslLastInLexRange(zskiplist *zsl, zlexrangespec *range) { in zslLastInLexRange() argument
613 if (!zslIsInLexRange(zsl,range)) return NULL; in zslLastInLexRange()
615 x = zsl->header; in zslLastInLexRange()
616 for (i = zsl->level-1; i >= 0; i--) { in zslLastInLexRange()
1086 length = ((zset*)zobj->ptr)->zsl->length; in zsetLength()
1112 zs->zsl = zslCreate(); in zsetConvert()
1128 node = zslInsert(zs->zsl,score,ele); in zsetConvert()
1147 node = zs->zsl->header->level[0].forward; in zsetConvert()
1148 zfree(zs->zsl->header); in zsetConvert()
1149 zfree(zs->zsl); in zsetConvert()
1176 if (zset->zsl->length <= server.zset_max_ziplist_entries && in zsetConvertToZiplistIfNeeded()
1362 serverAssertWithInfo(c,curobj,zslDelete(zs->zsl,curscore,curobj)); in zaddGenericCommand()
1363 znode = zslInsert(zs->zsl,score,curobj); in zaddGenericCommand()
1371 znode = zslInsert(zs->zsl,score,ele); in zaddGenericCommand()
1445 serverAssertWithInfo(c,c->argv[j],zslDelete(zs->zsl,score,c->argv[j])); in zremCommand()
1542 deleted = zslDeleteRangeByRank(zs->zsl,start+1,end+1,zs->dict); in zremrangeGenericCommand()
1545 deleted = zslDeleteRangeByScore(zs->zsl,&range,zs->dict); in zremrangeGenericCommand()
1548 deleted = zslDeleteRangeByLex(zs->zsl,&lexrange,zs->dict); in zremrangeGenericCommand()
1673 it->sl.node = it->sl.zs->zsl->header->level[0].forward; in zuiInitIterator()
1727 return zs->zsl->length; in zuiLength()
2062 znode = zslInsert(dstzset->zsl,score,tmp); in zunionInterGenericCommand()
2138 znode = zslInsert(dstzset->zsl,score,ele); in zunionInterGenericCommand()
2153 if (dstzset->zsl->length) { in zunionInterGenericCommand()
2256 zskiplist *zsl = zs->zsl; in zrangeGenericCommand() local
2262 ln = zsl->tail; in zrangeGenericCommand()
2264 ln = zslGetElementByRank(zsl,llen-start); in zrangeGenericCommand()
2266 ln = zsl->header->level[0].forward; in zrangeGenericCommand()
2268 ln = zslGetElementByRank(zsl,start+1); in zrangeGenericCommand()
2415 zskiplist *zsl = zs->zsl; in genericZrangebyscoreCommand() local
2420 ln = zslLastInRange(zsl,&range); in genericZrangebyscoreCommand()
2422 ln = zslFirstInRange(zsl,&range); in genericZrangebyscoreCommand()
2536 zskiplist *zsl = zs->zsl; in zcountCommand() local
2541 zn = zslFirstInRange(zsl, &range); in zcountCommand()
2545 rank = zslGetRank(zsl, zn->score, zn->obj); in zcountCommand()
2546 count = (zsl->length - (rank - 1)); in zcountCommand()
2549 zn = zslLastInRange(zsl, &range); in zcountCommand()
2553 rank = zslGetRank(zsl, zn->score, zn->obj); in zcountCommand()
2554 count -= (zsl->length - rank); in zcountCommand()
2614 zskiplist *zsl = zs->zsl; in zlexcountCommand() local
2619 zn = zslFirstInLexRange(zsl, &range); in zlexcountCommand()
2623 rank = zslGetRank(zsl, zn->score, zn->obj); in zlexcountCommand()
2624 count = (zsl->length - (rank - 1)); in zlexcountCommand()
2627 zn = zslLastInLexRange(zsl, &range); in zlexcountCommand()
2631 rank = zslGetRank(zsl, zn->score, zn->obj); in zlexcountCommand()
2632 count -= (zsl->length - rank); in zlexcountCommand()
2762 zskiplist *zsl = zs->zsl; in genericZrangebylexCommand() local
2767 ln = zslLastInLexRange(zsl,&range); in genericZrangebylexCommand()
2769 ln = zslFirstInLexRange(zsl,&range); in genericZrangebylexCommand()
2893 zskiplist *zsl = zs->zsl; in zrankGenericCommand() local
2901 rank = zslGetRank(zsl,score,ele); in zrankGenericCommand()