Test if the specified field exists in the given hash. Returns 1 if the field * exists, and 0 when it doesn't. */
| 170 | /* Test if the specified field exists in the given hash. Returns 1 if the field |
| 171 | * exists, and 0 when it doesn't. */ |
| 172 | int hashTypeExists(robj_roptr o, const char *field) { |
| 173 | if (o->encoding == OBJ_ENCODING_ZIPLIST) { |
| 174 | const unsigned char *vstr = NULL; |
| 175 | unsigned int vlen = UINT_MAX; |
| 176 | long long vll = LLONG_MAX; |
| 177 | |
| 178 | if (hashTypeGetFromZiplist(o, field, &vstr, &vlen, &vll) == 0) return 1; |
| 179 | } else if (o->encoding == OBJ_ENCODING_HT) { |
| 180 | if (hashTypeGetFromHashTable(o, field) != NULL) return 1; |
| 181 | } else { |
| 182 | serverPanic("Unknown hash encoding"); |
| 183 | } |
| 184 | return 0; |
| 185 | } |
| 186 | |
| 187 | /* Add a new field, overwrite the old with the new value if it already exists. |
| 188 | * Return 0 on insert and 1 on update. |
no test coverage detected