ringles commented on a change in pull request #6715:
URL: https://github.com/apache/geode/pull/6715#discussion_r686266557
##########
File path:
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSortedSet.java
##########
@@ -310,18 +311,66 @@ long zcount(SortedSetRangeOptions rangeOptions) {
return getRange(min, max, withScores, false);
}
+ List<byte[]> zrevrangebyscore(SortedSetRangeOptions rangeOptions, boolean
withScores) {
+ AbstractOrderedSetEntry maxEntry =
+ new DummyOrderedSetEntry(rangeOptions.getStartDouble(),
rangeOptions.isStartExclusive(),
+ false);
+ int maxIndex = scoreSet.indexOf(maxEntry);
+
+ AbstractOrderedSetEntry minEntry =
+ new DummyOrderedSetEntry(rangeOptions.getEndDouble(),
rangeOptions.isEndExclusive(), true);
+ int minIndex = scoreSet.indexOf(minEntry);
+ if (minIndex > getSortedSetSize()) {
+ return Collections.emptyList();
+ }
+
+ if (minIndex == maxIndex) {
+ return Collections.emptyList();
+ }
+
+ // Okay, if we make it this far there's a potential range of things to
return.
+ int count = Integer.MAX_VALUE;
+ if (rangeOptions.hasLimit()) {
+ count = rangeOptions.getCount();
+ maxIndex -= rangeOptions.getOffset();
+ if (maxIndex < 0) {
+ return Collections.emptyList();
+ }
+ }
+
+ int startIndex = maxIndex - 1;
+ int endIndex = Math.min(count, maxIndex - minIndex);
Review comment:
Using addLimitToRange() now (with some tweaks to handle reverse ranges).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]