MCPcopy Create free account
hub / github.com/F-Stack/f-stack / isHLLObjectOrReply

Function isHLLObjectOrReply

app/redis-6.2.6/src/hyperloglog.c:1149–1177  ·  view source on GitHub ↗

Check if the object is a String with a valid HLL representation. * Return C_OK if this is true, otherwise reply to the client * with an error and return C_ERR. */

Source from the content-addressed store, hash-verified

1147 * Return C_OK if this is true, otherwise reply to the client
1148 * with an error and return C_ERR. */
1149int isHLLObjectOrReply(client *c, robj *o) {
1150 struct hllhdr *hdr;
1151
1152 /* Key exists, check type */
1153 if (checkType(c,o,OBJ_STRING))
1154 return C_ERR; /* Error already sent. */
1155
1156 if (!sdsEncodedObject(o)) goto invalid;
1157 if (stringObjectLen(o) < sizeof(*hdr)) goto invalid;
1158 hdr = o->ptr;
1159
1160 /* Magic should be "HYLL". */
1161 if (hdr->magic[0] != 'H' || hdr->magic[1] != 'Y' ||
1162 hdr->magic[2] != 'L' || hdr->magic[3] != 'L') goto invalid;
1163
1164 if (hdr->encoding > HLL_MAX_ENCODING) goto invalid;
1165
1166 /* Dense representation string length should match exactly. */
1167 if (hdr->encoding == HLL_DENSE &&
1168 stringObjectLen(o) != HLL_DENSE_SIZE) goto invalid;
1169
1170 /* All tests passed. */
1171 return C_OK;
1172
1173invalid:
1174 addReplyError(c,"-WRONGTYPE Key is not a valid "
1175 "HyperLogLog string value.");
1176 return C_ERR;
1177}
1178
1179/* PFADD var ele ele ele ... ele => :0 or :1 */
1180void pfaddCommand(client *c) {

Callers 4

pfaddCommandFunction · 0.85
pfcountCommandFunction · 0.85
pfmergeCommandFunction · 0.85
pfdebugCommandFunction · 0.85

Calls 3

checkTypeFunction · 0.85
stringObjectLenFunction · 0.85
addReplyErrorFunction · 0.85

Tested by

no test coverage detected