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

Function zzlIsInLexRange

src/t_zset.cpp:930–949  ·  view source on GitHub ↗

Returns if there is a part of the zset is in range. Should only be used * internally by zzlFirstInRange and zzlLastInRange. */

Source from the content-addressed store, hash-verified

928/* Returns if there is a part of the zset is in range. Should only be used
929 * internally by zzlFirstInRange and zzlLastInRange. */
930int zzlIsInLexRange(unsigned char *zl, zlexrangespec *range) {
931 unsigned char *p;
932
933 /* Test for ranges that will always be empty. */
934 int cmp = sdscmplex(range->min,range->max);
935 if (cmp > 0 || (cmp == 0 && (range->minex || range->maxex)))
936 return 0;
937
938 p = ziplistIndex(zl,-2); /* Last element. */
939 if (p == NULL) return 0;
940 if (!zzlLexValueGteMin(p,range))
941 return 0;
942
943 p = ziplistIndex(zl,0); /* First element. */
944 serverAssert(p != NULL);
945 if (!zzlLexValueLteMax(p,range))
946 return 0;
947
948 return 1;
949}
950
951/* Find pointer to the first element contained in the specified lex range.
952 * Returns NULL when no element is contained in the range. */

Callers 2

zzlFirstInLexRangeFunction · 0.85
zzlLastInLexRangeFunction · 0.85

Calls 4

sdscmplexFunction · 0.85
ziplistIndexFunction · 0.85
zzlLexValueGteMinFunction · 0.85
zzlLexValueLteMaxFunction · 0.85

Tested by

no test coverage detected