Inspect `plan` and return a `BitmapHint` if the plan qualifies for bitmap pushdown, or `None` if the plan should run without a prefilter. Only exact-match shapes on `Ready` indexed columns are considered. Ranges are never emitted (no statistics available to confirm selectivity).
(plan: &SqlPlan)
| 40 | /// Only exact-match shapes on `Ready` indexed columns are considered. |
| 41 | /// Ranges are never emitted (no statistics available to confirm selectivity). |
| 42 | pub fn analyze(plan: &SqlPlan) -> Option<BitmapHint> { |
| 43 | match plan { |
| 44 | // Already a single-field equality index lookup — always qualifies. |
| 45 | SqlPlan::DocumentIndexLookup { |
| 46 | collection, |
| 47 | field, |
| 48 | value, |
| 49 | .. |
| 50 | } => Some(BitmapHint { |
| 51 | collection: collection.clone(), |
| 52 | field: field.clone(), |
| 53 | primary_value: value.clone(), |
| 54 | extra_values: Vec::new(), |
| 55 | }), |
| 56 | |
| 57 | // Plain scan: inspect WHERE filters for indexed-column equality / IN-list. |
| 58 | SqlPlan::Scan { |
| 59 | collection, |
| 60 | filters, |
| 61 | .. |
| 62 | } => { |
| 63 | // The `SqlPlan::Scan` does not directly carry `IndexSpec` list — that |
| 64 | // lives on `TableInfo` which the engine-rules layer consumed when it |
| 65 | // chose *not* to rewrite to `DocumentIndexLookup`. However, when the |
| 66 | // engine rules DID rewrite to `DocumentIndexLookup`, the caller should |
| 67 | // match the first arm above. |
| 68 | // |
| 69 | // For plain `Scan` nodes we can still detect equality/in-list filters |
| 70 | // but we have no way to confirm the column is indexed here — the planner |
| 71 | // already had that information. We conservatively return `None` so we |
| 72 | // never emit a sub-scan that would do a full table scan disguised as a |
| 73 | // bitmap producer. Only the `DocumentIndexLookup` arm (already |
| 74 | // index-backed) is emitted unconditionally. |
| 75 | // |
| 76 | // Future: if `Scan` carries index metadata, extend this arm. |
| 77 | analyze_scan_filters(collection, filters) |
| 78 | } |
| 79 | |
| 80 | _ => None, |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /// Attempt to extract an equality or bounded IN-list hint from scan filters. |
| 85 | /// |
no test coverage detected