nonbinaryprogrammer commented on a change in pull request #6296:
URL: https://github.com/apache/geode/pull/6296#discussion_r628551372



##########
File path: 
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSet.java
##########
@@ -243,24 +251,28 @@ private boolean membersRemove(ByteArrayWrapper 
memberToRemove) {
     boolean isRemoved = members.remove(memberToRemove);
     if (isRemoved) {
       sizeInBytes -= PER_MEMBER_OVERHEAD + memberToRemove.length();
+      if (members.isEmpty()) {
+        sizeInBytes = BASE_REDIS_SET_OVERHEAD;
+      }
     }
     return isRemoved;
   }
 
-  private synchronized boolean membersAddAll(AddsDeltaInfo addsDeltaInfo) {
+  private synchronized void membersAddAll(AddsDeltaInfo addsDeltaInfo) {
     ArrayList<ByteArrayWrapper> adds = addsDeltaInfo.getAdds();
     sizeInBytes += adds.stream().mapToInt(a -> a.length() + 
PER_MEMBER_OVERHEAD).sum();
-    return members.addAll(adds);
+    if (members.size() == 1) {
+      sizeInBytes += INTERNAL_HASH_SET_STORAGE_OVERHEAD;
+    }
+    members.addAll(adds);

Review comment:
       you're right. the other place we did this adds the member before doing 
that check, hence the `==1`




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to