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

Use cross-platform glob library #1562

Merged
merged 1 commit into from
May 25, 2023

Conversation

benjaminwinger
Copy link
Collaborator

I'll open a larger pull request later with the bulk of the changes required for windows support, but I thought I'd start with a smaller part which can be reviewed independently.

This changes the glob functionality to use https://github.com/p-ranav/glob. It's maintained, and seems to be the best choice out of the cross-platform globbing libraries available (others include this and this, both inactive).
It's probably not as robust as the linux/posix globbing library currently used, and one alternative could be to use this only on windows and use that otherwise, but using the same thing for both is a little simpler and more consistent.

I've included the single header version, using the master version since the latest release is out of date and missing some bugfixes, but I had to revert a commit to fix tilde expansion, which had regressed since the release.

It looks like it supports more or less the same features, with the exception that it does not appear to support username-specific tilde expansion (e.g. ~user -> /home/user). I think that it otherwise matches the posix glob.h (at least, with just the GLOB_TILDE extension. Other extensions like braces aren't supported, but they weren't being used anyway).

@ray6080 ray6080 requested a review from acquamarin May 24, 2023 03:47
@@ -2,6 +2,7 @@

#include "common/exception.h"
#include "common/string_utils.h"
#include <glob/glob.hpp>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since glob.hpp is a third-part library, use "glob/glob.hpp" instead of <>

glob(path.c_str(), GLOB_TILDE, nullptr, &globResult);
for (auto i = 0u; i < globResult.gl_pathc; ++i) {
result.emplace_back(globResult.gl_pathv[i]);
for (auto &resultPath: glob::glob(path)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is better to save the result of glob::glob(path) in a local variable, otherwise, we will call glob::glob(path) in each iteration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not convinced there's a difference. it should just be using an iterator, initialized at the start by the function call.

Godbolt shows the assembly as being almost identical for gcc (the one difference is before the loop starts), and cppinsights (clang) doesn't show any difference in control flow either.

Copy link
Collaborator

@acquamarin acquamarin left a comment

Choose a reason for hiding this comment

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

Remember to fix the CI, and squash all your commits before merge into master.

@codecov
Copy link

codecov bot commented May 25, 2023

Codecov Report

Patch coverage: 88.29% and project coverage change: -0.04 ⚠️

Comparison is base (c08468f) 92.00% compared to head (722f24e) 91.96%.

❗ Current head 722f24e differs from pull request most recent head 83092a5. Consider uploading reports for the commit 83092a5 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1562      +/-   ##
==========================================
- Coverage   92.00%   91.96%   -0.04%     
==========================================
  Files         700      701       +1     
  Lines       25116    25204      +88     
==========================================
+ Hits        23109    23180      +71     
- Misses       2007     2024      +17     
Impacted Files Coverage Δ
src/include/common/file_utils.h 100.00% <ø> (ø)
src/include/common/types/types.h 100.00% <ø> (ø)
src/include/storage/storage_utils.h 100.00% <ø> (ø)
src/include/storage/wal_replayer_utils.h 100.00% <ø> (ø)
...e/in_mem_storage_structure/in_mem_column_chunk.cpp 79.29% <80.81%> (-1.48%) ⬇️
src/common/types/types.cpp 91.47% <97.01%> (+0.39%) ⬆️
src/common/file_utils.cpp 68.57% <100.00%> (-0.45%) ⬇️
src/include/common/string_utils.h 100.00% <100.00%> (ø)
src/include/storage/copier/node_copier.h 93.54% <100.00%> (-0.21%) ⬇️
...e/storage/in_mem_storage_structure/in_mem_column.h 100.00% <100.00%> (ø)
... and 7 more

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@acquamarin acquamarin merged commit 1fb8cb1 into kuzudb:master May 25, 2023
7 checks passed
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

2 participants