Skip to content

Commit

Permalink
[GLUTEN-6900] Use clang-format-18
Browse files Browse the repository at this point in the history
  • Loading branch information
xumingming committed Aug 18, 2024
1 parent 9fcd488 commit 55b86f8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code_style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Run clang-format style check for C/C++
uses: jidicula/[email protected]
with:
clang-format-version: '15'
clang-format-version: '18'
check-path: ${{ matrix.path['check'] }}
fallback-style: 'Google' # optional

Expand Down
2 changes: 1 addition & 1 deletion cpp/core/jni/JniCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class SafeNativeArray {

private:
SafeNativeArray(JNIEnv* env, JavaArrayType javaArray, JniNativeArrayType nativeArray)
: env_(env), javaArray_(javaArray), nativeArray_(nativeArray){};
: env_(env), javaArray_(javaArray), nativeArray_(nativeArray) {};

JNIEnv* env_;
JavaArrayType javaArray_;
Expand Down
2 changes: 1 addition & 1 deletion cpp/core/utils/ObjectStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ObjectStore {

void release0(ResourceHandle handle);

ObjectStore(StoreHandle storeId) : storeId_(storeId){};
ObjectStore(StoreHandle storeId) : storeId_(storeId) {};
StoreHandle storeId_;
ResourceMap<std::shared_ptr<void>> store_;
std::set<ResourceHandle> aliveObjects_;
Expand Down
2 changes: 1 addition & 1 deletion cpp/core/utils/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@
#define TIME_NANO_TO_STRING(time) \
(time > 1e7 ? time / 1e6 : ((time > 1e4) ? time / 1e3 : time)) << (time > 1e7 ? "ms" : (time > 1e4 ? "us" : "ns"))

#define ROUND_TO_LINE(n, round) (((n) + (round)-1) & ~((round)-1))
#define ROUND_TO_LINE(n, round) (((n) + (round) - 1) & ~((round) - 1))
4 changes: 2 additions & 2 deletions cpp/core/utils/qpl/qpl_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HardwareCodecDeflateQpl {
/// RET_ERROR stands for hardware codec fail,need fallback to software codec.
static constexpr int64_t RET_ERROR = -1;

explicit HardwareCodecDeflateQpl(qpl_compression_levels compressionLevel) : compressionLevel_(compressionLevel){};
explicit HardwareCodecDeflateQpl(qpl_compression_levels compressionLevel) : compressionLevel_(compressionLevel) {};

int64_t doCompressData(const uint8_t* source, uint32_t source_size, uint8_t* dest, uint32_t dest_size) const {
uint32_t job_id;
Expand Down Expand Up @@ -99,7 +99,7 @@ class HardwareCodecDeflateQpl {

class SoftwareCodecDeflateQpl final {
public:
explicit SoftwareCodecDeflateQpl(qpl_compression_levels compressionLevel) : compressionLevel_(compressionLevel){};
explicit SoftwareCodecDeflateQpl(qpl_compression_levels compressionLevel) : compressionLevel_(compressionLevel) {};

~SoftwareCodecDeflateQpl() {
if (swJob) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/velox/operators/plannodes/RowVectorStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ValueStreamNode final : public facebook::velox::core::PlanNode {
}

private:
void addDetails(std::stringstream& stream) const override{};
void addDetails(std::stringstream& stream) const override {};

const facebook::velox::RowTypePtr outputType_;
std::unique_ptr<RowVectorStream> valueStream_;
Expand Down
6 changes: 1 addition & 5 deletions cpp/velox/tests/VeloxShuffleWriterTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,7 @@ TEST_P(HashPartitioningShuffleWriter, hashPart1Vector) {
makeFlatVector<int32_t>(
4, [](vector_size_t row) { return row % 2; }, nullEvery(5), DATE()),
makeFlatVector<Timestamp>(
4,
[](vector_size_t row) {
return Timestamp{row % 2, 0};
},
nullEvery(5)),
4, [](vector_size_t row) { return Timestamp{row % 2, 0}; }, nullEvery(5)),
});

auto rowType = facebook::velox::asRowType(vector->type());
Expand Down
30 changes: 21 additions & 9 deletions dev/formatcppcode.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
cd `dirname $0`

# Check if clang-format-15 is installed
if ! command -v clang-format-15 &> /dev/null
then
echo "clang-format-15 could not be found"
echo "Installing clang-format-15..."
sudo apt update
sudo apt install clang-format-15
CLANG_FORMAT_CMD=""
if [ "$(uname)" == "Darwin" ]; then
CLANG_FORMAT_CMD="clang-format"
if ! command -v $CLANG_FORMAT_CMD &> /dev/null
then
echo "$CLANG_FORMAT_CMD could not be found"
echo "Installing $CLANG_FORMAT_CMD..."
sudo brew install $CLANG_FORMAT_CMD
fi
else
CLANG_FORMAT_CMD="clang-format-18"
if ! command -v $CLANG_FORMAT_CMD &> /dev/null
then
echo "$CLANG_FORMAT_CMD could not be found"
echo "Installing $CLANG_FORMAT_CMD..."
sudo apt update
sudo apt install $CLANG_FORMAT_CMD
fi
fi

find ../cpp/core -regex '.*\.\(cc\|hpp\|cu\|c\|h\)' -exec clang-format-15 -style=file -i {} \;
find ../cpp/velox -regex '.*\.\(cc\|hpp\|cu\|c\|h\)' -exec clang-format-15 -style=file -i {} \;
echo "OS: $(uname), CLANG_FORMAT_CMD: ${CLANG_FORMAT_CMD}"
find ../cpp/core -type f \( -name "*.cc" -o -name "*.hpp" -o -name "*.cu" -o -name "*.c" -o -name "*.h" \) | xargs ${CLANG_FORMAT_CMD} -style=file -i
find ../cpp/velox -type f \( -name "*.cc" -o -name "*.hpp" -o -name "*.cu" -o -name "*.c" -o -name "*.h" \) | xargs ${CLANG_FORMAT_CMD} -style=file -i

0 comments on commit 55b86f8

Please sign in to comment.