-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(rust): Introduce Writeable
and AsyncWriteable
#21599
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #21599 +/- ##
==========================================
- Coverage 80.24% 80.15% -0.10%
==========================================
Files 1604 1604
Lines 231329 231401 +72
Branches 2639 2639
==========================================
- Hits 185635 185483 -152
- Misses 45085 45309 +224
Partials 609 609 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
16de202
to
3cb7e64
Compare
crates/polars-io/src/utils/file.rs
Outdated
eprintln!("try_get_writeable: forced async converted path: {}", path) | ||
pub fn close(self) -> PolarsResult<()> { | ||
match self { | ||
// @RAISE_FILE_CLOSE_ERR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left this todo for now // @RAISE_FILE_CLOSE_ERR
(here and 1 place down below)
It can be updated after #21588
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready to rebase. :)
/// | ||
/// Also see: `Writeable::into_async_writeable` and `AsyncWriteable`. | ||
pub enum Writeable { | ||
Local(std::fs::File), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we theoretically (in a follow up PR) add an in-memory buffer to this? This would allow sinks to also output to in-memory buffers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be, we can do it later when we decide to implement sinking to memory
3e23202
to
5dbaf9e
Compare
Ok(()) => {}, | ||
e @ Err(_) => { | ||
if std::thread::panicking() { | ||
eprintln!("ERROR: CloudWriter errored on close: {:?}", e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive-by, just print an error message if already panicking to avoid abort
eprintln!("try_get_writeable: forced async converted path: {}", path) | ||
pub fn close(self) -> std::io::Result<()> { | ||
match self { | ||
Self::Local(v) => ClosableFile::from(v).close(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Local files closed here
match self { | ||
Self::Local(v) => async { | ||
let f = v.into_std().await; | ||
ClosableFile::from(f).close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Local files closed here (AsyncWriteable)
Prepares for cloud support on new-streaming
Also implementsAsyncWrite
onto theCloudWriter
.A
Writeable
can generally be directly used for writing:It can be
Deref
ed if a trait object is needed:(similarly with
AsyncWriteable
)