xxchan commented on code in PR #982:
URL: https://github.com/apache/iceberg-rust/pull/982#discussion_r2095002353
##########
crates/iceberg/src/delete_file_index.rs:
##########
@@ -199,18 +218,22 @@ pub(crate) struct DeletesForDataFile<'a> {
state: Arc<RwLock<DeleteFileIndexState>>,
data_file: &'a DataFile,
seq_num: Option<i64>,
+ waker_set: Arc<WakerSet>,
}
impl Future for DeletesForDataFile<'_> {
type Output = Result<Vec<FileScanTaskDeleteFile>>;
- fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output>
{
+ fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match self.state.try_read() {
Ok(guard) => match guard.deref() {
DeleteFileIndexState::Populated(idx) => Poll::Ready(Ok(
idx.get_deletes_for_data_file(self.data_file, self.seq_num)
)),
- _ => Poll::Pending,
+ _ => {
+ self.waker_set.insert(cx);
+ Poll::Pending
+ }
},
Err(err) => Poll::Ready(Err(Error::new(ErrorKind::Unexpected,
err.to_string()))),
}
Review Comment:
> We're essentially waiting on something to be ready before we proceed with
its value which is exactly the intended use case of a Future.
async fn is just a Future, so I think this point doesn't justify the usage
of a manual Future impl.
And actually for "waiting on something to be ready", I think it means we
need a synchronization primitive.
Here the async computation is not "owned" by the future, but we are just
waiting for a notification.
--
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]