HappenLee opened a new pull request, #70514:
URL: https://github.com/apache/doris/pull/70514

   ### Background
   
   Condition cache stores per-segment granule results for scan predicates. 
Later scans with the same digest can skip granules that have no matching rows. 
TopN runtime filters tighten a threshold during execution, so their exclusions 
cannot be stored under a static predicate's cache key.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: None
   PR Type: Enhancement
   
   Problem Summary:
   
   Internal-table scans currently disable condition cache whenever a TopN 
filter source is present, even when a matching static predicate entry already 
exists. Allow those scans to consume the existing cache in read-only mode. 
Carry a write-permission flag through the reader options and guard bitmap 
allocation, survivor collection, and publication with it. Most of this diff 
adds tests for the policy and cache behavior.
   
   ### Details
   
   - **Change map:** 89 production lines changed across 11 files and 268 test 
lines changed across two files; no generated files or documentation changes. 
Production changes select the cache policy, pass one flag through existing 
reader options, and centralize the write guard. Tests cover policy selection 
and real cache lookup/publication behavior.
   - **Before and after:** Internal scans with TopN runtime filters previously 
skipped condition cache entirely. They can now read matching static predicate 
entries; on a miss they scan normally without allocating, collecting, or 
publishing a cache bitmap. External TopN scans retain their existing opt-out.
   - **Configs and defaults:** Reuse the existing condition-cache setting and 
per-scan enable flag. No new settings, cache keys, bitmap formats, or FE/BE 
protocol fields.
   - **Impact on existing users:** Warm static predicate entries can prune 
internal TopN scans. Ordinary scans keep their existing cache population 
behavior, including the guard against publishing after a pushed-down LIMIT 
truncates the scan.
   
   ### Testing
   
   - Passed locally: clang-format 16.0.6 on all changed C++ files, 
build-hygiene checks, and `git diff --check`.
   - Passed locally: compiler diagnostics and the `bugprone-unused-raii` check 
on all five changed production translation units and both test translation 
units, using the generated compilation database. The complete configured 
clang-tidy check set has not been completed.
   - Added eight unit tests covering static digest reuse, cache safety gates, 
external TopN opt-out, read-only misses and hits, unchanged cached bitmaps, 
ordinary scan population, and partial LIMIT scans.
   - Attempted `./run-be-ut.sh -j 48 --run 
--filter='ScanOperatorTest.*:SegmentIteratorConditionCacheTest.*'` on the PR 
base. Full build configuration is blocked by missing `bson-2.0` and 
`mongoc-2.0` headers in this machine's third-party installation. The tests and 
SQL end-to-end regressions have not run on this revision.
   
   ### Notes for Reviewers
   
   The digest is computed before `_process_conjuncts()` injects TopN 
expressions. It therefore remains compatible with entries produced by the 
original predicates. Read-only mode is selected from the plan's TopN source IDs 
before scanners are created, including when the runtime threshold has not 
arrived yet.
   
   ### Release note
   
   Internal-table scans with TopN runtime filters can reuse existing static 
predicate condition-cache entries.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details).
   - Does this need documentation: No.
   - Pre-submission status: Partially verified: full build and test execution 
require the current third-party dependencies.
   
   ### AI Disclosure
   
   - Tool: Codex; the exact model identifier is not exposed in this session.
   - Generated: Implementation, unit tests, and this description.
   - Human review: Not reported in this session; author review is pending.
   


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