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

Function hashTypeGetValue

src/t_hash.cpp:115–131  ·  view source on GitHub ↗

Higher level function of hashTypeGet*() that returns the hash value * associated with the specified field. If the field is found C_OK * is returned, otherwise C_ERR. The returned object 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 alwa

Source from the content-addressed store, hash-verified

113 * can always check the function return by checking the return value
114 * for C_OK and checking if vll (or vstr) is NULL. */
115int hashTypeGetValue(robj_roptr o, sds field, const unsigned char **vstr, unsigned int *vlen, long long *vll) {
116 if (o->encoding == OBJ_ENCODING_ZIPLIST) {
117 *vstr = NULL;
118 if (hashTypeGetFromZiplist(o, field, vstr, vlen, vll) == 0)
119 return C_OK;
120 } else if (o->encoding == OBJ_ENCODING_HT) {
121 const char *value;
122 if ((value = hashTypeGetFromHashTable(o, field)) != NULL) {
123 *vstr = (const unsigned char*) value;
124 *vlen = sdslen(value);
125 return C_OK;
126 }
127 } else {
128 serverPanic("Unknown hash encoding");
129 }
130 return C_ERR;
131}
132
133/* Like hashTypeGetValue() but returns a Redis object, which is useful for
134 * interaction with the hash type outside t_hash.c.

Callers 4

hashTypeGetValueObjectFunction · 0.85
hincrbyCommandFunction · 0.85
hincrbyfloatCommandFunction · 0.85
hrenameCommandFunction · 0.85

Calls 3

hashTypeGetFromZiplistFunction · 0.85
hashTypeGetFromHashTableFunction · 0.85
sdslenFunction · 0.85

Tested by

no test coverage detected