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

Function zzlIsInRange

src/t_zset.cpp:829–851  ·  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

827/* Returns if there is a part of the zset is in range. Should only be used
828 * internally by zzlFirstInRange and zzlLastInRange. */
829int zzlIsInRange(unsigned char *zl, zrangespec *range) {
830 unsigned char *p;
831 double score;
832
833 /* Test for ranges that will always be empty. */
834 if (range->min > range->max ||
835 (range->min == range->max && (range->minex || range->maxex)))
836 return 0;
837
838 p = ziplistIndex(zl,-1); /* Last score. */
839 if (p == NULL) return 0; /* Empty sorted set */
840 score = zzlGetScore(p);
841 if (!zslValueGteMin(score,range))
842 return 0;
843
844 p = ziplistIndex(zl,1); /* First score. */
845 serverAssert(p != NULL);
846 score = zzlGetScore(p);
847 if (!zslValueLteMax(score,range))
848 return 0;
849
850 return 1;
851}
852
853/* Find pointer to the first element contained in the specified range.
854 * Returns NULL when no element is contained in the range. */

Callers 2

zzlFirstInRangeFunction · 0.85
zzlLastInRangeFunction · 0.85

Calls 4

ziplistIndexFunction · 0.85
zzlGetScoreFunction · 0.85
zslValueGteMinFunction · 0.85
zslValueLteMaxFunction · 0.85

Tested by

no test coverage detected