You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@orc.apache.org by "ffacs (via GitHub)" <gi...@apache.org> on 2024/04/11 16:27:28 UTC
[PR] ORC-1687: [C++] Enforce naming style. [orc]
ffacs opened a new pull request, #1888:
URL: https://github.com/apache/orc/pull/1888
### What changes were proposed in this pull request?
1. Add `make check-format`, `make check-clang-tidy`,`make format` and `make fix-clang-tidy`
2. Add a github action that runs check-clang-tidy
3. Fix naming style errors in `c++/src/OrcHdfsFile.cc`
### Why are the changes needed?
To enforce identifiers' naming style on c++ side.
### How was this patch tested?
UT passed
### Was this patch authored or co-authored using generative AI tooling?
NO
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1687: [C++] Enforce naming style. [orc]
Posted by "ffacs (via GitHub)" <gi...@apache.org>.
ffacs commented on code in PR #1888:
URL: https://github.com/apache/orc/pull/1888#discussion_r1562588735
##########
cmake_modules/CheckFormat.cmake:
##########
@@ -0,0 +1,113 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, 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.
+
+# Needed for linting targets, etc.
+# Use the first Python installation on PATH, not the newest one
+set(Python3_FIND_STRATEGY "LOCATION")
+# On Windows, use registry last, not first
+set(Python3_FIND_REGISTRY "LAST")
+# On macOS, use framework last, not first
+set(Python3_FIND_FRAMEWORK "LAST")
+
+find_package(Python3)
+set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
+
+set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/c++/build-support")
+
+find_program(CLANG_FORMAT_BIN
+ NAMES clang-format clang-format-14
Review Comment:
I make it clang-format-13 only now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1687: [C++] Enforce naming style. [orc]
Posted by "ffacs (via GitHub)" <gi...@apache.org>.
ffacs commented on code in PR #1888:
URL: https://github.com/apache/orc/pull/1888#discussion_r1564124154
##########
c++/build-support/REAMD.md:
##########
@@ -0,0 +1,30 @@
+# Build support
+
+The Python scripts under the folder provide capabilities for formatting code.
+Make sure you've installed `clang-format-13`, `clang-tidy-13` and `clang-apply-replacements-13` and cmake could find them.
Review Comment:
> Why not use a higher version? The latest is 19 already.
https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
It seems that the ubuntu22.04 docker image of GitHub doesn't support clang-19 yet. We are using 13 right now, maybe we could upgrade to 15.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1687: [C++] Enforce naming style. [orc]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #1888:
URL: https://github.com/apache/orc/pull/1888#discussion_r1562214532
##########
c++/build-support/lint_exclusions.txt:
##########
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, 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.
Review Comment:
If there is nothing to exclude, probably remove it at all?
##########
.github/workflows/build_and_test.yml:
##########
@@ -169,19 +169,19 @@ jobs:
formatting-check:
name: "C++ format check"
- runs-on: ubuntu-20.04
- strategy:
- matrix:
- path:
- - 'c++'
- - 'tools'
+ runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
- - name: Run clang-format style check for C++ code
- uses: jidicula/clang-format-action@v4.9.0
- with:
- clang-format-version: '13'
- check-path: ${{ matrix.path }}
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ - name: Run build
+ run: |
+ mkdir build
+ cd build
+ cmake .. -DBUILD_JAVA=OFF -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DSTOP_BUILD_ON_WARNING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=1
+ - name: Check clang-tidy
+ run: make check-clang-tidy
+ - name: check clang-format
Review Comment:
```suggestion
- name: Check clang-format
```
##########
cmake_modules/CheckFormat.cmake:
##########
@@ -0,0 +1,113 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, 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.
+
+# Needed for linting targets, etc.
+# Use the first Python installation on PATH, not the newest one
+set(Python3_FIND_STRATEGY "LOCATION")
+# On Windows, use registry last, not first
+set(Python3_FIND_REGISTRY "LAST")
+# On macOS, use framework last, not first
+set(Python3_FIND_FRAMEWORK "LAST")
+
+find_package(Python3)
+set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
+
+set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/c++/build-support")
+
+find_program(CLANG_FORMAT_BIN
+ NAMES clang-format clang-format-14
+ HINTS ${CLANG_SEARCH_PATH})
+
+find_program(CLANG_TIDY_BIN
+ NAMES clang-tidy clang-tidy-14
+ HINTS ${CLANG_SEARCH_PATH})
+
+find_program(CLANG_APPLY_REPLACEMENTS_BIN
+ NAMES clang-apply-replacements clang-apply-replacements-14
+ HINTS ${CLANG_SEARCH_PATH})
+
+
+if("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND")
+ message(WARNING "Couldn't find clang-format.")
+else()
+ message(STATUS "Found clang-format at ${CLANG_FORMAT_BIN}")
+endif()
+
+if("${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND")
+ message(WARNING "Couldn't find clang-tidy.")
+else()
+ # Output compile_commands.json
+ set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+ message(STATUS "Found clang-tidy at ${CLANG_TIDY_BIN}")
+endif()
+
+if("${CLANG_APPLY_REPLACEMENTS_BIN}" STREQUAL "CLANG_APPLY_REPLACEMENTS_BIN-NOTFOUND")
+ message(WARNING "Couldn't find clang-apply-replacements.")
+else()
+ # Output compile_commands.json
+ set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+ message(STATUS "Found clang-apply-replacements at ${CLANG_APPLY_REPLACEMENTS_BIN}")
+endif()
+
+if(NOT LINT_EXCLUSIONS_FILE)
+ # source files matching a glob from a line in this file
+ # will be excluded from linting (cpplint, clang-tidy, clang-format)
+ set(LINT_EXCLUSIONS_FILE ${BUILD_SUPPORT_DIR}/lint_exclusions.txt)
+endif()
+
+# runs clang-tidy and exits with a non-zero exit code if any errors are found.
+# note that clang-tidy automatically looks for a .clang-tidy file in parent directories
+add_custom_target(check-clang-tidy
Review Comment:
Could you also add a README in the build-support folder to simply describe how to use these commands?
##########
c++/src/OrcHdfsFile.cc:
##########
@@ -42,23 +42,23 @@ namespace orc {
class HdfsFileInputStream : public InputStream {
private:
- std::string filename;
- std::unique_ptr<hdfs::FileHandle> file;
- std::unique_ptr<hdfs::FileSystem> file_system;
- uint64_t totalLength;
- const uint64_t READ_SIZE = 1024 * 1024; // 1 MB
- ReaderMetrics* metrics;
+ std::string filename_;
+ std::unique_ptr<hdfs::FileHandle> file_;
+ std::unique_ptr<hdfs::FileSystem> file_system_;
+ uint64_t totalLength_;
+ const uint64_t READ_SIZE_ = 1024 * 1024; // 1 MB
Review Comment:
This change looks a little bit weird.
##########
c++/src/OrcHdfsFile.cc:
##########
@@ -42,23 +42,23 @@ namespace orc {
class HdfsFileInputStream : public InputStream {
private:
- std::string filename;
- std::unique_ptr<hdfs::FileHandle> file;
- std::unique_ptr<hdfs::FileSystem> file_system;
- uint64_t totalLength;
- const uint64_t READ_SIZE = 1024 * 1024; // 1 MB
- ReaderMetrics* metrics;
+ std::string filename_;
+ std::unique_ptr<hdfs::FileHandle> file_;
+ std::unique_ptr<hdfs::FileSystem> file_system_;
Review Comment:
fileSystem_ ?
##########
cmake_modules/CheckFormat.cmake:
##########
@@ -0,0 +1,113 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, 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.
+
+# Needed for linting targets, etc.
+# Use the first Python installation on PATH, not the newest one
+set(Python3_FIND_STRATEGY "LOCATION")
+# On Windows, use registry last, not first
+set(Python3_FIND_REGISTRY "LAST")
+# On macOS, use framework last, not first
+set(Python3_FIND_FRAMEWORK "LAST")
+
+find_package(Python3)
+set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
+
+set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/c++/build-support")
+
+find_program(CLANG_FORMAT_BIN
+ NAMES clang-format clang-format-14
Review Comment:
why add clang-format and clang-format-14 at the same time?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1687: [C++] Enforce naming style. [orc]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #1888:
URL: https://github.com/apache/orc/pull/1888#issuecomment-2055602372
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1687: [C++] Enforce naming style. [orc]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #1888:
URL: https://github.com/apache/orc/pull/1888#discussion_r1564102897
##########
.github/workflows/build_and_test.yml:
##########
@@ -169,19 +169,20 @@ jobs:
formatting-check:
name: "C++ format check"
- runs-on: ubuntu-20.04
- strategy:
- matrix:
- path:
- - 'c++'
- - 'tools'
+ runs-on: ubuntu-latest
Review Comment:
nit: It would be better to use a fixed version. Otherwise, a breaking upgrade may result in CI failures, e.g. unable to find a specific version of clang tools.
##########
c++/build-support/REAMD.md:
##########
@@ -0,0 +1,30 @@
+# Build support
+
+The Python scripts under the folder provide capabilities for formatting code.
+Make sure you've installed `clang-format-13`, `clang-tidy-13` and `clang-apply-replacements-13` and cmake could find them.
Review Comment:
Why not use a higher version? The latest is 19 already.
##########
CMakeLists.txt:
##########
@@ -15,6 +15,8 @@
# specific language governing permissions and limitations
# under the License.
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # For clang-tidy.
Review Comment:
Is it better to move it to line 36?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1687: [C++] Enforce naming style. [orc]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #1888:
URL: https://github.com/apache/orc/pull/1888#discussion_r1565098528
##########
CMakeLists.txt:
##########
@@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
+
Review Comment:
```suggestion
```
Please remove this blank line.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1687: [C++] Enforce naming style. [orc]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac closed pull request #1888: ORC-1687: [C++] Enforce naming style.
URL: https://github.com/apache/orc/pull/1888
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org