-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
HDFS-16174. Refactor TempFile and TempDir in libhdfs++ #3303
Conversation
* Need to implement TempFile and TempDir in cc files for avoiding duplicate compilation of these classes.
* Implemented TempDir class in temp-dir.cc file.
* Creating an object library for test utils to help with modularization.
* Wrapped TempDir and TempFile in a TestUtils namespace.
* Added documentation for the TempDir class.
* Removed template type for it to be deduced automatically.
* Removed sys/stat.h from temp-dir.h as it was redundant.
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@@ -114,105 +111,6 @@ void writeDamagedConfig(const std::string& filename, Args... args) { | |||
out.open(filename); | |||
out << stream.rdbuf(); | |||
} | |||
|
|||
// TempDir: is deleted on destruction | |||
class TempFile { |
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.
Other than reducing the size of this file, is there any benefit of having this? Or this is just a refactor at this point?
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.
As I've mentioned in the corresponding JIRA - https://issues.apache.org/jira/browse/HDFS-16174, header files should contain only the declaration of the class and method signatures. The implementation must be done in the cc files. Otherwise, these classes get recompiled everytime they're #included, leading to longer compilation times. Also, it's not a good C++ practice to combine declaration and implementation in the header file, unless it's a template class or method.
Another thing that I've done in this PR is to make this into a test utility library, so that it's more modular and can be imported anywhere in libhdfs++.
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.
Those are valuable but let's make this a refactor PR to make it more explicit.
@@ -114,105 +111,6 @@ void writeDamagedConfig(const std::string& filename, Args... args) { | |||
out.open(filename); | |||
out << stream.rdbuf(); | |||
} | |||
|
|||
// TempDir: is deleted on destruction | |||
class TempFile { |
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.
Those are valuable but let's make this a refactor PR to make it more explicit.
TempDir in cc files for avoiding
duplicate compilation of these
classes.
TestUtils namespace.
TestUtils and added this as a
target as necessary.