mbutrovich commented on code in PR #1941:
URL: https://github.com/apache/iceberg-rust/pull/1941#discussion_r2627887426
##########
crates/iceberg/src/arrow/delete_filter.rs:
##########
@@ -82,6 +107,39 @@ impl DeleteFilter {
Some(notifier)
}
+ /// Attempts to mark a positional delete file as "loading".
+ ///
+ /// Returns an action dictating whether the caller should load the file,
+ /// wait for another task to load it, or do nothing.
+ pub(crate) fn try_start_pos_del_load(&self, file_path: &str) ->
PosDelLoadAction {
+ let mut state = self.state.write().unwrap();
+
+ if let Some(state) = state.positional_deletes.get(file_path) {
+ match state {
+ PosDelState::Loaded => return PosDelLoadAction::AlreadyLoaded,
+ PosDelState::Loading(notify) => return
PosDelLoadAction::WaitFor(notify.clone()),
+ }
+ }
+
+ let notifier = Arc::new(Notify::new());
+ state
+ .positional_deletes
+ .insert(file_path.to_string(), PosDelState::Loading(notifier));
+
+ PosDelLoadAction::Load
+ }
+
+ /// Marks a positional delete file as successfully loaded and notifies any
waiting tasks.
+ pub(crate) fn finish_pos_del_load(&self, file_path: &str) {
+ let mut state = self.state.write().unwrap();
+ if let Some(PosDelState::Loading(notify)) = state
+ .positional_deletes
+ .insert(file_path.to_string(), PosDelState::Loaded)
+ {
+ notify.notify_waiters();
Review Comment:
I could use a sanity check, but I think we would be safe to release the
write lock before notifying the waiters, similar to `insert_equality_delete`
now:
https://github.com/apache/iceberg-rust/blob/d4c4bd4ad3375ef012a5e943498e588bf808d14a/crates/iceberg/src/arrow/delete_filter.rs#L190.
Conceptually that would be something like:
```rust
pub(crate) fn finish_pos_del_load(&self, file_path: &str) {
let notify = {
let mut state = self.state.write().unwrap();
if let Some(PosDelState::Loading(notify)) = state
.positional_deletes
.insert(file_path.to_string(), PosDelState::Loaded)
{
Some(notify)
} else {
None
}
}; // Lock released here
if let Some(notify) = notify {
notify.notify_waiters();
}
}
```
I could use another set of eyes to confirm though. This is also
theoretically just a performance optimization, not a correctness issue.
--
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]