ringles commented on a change in pull request #6700:
URL: https://github.com/apache/geode/pull/6700#discussion_r671492567



##########
File path: 
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSortedSet.java
##########
@@ -307,6 +308,58 @@ long zcount(SortedSetRangeOptions rangeOptions) {
     return getRange(min, max, withScores, false);
   }
 
+
+  List<byte[]> zrangebyscore(SortedSetRangeOptions rangeOptions, boolean 
withScores) {
+    List<byte[]> result = new ArrayList<>();
+    AbstractOrderedSetEntry minEntry =
+        new DummyOrderedSetEntry(rangeOptions.getMinDouble(), 
rangeOptions.isMinExclusive(), true);
+    int minIndex = scoreSet.indexOf(minEntry);
+    if (minIndex >= scoreSet.size()) {
+      return Collections.emptyList();
+    }
+
+    AbstractOrderedSetEntry maxEntry =
+        new DummyOrderedSetEntry(rangeOptions.getMaxDouble(), 
rangeOptions.isMaxExclusive(), false);
+    int maxIndex = scoreSet.indexOf(maxEntry);
+    if (minIndex == maxIndex) {
+      return Collections.emptyList();
+    }
+
+    // Okay, if we make it this far there's a potential range of things to 
return.
+    int offset = 0;
+    int count = Integer.MAX_VALUE;
+    Iterator<AbstractOrderedSetEntry> entryIterator =
+        scoreSet.getIndexRange(minIndex, maxIndex, false);
+    if (rangeOptions.hasLimit()) {
+      count = rangeOptions.getCount();
+      offset = rangeOptions.getOffset();
+    }

Review comment:
       Short answer: Yes.
   Long answer:  Yes, and we can eliminate another variable, too.




-- 
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]


Reply via email to