nonbinaryprogrammer commented on a change in pull request #6861:
URL: https://github.com/apache/geode/pull/6861#discussion_r714291763
##########
File path:
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSortedSet.java
##########
@@ -578,6 +625,91 @@ private int
getMaxElementsToReturn(AbstractSortedSetRangeOptions<?> rangeOptions
return result;
}
+ private RedisSortedSet getIntersection(List<RedisSortedSet> sets,
ZAggregator aggregator) {
+ RedisSortedSet retVal = new RedisSortedSet(Collections.emptyList());
+
+ for (RedisSortedSet set : sets) {
+ for (OrderedSetEntry entry : set.members.values()) {
+ Double newScore;
+ if (aggregator.equals(ZAggregator.SUM)) {
+ newScore = recursivelySumScoresForMember(sets, entry.member, 0D);
+ } else if (aggregator.equals(ZAggregator.MAX)) {
+ newScore = recursivelyGetMaxScoreForMember(sets, entry.member,
Double.MIN_VALUE);
+ } else {
+ newScore = recursivelyGetMinScoreForMember(sets, entry.member,
Double.MAX_VALUE);
+ }
+
+ if (newScore != null) {
+ if (newScore.isNaN()) {
+ throw new ArithmeticException(ERROR_OPERATION_PRODUCED_NAN);
+ }
+ retVal.memberAdd(entry.getMember(), Coder.doubleToBytes(newScore));
+ }
+ }
+ }
+ return retVal;
+ }
+
+ private Double recursivelySumScoresForMember(List<RedisSortedSet> sets,
byte[] member,
+ Double runningTotal) {
+ if (sets.isEmpty()) {
+ return runningTotal;
+ }
+
+ if (runningTotal.isNaN()) {
+ return runningTotal;
+ }
+
+ if (sets.get(0).members.containsKey(member)) {
Review comment:
I'm not entirely sure what you mean. it's a get followed by a contains,
not the other way around
--
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]