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

Adopt the Include-What-You-Use for presto_cpp/main/common/ #24243

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions presto-native-execution/presto_cpp/main/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

add_library(presto_exception Exception.cpp)
add_library(presto_common Counters.cpp Utils.cpp ConfigReader.cpp Configs.cpp)
add_library(presto_exception Exception.cpp Exception.h)

target_link_libraries(presto_exception velox_exception)
set_property(TARGET presto_exception PROPERTY JOB_POOL_LINK
presto_link_job_pool)
add_library(presto_common_Counters Counters.cpp Counters.h)
add_library(presto_common_Utils Utils.cpp Utils.h)
add_library(presto_common_ConfigReader ConfigReader.cpp ConfigReader.h)
add_library(presto_common_Configs Configs.cpp Configs.h)

target_link_libraries(presto_common_ConfigReader velox_common_config velox_exception)

target_link_libraries(presto_common_Configs velox_common_config velox_core velox_exception)

target_link_libraries(presto_common velox_common_config velox_core
velox_exception)
set_property(TARGET presto_common PROPERTY JOB_POOL_LINK presto_link_job_pool)
target_link_libraries(presto_common_Counters velox_common_config)

target_link_libraries(presto_common_Utils velox_common_config)

target_link_libraries(presto_exception velox_exception)

if(PRESTO_ENABLE_TESTING)
add_subdirectory(tests)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/

#include "presto_cpp/main/common/ConfigReader.h"
#include <algorithm>
#include <cctype>
#include <fmt/format.h>
#include <fstream>
#include "velox/common/base/Exceptions.h"
Expand Down Expand Up @@ -52,7 +54,7 @@ std::unordered_map<std::string, std::string> readConfig(
std::unordered_map<std::string, std::string> properties;
std::string line;
while (getline(configFile, line)) {
line.erase(std::remove_if(line.begin(), line.end(), isspace), line.end());
line.erase(remove_if(line.begin(), line.end(), isspace), line.end());
if (line.empty() || line[0] == '#') {
continue;
}
Expand Down
9 changes: 4 additions & 5 deletions presto-native-execution/presto_cpp/main/common/Configs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
#include "presto_cpp/main/common/Configs.h"
#include "presto_cpp/main/common/ConfigReader.h"
#include "presto_cpp/main/common/Utils.h"
#include "velox/core/QueryConfig.h"

#include <boost/lexical_cast.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#if __has_include("filesystem")
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
#include <boost/lexical_cast.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include "velox/core/QueryConfig.h"

namespace facebook::presto {

Expand Down
5 changes: 4 additions & 1 deletion presto-native-execution/presto_cpp/main/common/Configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
*/
#pragma once

#include <folly/SocketAddress.h>
#include <cstdint>
#include <memory>
#include <string>
#include <unordered_map>
#include <folly/Optional.h>
#include <folly/SocketAddress.h>
#include "velox/common/base/Exceptions.h"
#include "velox/common/config/Config.h"

namespace facebook::presto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#pragma once

#include <folly/Range.h>
#include <string_view>

// Here we have all the counters presto cpp worker would export.
namespace facebook::presto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
*/
#pragma once

#include <unordered_map>
#include "presto_cpp/presto_protocol/core/presto_protocol_core.h"
#include <exception>
#include <unordered_map>
#include "velox/common/base/VeloxException.h"

namespace std {
Expand Down
2 changes: 1 addition & 1 deletion presto-native-execution/presto_cpp/main/common/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/

#include "presto_cpp/main/common/Utils.h"
#include <fmt/format.h>
#include <sys/resource.h>
#include <fmt/format.h>
#include "velox/common/process/ThreadDebugInfo.h"

namespace facebook::presto::util {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include "presto_cpp/main/common/Configs.h"
#include <gtest/gtest.h>
#include "velox/common/base/Exceptions.h"
#include "velox/common/file/File.h"
#include "velox/common/file/FileSystems.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,41 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
add_executable(presto_common_test CommonTest.cpp ConfigTest.cpp
BaseVeloxQueryConfigTest.cpp)

add_test(presto_common_test presto_common_test)
add_executable(presto_common_BaseVeloxQueryConfigTest BaseVeloxQueryConfigTest.cpp)
add_executable(presto_common_CommonTest CommonTest.cpp)
add_executable(presto_common_ConfigTest ConfigTest.cpp)

add_test(presto_common_BaseVeloxQueryConfigTest presto_common_BaseVeloxQueryConfigTest)
add_test(presto_common_CommonTest presto_common_CommonTest)
add_test(presto_common_ConfigTest presto_common_ConfigTest)

target_link_libraries(
presto_common_CommonTest
presto_common_Utils
presto_exception
${RE2}
velox_exception
GTest::gtest
GTest::gtest_main)

target_link_libraries(
presto_common_test
presto_common
presto_exception
velox_exception
velox_file
${RE2}
GTest::gtest
GTest::gtest_main)
presto_common_ConfigTest
presto_common_ConfigReader
presto_common_Configs
${RE2}
velox_exception
velox_file
GTest::gtest
GTest::gtest_main)

set_property(TARGET presto_common_test PROPERTY JOB_POOL_LINK
presto_link_job_pool)
target_link_libraries(
presto_common_BaseVeloxQueryConfigTest
presto_common_ConfigReader
presto_common_Configs
${RE2}
Copy link
Contributor

Choose a reason for hiding this comment

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

can be removed?

velox_core
velox_exception
velox_file
GTest::gtest
GTest::gtest_main)
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include "presto_cpp/main/common/Exception.h"
#include "presto_cpp/main/common/Utils.h"
#include <gtest/gtest.h>
#include "velox/common/base/Exceptions.h"

using namespace facebook::velox;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include "presto_cpp/main/common/ConfigReader.h"
#include "presto_cpp/main/common/Configs.h"
#include <gtest/gtest.h>
#include "velox/common/base/Exceptions.h"
#include "velox/common/base/tests/GTestUtils.h"
#include "velox/common/file/File.h"
Expand Down
Loading