| 2132 | } |
| 2133 | |
| 2134 | unsigned long zuiLength(zsetopsrc *op) { |
| 2135 | if (op->subject == NULL) |
| 2136 | return 0; |
| 2137 | |
| 2138 | if (op->type == OBJ_SET) { |
| 2139 | if (op->encoding == OBJ_ENCODING_INTSET) { |
| 2140 | return intsetLen((const intset*)op->subject->m_ptr); |
| 2141 | } else if (op->encoding == OBJ_ENCODING_HT) { |
| 2142 | dict *ht = (dict*)op->subject->m_ptr; |
| 2143 | return dictSize(ht); |
| 2144 | } else { |
| 2145 | serverPanic("Unknown set encoding"); |
| 2146 | } |
| 2147 | } else if (op->type == OBJ_ZSET) { |
| 2148 | if (op->encoding == OBJ_ENCODING_ZIPLIST) { |
| 2149 | return zzlLength((unsigned char*)op->subject->m_ptr); |
| 2150 | } else if (op->encoding == OBJ_ENCODING_SKIPLIST) { |
| 2151 | zset *zs = (zset*)op->subject->m_ptr; |
| 2152 | return zs->zsl->length; |
| 2153 | } else { |
| 2154 | serverPanic("Unknown sorted set encoding"); |
| 2155 | } |
| 2156 | } else { |
| 2157 | serverPanic("Unsupported type"); |
| 2158 | } |
| 2159 | } |
| 2160 | |
| 2161 | /* Check if the current value is valid. If so, store it in the passed structure |
| 2162 | * and move to the next element. If not valid, this means we have reached the |
no test coverage detected