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

Function rioWriteHashIteratorCursor

src/aof.cpp:1277–1295  ·  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

1275 *
1276 * The function returns 0 on error, non-zero on success. */
1277static int rioWriteHashIteratorCursor(rio *r, hashTypeIterator *hi, int what) {
1278 if (hi->encoding == OBJ_ENCODING_ZIPLIST) {
1279 unsigned char *vstr = NULL;
1280 unsigned int vlen = UINT_MAX;
1281 long long vll = LLONG_MAX;
1282
1283 hashTypeCurrentFromZiplist(hi, what, &vstr, &vlen, &vll);
1284 if (vstr)
1285 return rioWriteBulkString(r, (char*)vstr, vlen);
1286 else
1287 return rioWriteBulkLongLong(r, vll);
1288 } else if (hi->encoding == OBJ_ENCODING_HT) {
1289 sds value = hashTypeCurrentFromHashTable(hi, what);
1290 return rioWriteBulkString(r, value, sdslen(value));
1291 }
1292
1293 serverPanic("Unknown hash encoding");
1294 return 0;
1295}
1296
1297/* Emit the commands needed to rebuild a hash object.
1298 * 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