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

Function zsetScore

src/t_zset.cpp:1263–1277  ·  view source on GitHub ↗

Return (by reference) the score of the specified member of the sorted set * storing it into *score. If the element does not exist C_ERR is returned * otherwise C_OK is returned and *score is correctly populated. * If 'zobj' or 'member' is NULL, C_ERR is returned. */

Source from the content-addressed store, hash-verified

1261 * otherwise C_OK is returned and *score is correctly populated.
1262 * If 'zobj' or 'member' is NULL, C_ERR is returned. */
1263int zsetScore(robj_roptr zobj, sds member, double *score) {
1264 if (!zobj || !member) return C_ERR;
1265
1266 if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
1267 if (zzlFind((unsigned char*)zobj->m_ptr, member, score) == NULL) return C_ERR;
1268 } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
1269 zset *zs = (zset*)zobj->m_ptr;
1270 dictEntry *de = dictFind(zs->dict, member);
1271 if (de == NULL) return C_ERR;
1272 *score = *(double*)dictGetVal(de);
1273 } else {
1274 serverPanic("Unknown sorted set encoding");
1275 }
1276 return C_OK;
1277}
1278
1279/* Add a new element or update the score of an existing element in a sorted
1280 * set, regardless of its encoding.

Callers 8

longLatFromMemberFunction · 0.85
geohashCommandFunction · 0.85
geoposCommandFunction · 0.85
geodistCommandFunction · 0.85
zscoreCommandFunction · 0.85
zmscoreCommandFunction · 0.85
expireMemberCoreFunction · 0.85
RM_ZsetScoreFunction · 0.85

Calls 2

zzlFindFunction · 0.85
dictFindFunction · 0.70

Tested by

no test coverage detected