-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-6606: [C++] Add PathTree tree structure #5430
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
Conversation
aff3032 to
bbb9f3c
Compare
pitrou
left a comment
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.
The whole design looks a bit complicated. I would expect a simple DirectoryTree. Non-directories need not be tree entries (but if you want a file to point to its DirectoryTree parent, perhaps you can have a simple struct FileTreeEntry { DirectoryTree*, FileStats }).
cpp/src/arrow/filesystem/test_util.h
Outdated
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.
It would be better to give this a less generic name, e.g. StatsForFile.
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.
The goal is to write succinct test. That's why I kept it short.
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.
Instead of computing path depth, you can probably sort by string length...
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.
You can even sort the file stats by string length in a work queue (without distinguishing directories up front) and build up the tree like that. I don't think you need to build directories first explicitly, everything will be done naturally in graph order.
bbb9f3c to
5b77220
Compare
|
I iterated a couple of time over the design. I initially implemented the tree with Directory only node |
|
You could have a |
|
Do you prefer I rewrite it that way? |
|
You mean as a tree of directories? Yes. |
cf9762d to
d609ef7
Compare
|
@pitrou, I'd prefer that we keep it that way for the sake of simplifying consumption, creation and testing. The downside of this version is that the type allow invalid tree as per what is found in a real file system. If the user calls Make(), there can't be any "non-directory" in non-leaves nodes. We could make this class namespace "internal" so users can't call the constructor and build invalid trees. The constructor are useful for simplifying unit tests. Minus this point, the other comments were addressed. |
d609ef7 to
c70e69b
Compare
|
(woops, sorry, wrong PR :-)) |
pitrou
left a comment
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.
Ok, just a couple more questions :-)
|
Comments were addressed and I also added missing test for the Visit facility. |
pitrou
left a comment
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.
+1, thank you!
|
Hmm, this needs to be rebased, sorry. |
Construct tree structure from std::vector<fs::FileStats>, following the path directory hierarchy.
13ebc7d to
43d19fa
Compare
Construct tree structure from std::vectorfs::FileStats, following the path directory hierarchy.