Look up cached physical tasks for the given SQL. On a hit returns both the cached tasks and the `DescriptorVersionSet` they were built against — the caller feeds the set into `SharedState::acquire_plan_lease_scope` so cache hits and fresh plans share the same lease-acquisition path. Returns `None` if not cached or if any recorded descriptor version has bumped / been dropped. Stale entries are ev
(
&mut self,
sql: &str,
current_version: F,
)
| 97 | /// descriptor version has bumped / been dropped. Stale |
| 98 | /// entries are evicted automatically. |
| 99 | pub fn get<F>( |
| 100 | &mut self, |
| 101 | sql: &str, |
| 102 | current_version: F, |
| 103 | ) -> Option<(Vec<PhysicalTask>, DescriptorVersionSet)> |
| 104 | where |
| 105 | F: Fn(&DescriptorId) -> Option<u64>, |
| 106 | { |
| 107 | let key = hash_sql(sql); |
| 108 | let entry = self.entries.get(&key)?; |
| 109 | if entry.versions.all_fresh(¤t_version) { |
| 110 | return Some((entry.tasks.clone(), entry.versions.clone())); |
| 111 | } |
| 112 | // Stale — evict. |
| 113 | self.entries.remove(&key); |
| 114 | self.order.retain(|k| *k != key); |
| 115 | None |
| 116 | } |
| 117 | |
| 118 | /// Store compiled physical tasks in the cache along with |
| 119 | /// the descriptor version set they were built against. |
no test coverage detected