jbellis commented on code in PR #2495:
URL: https://github.com/apache/cassandra/pull/2495#discussion_r1265393094


##########
src/java/org/apache/cassandra/index/sai/iterators/KeyRangeIntersectionIterator.java:
##########
@@ -249,14 +249,24 @@ private void updateStatistics(Statistics statistics, 
KeyRangeIterator range)
 
     private static class IntersectionStatistics extends 
KeyRangeIterator.Builder.Statistics
     {
+        private boolean empty = true;
+
         @Override
         public void update(KeyRangeIterator range)
         {
             // minimum of the intersection is the biggest minimum of 
individual iterators
             min = nullSafeMax(min, range.getMinimum());
             // maximum of the intersection is the smallest maximum of 
individual iterators
             max = nullSafeMin(max, range.getMaximum());
-            count += range.getCount();
+            if (empty)
+            {
+                empty = false;
+                count = range.getCount();
+            }
+            else
+            {
+                count = Math.min(count, range.getCount());
+            }

Review Comment:
   I don't think so.  Consider adding two iterators A and B.  A has count of 0, 
B has count of 1.
   
   If we add A first, then B, then we will end up with a count of 1, since it's 
treating 0 as "uninitialized" which is not correct.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to