Higher level function using hashTypeGet*() to return the length of the * object associated with the requested field, or 0 if the field does not * exist. */
| 148 | * object associated with the requested field, or 0 if the field does not |
| 149 | * exist. */ |
| 150 | size_t hashTypeGetValueLength(robj_roptr o, const char *field) { |
| 151 | size_t len = 0; |
| 152 | if (o->encoding == OBJ_ENCODING_ZIPLIST) { |
| 153 | const unsigned char *vstr = NULL; |
| 154 | unsigned int vlen = UINT_MAX; |
| 155 | long long vll = LLONG_MAX; |
| 156 | |
| 157 | if (hashTypeGetFromZiplist(o, field, &vstr, &vlen, &vll) == 0) |
| 158 | len = vstr ? vlen : sdigits10(vll); |
| 159 | } else if (o->encoding == OBJ_ENCODING_HT) { |
| 160 | const char *aux; |
| 161 | |
| 162 | if ((aux = hashTypeGetFromHashTable(o, field)) != NULL) |
| 163 | len = sdslen(aux); |
| 164 | } else { |
| 165 | serverPanic("Unknown hash encoding"); |
| 166 | } |
| 167 | return len; |
| 168 | } |
| 169 | |
| 170 | /* Test if the specified field exists in the given hash. Returns 1 if the field |
| 171 | * exists, and 0 when it doesn't. */ |
no test coverage detected