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

Function hashTypeLength

src/t_hash.cpp:314–325  ·  view source on GitHub ↗

Return the number of elements in a hash. */

Source from the content-addressed store, hash-verified

312
313/* Return the number of elements in a hash. */
314unsigned long hashTypeLength(robj_roptr o) {
315 unsigned long length = ULONG_MAX;
316
317 if (o->encoding == OBJ_ENCODING_ZIPLIST) {
318 length = ziplistLen((unsigned char*)ptrFromObj(o)) / 2;
319 } else if (o->encoding == OBJ_ENCODING_HT) {
320 length = dictSize((const dict*)ptrFromObj(o));
321 } else {
322 serverPanic("Unknown hash encoding");
323 }
324 return length;
325}
326
327hashTypeIterator *hashTypeInitIterator(robj_roptr subject) {
328 hashTypeIterator *hi = (hashTypeIterator*)zmalloc(sizeof(hashTypeIterator), MALLOC_LOCAL);

Callers 12

hashTypeSetFunction · 0.85
hdelCommandFunction · 0.85
hlenCommandFunction · 0.85
genericHgetallCommandFunction · 0.85
hrandfieldCommandFunction · 0.85
rdbLoadObjectFunction · 0.85
activeExpireCycleExpireFunction · 0.85
serverLogObjectDebugInfoFunction · 0.85
moduleDelKeyIfEmptyFunction · 0.85
RM_ValueLengthFunction · 0.85
rewriteHashObjectFunction · 0.85

Calls 2

ziplistLenFunction · 0.85
ptrFromObjFunction · 0.85

Tested by

no test coverage detected