ringles commented on a change in pull request #6715:
URL: https://github.com/apache/geode/pull/6715#discussion_r679240436
##########
File path:
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSortedSet.java
##########
@@ -310,18 +311,62 @@ long zcount(SortedSetRangeOptions rangeOptions) {
return getRange(min, max, withScores, false);
}
+ List<byte[]> zrevrangebyscore(SortedSetRangeOptions rangeOptions, boolean
withScores) {
+ List<byte[]> result = new ArrayList<>();
+ 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();
+ }
+ }
+ Iterator<AbstractOrderedSetEntry> entryIterator =
+ scoreSet.getIndexRange(maxIndex - 1, Math.min(count, maxIndex -
minIndex), true);
Review comment:
Done, or at least a stab thereto.
--
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]