(
table: &Table,
config: &CompactConfig,
)
| 264 | } |
| 265 | |
| 266 | pub async fn check_opened_table_and_compact( |
| 267 | table: &Table, |
| 268 | config: &CompactConfig, |
| 269 | ) -> CompactResult { |
| 270 | let started = Instant::now(); |
| 271 | let finalize = |action: CompactAction, |
| 272 | small_fragments: usize, |
| 273 | max_unindexed_rows: usize, |
| 274 | compacted: bool, |
| 275 | pruned: bool, |
| 276 | index_optimized: bool, |
| 277 | error: Option<String>| CompactResult { |
| 278 | table: table.name().to_string(), |
| 279 | small_fragments, |
| 280 | max_unindexed_rows, |
| 281 | action, |
| 282 | elapsed_ms: started.elapsed().as_millis(), |
| 283 | compacted, |
| 284 | pruned, |
| 285 | index_optimized, |
| 286 | error, |
| 287 | }; |
| 288 | |
| 289 | if !config.enabled { |
| 290 | return finalize(CompactAction::CompactionDisabled, 0, 0, false, false, false, None); |
| 291 | } |
| 292 | |
| 293 | let small = match count_small_fragments(table).await { |
| 294 | Ok(count) => count, |
| 295 | Err(err) => { |
| 296 | return finalize( |
| 297 | CompactAction::StatsFailed, |
| 298 | 0, |
| 299 | 0, |
| 300 | false, |
| 301 | false, |
| 302 | false, |
| 303 | Some(format!("fragment scan failed: {err}")), |
| 304 | ) |
| 305 | }, |
| 306 | }; |
| 307 | let max_unindexed_rows = match max_unindexed_rows(table).await { |
| 308 | Ok(count) => count, |
| 309 | Err(err) => { |
| 310 | return finalize( |
| 311 | CompactAction::StatsFailed, |
| 312 | small, |
| 313 | 0, |
| 314 | false, |
| 315 | false, |
| 316 | false, |
| 317 | Some(format!("index scan failed: {err}")), |
| 318 | ) |
| 319 | }, |
| 320 | }; |
| 321 | if small < config.fragment_threshold { |
| 322 | // Even when compaction is skipped, old versions should still be pruned |
| 323 | // and lagging indices repaired through the same maintenance entrypoint. |
no test coverage detected