ringles commented on a change in pull request #6700:
URL: https://github.com/apache/geode/pull/6700#discussion_r671357362
##########
File path:
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSortedSet.java
##########
@@ -307,6 +308,57 @@ 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);
+ long minIndex = scoreSet.indexOf(minEntry);
+ if (minIndex >= scoreSet.size()) {
+ return Collections.emptyList();
+ }
+
+ AbstractOrderedSetEntry maxEntry =
+ new DummyOrderedSetEntry(rangeOptions.getMaxDouble(),
rangeOptions.isMaxExclusive(), false);
+ long 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((int) minIndex, (int) maxIndex, false);
+ if (rangeOptions.hasLimit()) {
+ count = rangeOptions.getCount();
+ offset = rangeOptions.getOffset();
+ }
+ int skip = 0;
+ int returnedCount = 0;
+
+ while (entryIterator.hasNext() && returnedCount < count) {
+ AbstractOrderedSetEntry entry = entryIterator.next();
+ if (skip < offset) {
+ skip++;
+ continue;
+ }
Review comment:
Nice; I think I can do that with 'count' as well!
--
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]