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

Function zzlDeleteRangeByLex

src/t_zset.cpp:1121–1146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1119}
1120
1121unsigned char *zzlDeleteRangeByLex(unsigned char *zl, zlexrangespec *range, unsigned long *deleted) {
1122 unsigned char *eptr, *sptr;
1123 unsigned long num = 0;
1124
1125 if (deleted != NULL) *deleted = 0;
1126
1127 eptr = zzlFirstInLexRange(zl,range);
1128 if (eptr == NULL) return zl;
1129
1130 /* When the tail of the ziplist is deleted, eptr will point to the sentinel
1131 * byte and ziplistNext will return NULL. */
1132 while ((sptr = ziplistNext(zl,eptr)) != NULL) {
1133 if (zzlLexValueLteMax(eptr,range)) {
1134 /* Delete both the element and the score. */
1135 zl = ziplistDelete(zl,&eptr);
1136 zl = ziplistDelete(zl,&eptr);
1137 num++;
1138 } else {
1139 /* No longer in range. */
1140 break;
1141 }
1142 }
1143
1144 if (deleted != NULL) *deleted = num;
1145 return zl;
1146}
1147
1148/* Delete all the elements with rank between start and end from the skiplist.
1149 * Start and end are inclusive. Note that start and end need to be 1-based */

Callers 1

zremrangeGenericCommandFunction · 0.85

Calls 4

zzlFirstInLexRangeFunction · 0.85
ziplistNextFunction · 0.85
zzlLexValueLteMaxFunction · 0.85
ziplistDeleteFunction · 0.85

Tested by

no test coverage detected