anoopj commented on code in PR #3015:
URL: https://github.com/apache/iceberg-rust/pull/3015#discussion_r3844667387
##########
crates/iceberg/src/arrow/caching_delete_file_loader.rs:
##########
@@ -374,16 +383,51 @@ impl CachingDeleteFileLoader {
));
}
- result
- .entry(file_path.to_string())
- .or_default()
- .insert(pos as u64);
+ if run_path != Some(file_path) {
+ if let Some(prev_path) = run_path {
+ Self::merge_delete_positions(&mut result, prev_path,
&run_positions);
+ run_positions.clear();
+ }
+
+ run_path = Some(file_path);
+ }
+
+ run_positions.push(pos as u64);
+ }
+
+ if let Some(prev_path) = run_path {
+ Self::merge_delete_positions(&mut result, prev_path,
&run_positions);
+ run_positions.clear();
}
}
Ok(result)
}
+ /// Marks every position in `positions` as deleted for `file_path`, merging
+ /// into any delete vector already recorded for that file.
+ fn merge_delete_positions(
+ result: &mut HashMap<String, DeleteVector>,
+ file_path: &str,
+ positions: &[u64],
+ ) {
+ // Callers only flush a run after pushing at least one position onto
it.
+ debug_assert!(!positions.is_empty());
+
+ let delete_vector = result.entry(file_path.to_string()).or_default();
+ // A run is a strictly ascending slice in the spec-compliant case,
which
Review Comment:
Good catch, fixed.
--
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]