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

Function zsetConvertToZiplistIfNeeded

src/t_zset.cpp:1249–1257  ·  view source on GitHub ↗

Convert the sorted set object into a ziplist if it is not already a ziplist * and if the number of elements and the maximum element size and total elements size * are within the expected ranges. */

Source from the content-addressed store, hash-verified

1247 * and if the number of elements and the maximum element size and total elements size
1248 * are within the expected ranges. */
1249void zsetConvertToZiplistIfNeeded(robj *zobj, size_t maxelelen, size_t totelelen) {
1250 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) return;
1251 zset *set = (zset*)zobj->m_ptr;
1252
1253 if (set->zsl->length <= g_pserver->zset_max_ziplist_entries &&
1254 maxelelen <= g_pserver->zset_max_ziplist_value &&
1255 ziplistSafeToAdd(NULL, totelelen))
1256 zsetConvert(zobj,OBJ_ENCODING_ZIPLIST);
1257}
1258
1259/* Return (by reference) the score of the specified member of the sorted set
1260 * storing it into *score. If the element does not exist C_ERR is returned

Callers 2

georadiusGenericFunction · 0.85

Calls 2

ziplistSafeToAddFunction · 0.85
zsetConvertFunction · 0.85

Tested by

no test coverage detected