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

Function rioWriteHashIteratorCursor

app/redis-6.2.6/src/aof.c:1178–1196  ·  view source on GitHub ↗

Write either the key or the value of the currently selected item of a hash. * The 'hi' argument passes a valid Redis hash iterator. * The 'what' filed specifies if to write a key or a value and can be * either OBJ_HASH_KEY or OBJ_HASH_VALUE. * * The function returns 0 on error, non-zero on success. */

Source from the content-addressed store, hash-verified

1176 *
1177 * The function returns 0 on error, non-zero on success. */
1178static int rioWriteHashIteratorCursor(rio *r, hashTypeIterator *hi, int what) {
1179 if (hi->encoding == OBJ_ENCODING_ZIPLIST) {
1180 unsigned char *vstr = NULL;
1181 unsigned int vlen = UINT_MAX;
1182 long long vll = LLONG_MAX;
1183
1184 hashTypeCurrentFromZiplist(hi, what, &vstr, &vlen, &vll);
1185 if (vstr)
1186 return rioWriteBulkString(r, (char*)vstr, vlen);
1187 else
1188 return rioWriteBulkLongLong(r, vll);
1189 } else if (hi->encoding == OBJ_ENCODING_HT) {
1190 sds value = hashTypeCurrentFromHashTable(hi, what);
1191 return rioWriteBulkString(r, value, sdslen(value));
1192 }
1193
1194 serverPanic("Unknown hash encoding");
1195 return 0;
1196}
1197
1198/* Emit the commands needed to rebuild a hash object.
1199 * The function returns 0 on error, 1 on success. */

Callers 1

rewriteHashObjectFunction · 0.85

Calls 5

rioWriteBulkStringFunction · 0.85
rioWriteBulkLongLongFunction · 0.85
sdslenFunction · 0.85

Tested by

no test coverage detected