github-actions[bot] commented on code in PR #67171:
URL: https://github.com/apache/doris/pull/67171#discussion_r3868275460


##########
be/src/storage/segment/segment_iterator.cpp:
##########
@@ -1249,6 +1265,14 @@ Status SegmentIterator::_apply_index_expr() {
                 return st;
             }
         }
+        if (expr_ctx->all_expr_inverted_index_evaluated()) {
+            const auto* result = 
expr_ctx->get_index_context()->get_index_result_for_expr(
+                    expr_ctx->root().get());
+            if (result != nullptr) {

Review Comment:
   **[P2] Skip virtual MATCH projection work once no rows survive**
   
   After this progressive intersection makes `_row_bitmap` empty, 
`_apply_index_expr()` still unconditionally evaluates every 
`_virtual_column_exprs` context below. For a query such as `SELECT msg 
MATCH_PHRASE_PREFIX '...' FROM logs WHERE namespace MATCH 'no-hit'`, the 
projection therefore performs its whole-segment postings/positions lookup even 
though `_output_index_result_column()` immediately returns for a zero selection 
and EOF emits only empty typed columns. Please bypass ordinary virtual-column 
index evaluation once the candidate bitmap is empty, and add an 
evaluation-count case for this projection path. This is distinct from the 
existing ANN thread: it occurs with no ANN expression.



##########
be/src/storage/segment/segment_iterator.cpp:
##########
@@ -1302,6 +1326,20 @@ Status SegmentIterator::_apply_index_expr() {
         _opts.stats->ann_index_range_cache_hits += 
ann_index_stats.range_cache_hits.value();
     }
 
+    if (bitmap_exhausted) {
+        // Zero surviving rows satisfy every remaining conjunct, so the whole
+        // list is consumed -- mirroring the column-predicate short circuit.

Review Comment:
   **[P2] Preserve the valid all-false condition-cache result**
   
   This comment is correct that an empty indexed prefix proves the full 
conjunction empty, but the following `clear()` makes the caller set 
`condition_cache_digest` to `0` solely because the list is empty. For contexts 
`[A, B]` where indexed `A` is empty and `B` is residual or downgraded, EOF then 
skips inserting the already-proven all-false cache entry. Before this change, 
`B` remained, the digest survived, and repeated scans could reuse that sound 
result. Please preserve an explicit full-conjunction-empty/digest state while 
clearing the contexts, and cover an empty indexed prefix followed by a residual 
expression with a cache insertion/hit test.



##########
be/src/storage/segment/segment_iterator.cpp:
##########
@@ -1302,6 +1326,20 @@ Status SegmentIterator::_apply_index_expr() {
         _opts.stats->ann_index_range_cache_hits += 
ann_index_stats.range_cache_hits.value();
     }
 
+    if (bitmap_exhausted) {
+        // Zero surviving rows satisfy every remaining conjunct, so the whole
+        // list is consumed -- mirroring the column-predicate short circuit.
+        // This keeps the "all conditions consumed by the index" contract and
+        // leaves the condition-cache digest valid: an empty result is correct

Review Comment:
   **[P2] Do not enable ANN TopN after clearing an empty residual scan**
   
   This `clear()` also removes the `has_common_expr_push_down` veto used later 
by `_apply_ann_topn_predicate()`. With contexts `[A, B]`, if indexed `A` 
empties `_row_bitmap` and `B` is residual, the old path left `B` and ANN TopN 
fell back before loading the index. Now the list is empty; with both candidate 
thresholds set to `0`, `should_fallback_ann_index_by_small_candidate(0, ...)` 
is false, so the later TopN path can load/cache/search ANN with an empty 
selector. Please carry the proven-empty state into ANN TopN while preserving 
its metric checks, and cover this residual-suffix plus thresholds-disabled 
case. This is a different call path from the existing ANN range-search thread.



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