[ 
https://issues.apache.org/jira/browse/CASSANALYTICS-180?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yifan Cai updated CASSANALYTICS-180:
------------------------------------
     Bug Category: Parent values: Code(13163)Level 1 values: Bug - Unclear 
Impact(13164)
       Complexity: Low Hanging Fruit
    Discovered By: Code Inspection
         Severity: Low
           Status: Open  (was: Triage Needed)

> TokenPartitioner fails to detect range gap in reader
> -----------------------------------------------------
>
>                 Key: CASSANALYTICS-180
>                 URL: https://issues.apache.org/jira/browse/CASSANALYTICS-180
>             Project: Apache Cassandra Analytics
>          Issue Type: Bug
>          Components: Reader
>            Reporter: Yifan Cai
>            Priority: Normal
>
> Found the minor bug when inspecting the code. The implementation filters out 
> the non-empty ranges wrongly when detecting gaps in the range split. 
> Below is the test to prove the bug.
> It is a minor bug because no correctness is affected; the range split step is 
> mathematically gap-free today. 
> It is still worth fixing because the check itself is broken and won't catch 
> any future regression that reintroduces a coverage gap.
>  
>  
> {code:java}
> @Test
> public void testValidateCompleteRangeCoverageFailsToDetectGap()
> {
>     Partitioner partitioner = Partitioner.Murmur3Partitioner;
>     List<Range<BigInteger>> subRangesWithGap = Arrays.asList(
>     Range.openClosed(partitioner.minToken(), 
> partitioner.minToken().add(BigInteger.ONE)),
>     
> Range.openClosed(partitioner.minToken().add(BigInteger.ONE).add(BigInteger.TEN),
>  partitioner.maxToken()));
>     // leaves (minToken()+1, minToken()+11] uncovered -- a real, non-empty gap
>     RangeSet<BigInteger> missingRangeSet = TreeRangeSet.create();
>     missingRangeSet.add(Range.closed(partitioner.minToken(), 
> partitioner.maxToken()));
>     subRangesWithGap.forEach(missingRangeSet::remove);
>     // This mirrors TokenPartitioner#validateCompleteRangeCoverage exactly
>     List<Range<BigInteger>> missingRanges = 
> missingRangeSet.asRanges().stream()
>                                                            
> .filter(Range::isEmpty)
>                                                            
> .collect(Collectors.toList());
>     // BUG: missingRanges is empty here even though a real gap exists,
>     // because the filter keeps only degenerate zero-width ranges instead of 
> dropping them.
>     assertThat(missingRanges).isEmpty(); // passes -- but it should have 
> caught the gap and failed 
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to