airborne12 commented on code in PR #66877:
URL: https://github.com/apache/doris/pull/66877#discussion_r3843802097


##########
be/test/storage/index/snii/snii_index_reader_count_fallback_test.cpp:
##########
@@ -1423,6 +1527,46 @@ TEST_F(SniiIndexReaderCountFallback, 
PublicSingleTermCountFastPathLeavesPrxStats
     verify_query("failed ~1");
 }
 
+TEST_F(SniiIndexReaderCountFallback, 
CountFastPathRejectsDfBeyondDocumentDomain) {
+    CorruptDfLogicalIndex corrupt;
+    assert_ok(build_corrupt_df_logical_index(/*nullable=*/false, &corrupt));
+    QueryExecutionContext execution(/*enable_query_cache=*/false,
+                                    /*count_on_index_fastpath=*/true);
+    InvertedIndexQueryInfo query_info;
+    query_info.term_infos.emplace_back("alpha", 0);
+    const std::vector<std::string> terms {"alpha"};
+    bool handled = false;
+    std::shared_ptr<roaring::Roaring> bitmap;
+
+    const Status status = _index_reader->_try_count_only_fastpath(
+            execution.context, InvertedIndexQueryType::MATCH_PHRASE_QUERY, 
query_info, terms,
+            &handled, &bitmap, &corrupt.reader);
+
+    EXPECT_TRUE(status.is<ErrorCode::INVERTED_INDEX_FILE_CORRUPTED>()) << 
status;
+    EXPECT_FALSE(handled);
+    EXPECT_EQ(bitmap, nullptr);
+}
+
+TEST_F(SniiIndexReaderCountFallback, 
CountFastPathRejectsDfBeyondNonNullDomain) {

Review Comment:
   Confirmed and fixed in d123e3ac64e. You were exactly right that the indexed 
half of the check had no test protecting it: with `kCorruptDf = 100` against 
`doc_count = 10`, `count > stats.doc_count` short-circuits the `||` and the 
second clause is never reached.
   
   The fixture is now parameterized (`CorruptDfSpec { nullable, df, 
stats_doc_count }`) and the nullable case uses the numbers you proposed: `df = 
9`, `doc_count = 10`, `indexed_doc_count = 8`. `9 > 10` is false, so a 
rejection can only come from `df > indexed_doc_count`.
   
   Verified by mutation rather than by inspection — each guard was disabled in 
turn and the suite re-run:
   
   | mutation | red | rest |
   |---|---|---|
   | drop `\|\| count > stats.indexed_doc_count` | 
`CountFastPathRejectsDfBeyondNonNullDomain` | green |
   | disable `stats.doc_count > _rows_of_segment` | 
`CountFastPathRejectsADocumentDomainLargerThanTheSegment` | green |
   | disable the ARRAY guard | 
`CountFastPathDeclinesAnArrayColumnHoldingANullRowInAPosting` | green |
   
   Before this change the first mutation killed nothing, which is the defect 
you reported.



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