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

Function hashTypeCurrentObject

src/t_hash.cpp:429–440  ·  view source on GitHub ↗

Higher level function of hashTypeCurrent*() that returns the hash value * at current iterator position. * * The returned element is returned by reference in either *vstr and *vlen if * it's returned in string form, or stored in *vll if it's returned as * a number. * * If *vll is populated *vstr is set to NULL, so the caller * can always check the function return by checking the return valu

Source from the content-addressed store, hash-verified

427 * can always check the function return by checking the return value
428 * type checking if vstr == NULL. */
429void hashTypeCurrentObject(hashTypeIterator *hi, int what, unsigned char **vstr, unsigned int *vlen, long long *vll) {
430 if (hi->encoding == OBJ_ENCODING_ZIPLIST) {
431 *vstr = NULL;
432 hashTypeCurrentFromZiplist(hi, what, vstr, vlen, vll);
433 } else if (hi->encoding == OBJ_ENCODING_HT) {
434 sds ele = hashTypeCurrentFromHashTable(hi, what);
435 *vstr = (unsigned char*) ele;
436 *vlen = sdslen(ele);
437 } else {
438 serverPanic("Unknown hash encoding");
439 }
440}
441
442/* Return the key or value at the current iterator position as a new
443 * SDS string. */

Callers 1

Calls 3

sdslenFunction · 0.85

Tested by

no test coverage detected