MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zuiInitIterator

Function zuiInitIterator

app/redis-6.2.6/src/t_zset.c:2069–2106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2067typedef union _iterzset iterzset;
2068
2069void zuiInitIterator(zsetopsrc *op) {
2070 if (op->subject == NULL)
2071 return;
2072
2073 if (op->type == OBJ_SET) {
2074 iterset *it = &op->iter.set;
2075 if (op->encoding == OBJ_ENCODING_INTSET) {
2076 it->is.is = op->subject->ptr;
2077 it->is.ii = 0;
2078 } else if (op->encoding == OBJ_ENCODING_HT) {
2079 it->ht.dict = op->subject->ptr;
2080 it->ht.di = dictGetIterator(op->subject->ptr);
2081 it->ht.de = dictNext(it->ht.di);
2082 } else {
2083 serverPanic("Unknown set encoding");
2084 }
2085 } else if (op->type == OBJ_ZSET) {
2086 /* Sorted sets are traversed in reverse order to optimize for
2087 * the insertion of the elements in a new list as in
2088 * ZDIFF/ZINTER/ZUNION */
2089 iterzset *it = &op->iter.zset;
2090 if (op->encoding == OBJ_ENCODING_ZIPLIST) {
2091 it->zl.zl = op->subject->ptr;
2092 it->zl.eptr = ziplistIndex(it->zl.zl,-2);
2093 if (it->zl.eptr != NULL) {
2094 it->zl.sptr = ziplistNext(it->zl.zl,it->zl.eptr);
2095 serverAssert(it->zl.sptr != NULL);
2096 }
2097 } else if (op->encoding == OBJ_ENCODING_SKIPLIST) {
2098 it->sl.zs = op->subject->ptr;
2099 it->sl.node = it->sl.zs->zsl->tail;
2100 } else {
2101 serverPanic("Unknown sorted set encoding");
2102 }
2103 } else {
2104 serverPanic("Unsupported type");
2105 }
2106}
2107
2108void zuiClearIterator(zsetopsrc *op) {
2109 if (op->subject == NULL)

Callers 4

zdiffAlgorithm1Function · 0.85
zdiffAlgorithm2Function · 0.85

Calls 4

ziplistIndexFunction · 0.85
ziplistNextFunction · 0.85
dictGetIteratorFunction · 0.70
dictNextFunction · 0.70

Tested by

no test coverage detected