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

Function setTypeNextObject

src/t_set.cpp:180–196  ·  view source on GitHub ↗

The not copy on write friendly version but easy to use version * of setTypeNext() is setTypeNextObject(), returning new SDS * strings. So if you don't retain a pointer to this object you should call * sdsfree() against it. * * This function is the way to go for write operations where COW is not * an issue. */

Source from the content-addressed store, hash-verified

178 * This function is the way to go for write operations where COW is not
179 * an issue. */
180sds setTypeNextObject(setTypeIterator *si) {
181 int64_t intele;
182 const char *sdsele;
183 int encoding;
184
185 encoding = setTypeNext(si,&sdsele,&intele);
186 switch(encoding) {
187 case -1: return NULL;
188 case OBJ_ENCODING_INTSET:
189 return sdsfromlonglong(intele);
190 case OBJ_ENCODING_HT:
191 return sdsdup(sdsele);
192 default:
193 serverPanic("Unsupported encoding");
194 }
195 return NULL; /* just to suppress warnings */
196}
197
198/* Return random element from a non empty set.
199 * The returned element can be an int64_t value if the set is encoded

Callers 3

sortCommandFunction · 0.85
sunionDiffGenericCommandFunction · 0.85
xorObjectDigestFunction · 0.85

Calls 3

setTypeNextFunction · 0.85
sdsfromlonglongFunction · 0.85
sdsdupFunction · 0.85

Tested by

no test coverage detected