jdeppe-pivotal commented on a change in pull request #6861:
URL: https://github.com/apache/geode/pull/6861#discussion_r715895087
##########
File path:
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSortedSet.java
##########
@@ -288,6 +288,49 @@ long zcount(SortedSetScoreRangeOptions rangeOptions) {
return Coder.doubleToBytes(score);
}
+ long zinterstore(RegionProvider regionProvider, RedisKey key,
List<ZKeyWeight> keyWeights,
+ ZAggregator aggregator) {
+ List<RedisSortedSet> sets = new ArrayList<>(keyWeights.size());
+ for (ZKeyWeight keyWeight : keyWeights) {
+ RedisSortedSet set =
+ regionProvider.getTypedRedisData(REDIS_SORTED_SET,
keyWeight.getKey(), false);
+
+ if (set == NULL_REDIS_SORTED_SET) {
+ continue;
+ }
+
+ double weight = keyWeight.getWeight();
+ RedisSortedSet weightedSet = new RedisSortedSet(Collections.emptyList(),
new double[] {});
+
+ for (AbstractOrderedSetEntry entry : set.members.values()) {
Review comment:
Sorry for the late comments and also if this has already been discussed,
but it seems like we're potentially doing a lot of work here and creating a lot
of allocations for sets that are just going to be tossed away. Would it be
possible to first determine whether a member is intersecting and then perform
any aggregation/weighting? Essentially what is already happening in
`getIntersection` but include the weighting there instead of this loop. I like
how that method is picking the smallest set to iterate over as the base.
--
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]