MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / setTypeNext

Function setTypeNext

src/t_set.cpp:157–171  ·  view source on GitHub ↗

Move to the next entry in the set. Returns the object at the current * position. * * Since set elements can be internally be stored as SDS strings or * simple arrays of integers, setTypeNext returns the encoding of the * set object you are iterating, and will populate the appropriate pointer * (sdsele) or (llele) accordingly. * * Note that both the sdsele and llele pointers should be passe

Source from the content-addressed store, hash-verified

155 *
156 * When there are no longer elements -1 is returned. */
157int setTypeNext(setTypeIterator *si, const char **sdsele, int64_t *llele) {
158 if (si->encoding == OBJ_ENCODING_HT) {
159 dictEntry *de = dictNext(si->di);
160 if (de == NULL) return -1;
161 *sdsele = (sds)dictGetKey(de);
162 *llele = -123456789; /* Not needed. Defensive. */
163 } else if (si->encoding == OBJ_ENCODING_INTSET) {
164 if (!intsetGet((intset*)si->subject->m_ptr,si->ii++,llele))
165 return -1;
166 *sdsele = NULL; /* Not needed. Defensive. */
167 } else {
168 serverPanic("Wrong set encoding in setTypeNext");
169 }
170 return si->encoding;
171}
172
173/* The not copy on write friendly version but easy to use version
174 * of setTypeNext() is setTypeNextObject(), returning new SDS

Callers 6

setTypeNextObjectFunction · 0.85
setTypeConvertFunction · 0.85
setTypeDupFunction · 0.85
spopWithCountCommandFunction · 0.85
sinterGenericCommandFunction · 0.85

Calls 2

intsetGetFunction · 0.85
dictNextFunction · 0.70

Tested by

no test coverage detected