pub(crate) fn recompress_file(path: &Path, dry_run: bool) -> Result<Outcome>Expand description
Rewrites one file in the current format after verifying the copy.
Steps, in order:
- If the file has no row groups, return
Outcome::Empty. If it is already current, returnOutcome::AlreadyCurrent. Neither touches the file. - Read all rows and metadata into memory.
- Write them to
<path>.recompress-tmpwithwrite_archive(which syncs it). - Reopen the copy, check it is in the current format, and compare it with the
original using
verify_identical. - In a dry run, delete the copy. Otherwise rename it over the original and sync the parent directory so the rename is durable.
If any step from 3 to 4 fails, the temporary copy is deleted (best effort) and the original is left as it was.
§Arguments
path- Path of a finishedpart-*.parquetfile.dry_run- Whentrue, verify the rewrite but keep the original file.
§Returns
Outcome::Rewritten with the before and after sizes and row count (also in a dry
run), Outcome::AlreadyCurrent or Outcome::Empty.
§Errors
Returns an error if the file cannot be opened or read, if writing or verifying the copy fails, or if deleting the copy (dry run), renaming it or syncing the directory fails.