alamb commented on code in PR #24923:
URL: https://github.com/apache/datafusion/pull/24923#discussion_r4000829791


##########
datafusion/execution/src/spill_file.rs:
##########
@@ -38,14 +41,93 @@ pub trait SpillFile: Send + Sync {
 
     /// Opens a writer for appending data to this file.
     fn open_writer(&self) -> Result<Box<dyn SpillWriter>>;
+
+    /// Opens an asynchronous writer for appending data to this file.
+    ///
+    /// The default implementation adapts [`Self::open_writer`] for backwards
+    /// compatibility. Backends with native asynchronous I/O should override
+    /// this method to avoid blocking an async executor.
+    async fn open_async_writer(&self) -> Result<Box<dyn AsyncSpillWriter>> {

Review Comment:
   this makes sense to add a second API here 👍 



##########
datafusion/execution/src/spill_file.rs:
##########
@@ -38,14 +41,93 @@ pub trait SpillFile: Send + Sync {
 
     /// Opens a writer for appending data to this file.
     fn open_writer(&self) -> Result<Box<dyn SpillWriter>>;
+
+    /// Opens an asynchronous writer for appending data to this file.
+    ///
+    /// The default implementation adapts [`Self::open_writer`] for backwards
+    /// compatibility. Backends with native asynchronous I/O should override
+    /// this method to avoid blocking an async executor.
+    async fn open_async_writer(&self) -> Result<Box<dyn AsyncSpillWriter>> {
+        Ok(Box::new(BlockingSpillWriterAdapter {
+            inner: self.open_writer()?,
+        }))
+    }
 }
 
 /// Writer for spill file backends.
-pub trait SpillWriter: std::io::Write + Send {
+pub trait SpillWriter: Write + Send {
     /// Intended for close/sync/commit operations.
     fn finish(&mut self) -> Result<()>;
 }
 
+/// Asynchronous writer for spill file backends.

Review Comment:
   this is a great writeup



-- 
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]

Reply via email to