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

[PFS-46] Fix directory creation with path range requests #8528

Merged
merged 4 commits into from
Jan 25, 2023

Conversation

brycemcanally
Copy link
Contributor

This PR fixes directory creation when the first file in the directory is the upper bound in a path range request. The source abstraction is responsible for emitting PFS directories / files and supports path range requests. The issue is that a path range is an inclusive, exclusive range, so a directory with its first file as the upper bound would not get generated since the file would not be emitted by the internal index iterators. To ensure that the correct directories are emitted in this case, the path range that is passed to the indexing layer is tweaked to iterate past the upper bound. The source iterator will exit early when the upper bound is reached or passed. This ensures that the correct directories will be emitted within the path range provided to the source. This PR also includes some additional testing for this.

s.fileIndexOpts = append(s.fileIndexOpts, index.WithRange(&index.PathRange{
Lower: sc.pathRange.Lower,
Upper: sc.pathRange.Upper,
Upper: sc.pathRange.Upper + "_",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any value to using "\0" here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't affect the results, but it is probably clearer what is being done if the null byte is used.

s.fileIndexOpts = append(s.fileIndexOpts, index.WithRange(&index.PathRange{
Lower: sc.pathRange.Lower,
Upper: sc.pathRange.Upper,
Upper: sc.pathRange.Upper + "_",
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't explode on invalid paths, I would prefer to add a null byte here. I prefer the guarantee that there is no path between sc.pathRange.Upper and the index.PathRange upper bound. I believe the guarantee here is that there is no currently valid path between them. If we change the allowed character set, this could break.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wouldn't break with an allowable character set change because the upper bound is still used in the source iteration, but using the null byte is probably clearer anyways.

Copy link
Contributor

@brendoncarroll brendoncarroll left a comment

Choose a reason for hiding this comment

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

Small suggestion, up to you. Otherwise good to merge.

@brycemcanally brycemcanally merged commit aba8817 into master Jan 25, 2023
@brycemcanally brycemcanally deleted the fix-directory-creation-path-range branch January 25, 2023 20:34
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.

None yet

3 participants