-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use NamedTempFile rather than String
in DiskManager
#1680
Conversation
cc @yjshen |
path.push(file_name); | ||
path.to_str().unwrap().to_string() | ||
} | ||
fn create_tmp_file(local_dirs: &[TempDir]) -> Result<NamedTempFile> { |
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.
tempfiles are now generated using tempfile
rather than string manipulation
@@ -301,17 +306,16 @@ async fn spill_partial_sorted_stream( | |||
} | |||
|
|||
fn read_spill_as_stream( | |||
path: String, | |||
path: NamedTempFile, |
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.
Since ownership of NamedTempFile
is passed into the actual task doing the reading, when it is done, the temp file is cleaned up 🧹
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.
nice work and great explanation
LGTM
Which issue does this PR close?
Closes #1679
Rationale for this change
String
for temporary files leaves the files around longer than necessary, and would cause trouble with a long lived DiskManager across plans.tempfile
crate in rust is likely to work better across operating systems than DataFusion specific tempfile creation logicWhat changes are included in this PR?
DiskManager
passes outNamedTempFile
s rather thanString
(when these are dropped they also clean up the temp file immediately)Are there any user-facing changes?
No