You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "jbellis (via GitHub)" <gi...@apache.org> on 2023/07/17 13:49:32 UTC
[GitHub] [cassandra] jbellis commented on a diff in pull request #2495: Fix sai intersection count
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org