Skip to content
Merged
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
37 changes: 7 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,38 +87,15 @@ jobs:
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_BENCHMARKS=ON -DCMAKE_CXX_FLAGS="--coverage" -DCMAKE_C_FLAGS="--coverage"

- name: Cpp Format and lint
working-directory: "cpp/build"
- name: clang-format
run: |
# install clang-format
sudo curl -L https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-22538c65/clang-format-8_linux-amd64 --output /usr/bin/clang-format
sudo chmod +x /usr/bin/clang-format

# validate format
function prepend() { while read line; do echo "${1}${line}"; done; }

make graphar-clformat
GIT_DIFF=$(git diff --ignore-submodules)
if [[ -n $GIT_DIFF ]]; then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "| clang-format failures found!"
echo "|"
echo "$GIT_DIFF" | prepend "| "
echo "|"
echo "| Run: "
echo "|"
echo "| make graphar-clformat"
echo "|"
echo "| to fix this error."
echo "|"
echo "| Ensure you are working with clang-format-8, which can be obtained from"
echo "|"
echo "| https://github.com/muttleyxd/clang-tools-static-binaries/releases"
echo "|"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit -1
fi
pip install pre-commit
pre-commit install
pre-commit run clang-format -a

- name: cpplint
working-directory: "cpp/build"
run: |
function ec() { [[ "$1" == "-h" ]] && { shift && eval $* > /dev/null 2>&1; ec=$?; echo $ec; } || eval $*; ec=$?; }

ec make graphar-cpplint
Expand Down
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ repos:
rev: v21.1.2
hooks:
- id: clang-format
files: ^python/
files: \.(cc|cpp|h|hpp)$
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The clang-format hook now matches all C++ extensions repo-wide, which also pulls in vendored code under cpp/thirdparty (this repo appears to intentionally exclude thirdparty from tooling, e.g., the CMake graphar-clformat target and codecov ignore list). Consider excluding cpp/thirdparty (and any other vendored/generated trees) via the hook's exclude: or by tightening the files: regex, so formatting enforcement stays focused on maintained sources.

Suggested change
files: \.(cc|cpp|h|hpp)$
files: ^cpp/.*\.(cc|cpp|h|hpp)$
exclude: ^cpp/thirdparty/

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to exclude the thirdparty.

types_or: [c++]
args: [--style=file, --verbose]

exclude: ^cpp/thirdparty/

- repo: local
hooks:
- id: spotless-java-info
Expand Down
13 changes: 6 additions & 7 deletions cpp/src/graphar/filesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ Result<T> FileSystem::ReadFileToValue(const std::string& path) const noexcept {
}

template <>
Result<std::string> FileSystem::ReadFileToValue(const std::string& path) const
noexcept {
Result<std::string> FileSystem::ReadFileToValue(
const std::string& path) const noexcept {
GAR_RETURN_ON_ARROW_ERROR_AND_ASSIGN(auto access_file,
arrow_fs_->OpenInputFile(path));
GAR_RETURN_ON_ARROW_ERROR_AND_ASSIGN(auto bytes, access_file->GetSize());
Expand Down Expand Up @@ -293,8 +293,8 @@ Status FileSystem::WriteTableToFile(
}

Status FileSystem::WriteLabelTableToFile(
const std::shared_ptr<arrow::Table>& table, const std::string& path) const
noexcept {
const std::shared_ptr<arrow::Table>& table,
const std::string& path) const noexcept {
// try to create the directory, oss filesystem may not support this, ignore
ARROW_UNUSED(arrow_fs_->CreateDir(path.substr(0, path.find_last_of("/"))));
GAR_RETURN_ON_ARROW_ERROR_AND_ASSIGN(auto output_stream,
Expand Down Expand Up @@ -397,7 +397,6 @@ Status FinalizeS3() {
template Result<IdType> FileSystem::ReadFileToValue<IdType>(
const std::string&) const noexcept;
/// template specialization for std::string
template Status FileSystem::WriteValueToFile<IdType>(const IdType&,
const std::string&) const
noexcept;
template Status FileSystem::WriteValueToFile<IdType>(
const IdType&, const std::string&) const noexcept;
} // namespace graphar
12 changes: 6 additions & 6 deletions cpp/src/graphar/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class FileSystem {
* @return A Status indicating OK if successful, or an error if unsuccessful.
*/
template <typename T>
Status WriteValueToFile(const T& value, const std::string& path) const
noexcept;
Status WriteValueToFile(const T& value,
const std::string& path) const noexcept;

/**
* @brief Write a table to a file with a specific type.
Expand All @@ -115,10 +115,10 @@ class FileSystem {
* @param options Options for writing the table, such as compression.
* @return A Status indicating OK if successful, or an error if unsuccessful.
*/
Status WriteTableToFile(const std::shared_ptr<arrow::Table>& table,
FileType file_type, const std::string& path,
const std::shared_ptr<WriterOptions>& options) const
noexcept;
Status WriteTableToFile(
const std::shared_ptr<arrow::Table>& table, FileType file_type,
const std::string& path,
const std::shared_ptr<WriterOptions>& options) const noexcept;

/**
* @brief Write a label table to a file with parquet type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* under the License.
*/

#include <jni.h>
#include <new>
#include <iostream>
#include "arrow/api.h"
#include "arrow/c/bridge.h"
#include <iostream>
#include <jni.h>
#include <new>

#ifdef __cplusplus
extern "C" {
Expand All @@ -30,10 +30,16 @@ extern "C" {
// Common Stubs

JNIEXPORT
jlong JNICALL Java_org_apache_graphar_arrow_ArrowTable_1Static_1cxx_10x58c7409_nativeFromArrowArrayAndArrowSchema(JNIEnv*, jclass, jlong rv_base, jlong arg0 /* arrayAddress0 */, jlong arg1 /* schemaAddress1 */) {
auto maybeRecordBatch = arrow::ImportRecordBatch(reinterpret_cast<struct ArrowArray*>(arg0), reinterpret_cast<struct ArrowSchema*>(arg1));
auto table = arrow::Table::FromRecordBatches({maybeRecordBatch.ValueOrDie()});
return reinterpret_cast<jlong>(new((void*)rv_base) arrow::Result<std::shared_ptr<arrow::Table>>(table));
jlong JNICALL
Java_org_apache_graphar_arrow_ArrowTable_1Static_1cxx_10x58c7409_nativeFromArrowArrayAndArrowSchema(
JNIEnv *, jclass, jlong rv_base, jlong arg0 /* arrayAddress0 */,
jlong arg1 /* schemaAddress1 */) {
auto maybeRecordBatch =
arrow::ImportRecordBatch(reinterpret_cast<struct ArrowArray *>(arg0),
reinterpret_cast<struct ArrowSchema *>(arg1));
auto table = arrow::Table::FromRecordBatches({maybeRecordBatch.ValueOrDie()});
return reinterpret_cast<jlong>(new (
(void *)rv_base) arrow::Result<std::shared_ptr<arrow::Table>>(table));
}

#ifdef __cplusplus
Expand Down
Loading
Loading