Skip to content
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

Do not create extra 0 sized file if last part is bigger than expected. #402

Merged
merged 4 commits into from
May 2, 2024

Conversation

mgautierfr
Copy link
Collaborator

We don't need to open a new file just after we copy out our big part. Yes we will have to open a new file if we have content after but it will be catch correctly by the else two lines above.

But meanwhile, in our big part is the last one, we should not open a new file.

Fix #401

@mgautierfr mgautierfr requested a review from veloman-yunkan May 1, 2024 21:50
Copy link

codecov bot commented May 1, 2024

Codecov Report

Attention: Patch coverage is 0% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 28.35%. Comparing base (9abf37a) to head (3eee552).

Files Patch % Lines
src/zimsplit.cpp 0.00% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #402      +/-   ##
==========================================
+ Coverage   28.30%   28.35%   +0.05%     
==========================================
  Files          26       26              
  Lines        2551     2546       -5     
  Branches     1341     1336       -5     
==========================================
  Hits          722      722              
+ Misses       1342     1337       -5     
  Partials      487      487              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a while to verify that everything is correct. However the logic can be simplified as follows:

        for(auto offset:offsets) {
            auto currentSize = offset-last;
            if (out_size > 0 && out_size+currentSize > partSize) {
                new_file();
            }
            copy_out(currentSize);
            last = offset;
        }

mgautierfr added 4 commits May 2, 2024 18:13
We don't need to open a new file just after we copy out our big part.

Algorithm is simplified (thanks to @veloman-yunkan):
- We better check if current part should be closed at beggining of the loop.
- Copy the data in the (potentially new) current part.
- No (not so) special cases.
@mgautierfr
Copy link
Collaborator Author

Remade the PR, starting by renaming few variables and taking your suggestion.

@mgautierfr mgautierfr requested a review from veloman-yunkan May 2, 2024 16:15
@mgautierfr mgautierfr merged commit 9894a5c into main May 2, 2024
10 of 12 checks passed
@mgautierfr mgautierfr deleted the no_0part branch May 2, 2024 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zimsplit create surnumerous empty chunk
2 participants