dschneider-pivotal commented on a change in pull request #7236:
URL: https://github.com/apache/geode/pull/7236#discussion_r781451512
##########
File path:
geode-for-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSet.java
##########
@@ -110,6 +111,42 @@ private static MemberSet calculateDiff(RegionProvider
regionProvider, List<Redis
return diff;
}
+ public static Set<byte[]> sinter(RegionProvider regionProvider,
List<RedisKey> keys) {
+ List<RedisSet> sets = new ArrayList<>(keys.size());
+ RedisSet smallestSet = NULL_REDIS_SET;
Review comment:
I wonder if this code would be easier to understand if you just did the
following:
```
List<RedisSet> sets = createRedisSetList(keys, regionProvider);
RedisSet smallestSet = findSmallest(sets);
if (smallestSet.scard() == 0) {
return emptySet();
}
```
now create the result with the existing code except as you iterate otherSet
checks to see if "otherSet == smallestSet" and if so skip it.
##########
File path:
geode-for-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSet.java
##########
@@ -110,6 +111,42 @@ private static MemberSet calculateDiff(RegionProvider
regionProvider, List<Redis
return diff;
}
+ public static Set<byte[]> sinter(RegionProvider regionProvider,
List<RedisKey> keys) {
+ List<RedisSet> sets = new ArrayList<>(keys.size());
+ RedisSet smallestSet = NULL_REDIS_SET;
+
+ for (RedisKey key : keys) {
+ RedisSet redisSet = regionProvider.getTypedRedisData(REDIS_SET, key,
true);
+ if (redisSet == NULL_REDIS_SET) {
+ return Collections.emptySet();
+ }
+ if (smallestSet == NULL_REDIS_SET) {
+ smallestSet = redisSet;
Review comment:
This still ends up adding the initial "smallestSet" to "sets". You could
fix this by adding an "else" to this "if".
--
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]