Creates a new [`ExpressionCache`] and reconciles all entries in current build version. Reconciliation will remove all entries that are not in `current_ids` and remove all entries that have optimizer features that are not equal to `optimizer_features`. If `remove_prior_versions` is `true`, then all previous versions are durably removed from the cache. If `compact_shard` is `true`, then this funct
(
ExpressionCacheConfig {
build_version,
persist,
shard_id,
current_ids,
remove_prior_versions,
compact_shard,
| 154 | /// |
| 155 | /// Returns all cached expressions in the current build version, after reconciliation. |
| 156 | pub async fn open( |
| 157 | ExpressionCacheConfig { |
| 158 | build_version, |
| 159 | persist, |
| 160 | shard_id, |
| 161 | current_ids, |
| 162 | remove_prior_versions, |
| 163 | compact_shard, |
| 164 | dyncfgs, |
| 165 | }: ExpressionCacheConfig, |
| 166 | ) -> ( |
| 167 | Self, |
| 168 | BTreeMap<GlobalId, LocalExpressions>, |
| 169 | BTreeMap<GlobalId, GlobalExpressions>, |
| 170 | ) { |
| 171 | let durable_cache = DurableCache::new(&persist, shard_id, "expressions").await; |
| 172 | let mut cache = Self { |
| 173 | build_version, |
| 174 | durable_cache, |
| 175 | }; |
| 176 | |
| 177 | const RETRIES: usize = 100; |
| 178 | for _ in 0..RETRIES { |
| 179 | match cache |
| 180 | .try_open(¤t_ids, remove_prior_versions, compact_shard, &dyncfgs) |
| 181 | .await |
| 182 | { |
| 183 | Ok((local_expressions, global_expressions)) => { |
| 184 | return (cache, local_expressions, global_expressions); |
| 185 | } |
| 186 | Err(err) => debug!("failed to open cache: {err} ... retrying"), |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | panic!("Unable to open expression cache after {RETRIES} retries"); |
| 191 | } |
| 192 | |
| 193 | async fn try_open( |
| 194 | &mut self, |