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
32 changes: 26 additions & 6 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ if(MSVC)
# Avoid GCC/Clang-specific flags on MSVC.
# C++17 is already enforced via CMAKE_CXX_STANDARD/target features.
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror=unused-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wno-unused-parameter -Wno-empty-body")
endif()

if (APPLE)
Expand Down Expand Up @@ -191,7 +191,7 @@ endmacro()

macro(install_graphar_target target)
# install
install(TARGETS ${target}
install(TARGETS ${target} graphar_thirdparty
EXPORT graphar-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
Expand Down Expand Up @@ -288,8 +288,19 @@ function(graphar_create_merged_static_lib output_target)
add_dependencies(${output_target} ${output_target}_merge)
endfunction()

macro(build_graphar_thirdparty)
file(GLOB_RECURSE THIRDPARTY_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/mini-yaml/yaml/*.cpp)
add_library(graphar_thirdparty STATIC ${THIRDPARTY_SRC_FILES})
target_include_directories(graphar_thirdparty PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty)
target_compile_features(graphar_thirdparty PRIVATE cxx_std_17)
if(NOT MSVC)
target_compile_options(graphar_thirdparty PRIVATE -fPIC -w)
endif()
endmacro()

macro(build_graphar)
file(GLOB_RECURSE CORE_SRC_FILES "src/graphar/*.cc" ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/mini-yaml/yaml/*.cpp)
build_graphar_thirdparty()
file(GLOB_RECURSE CORE_SRC_FILES "src/graphar/*.cc")
if(GRAPHAR_BUILD_STATIC)
add_library(graphar STATIC ${CORE_SRC_FILES})
else()
Expand All @@ -298,7 +309,11 @@ macro(build_graphar)
install_graphar_target(graphar)
target_compile_features(graphar PRIVATE cxx_std_${GAR_CXX_STANDARD})
target_include_directories(graphar PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty)
target_link_libraries(graphar PRIVATE ${CMAKE_DL_LIBS})
if(GRAPHAR_BUILD_STATIC)
target_link_libraries(graphar PUBLIC graphar_thirdparty ${CMAKE_DL_LIBS})
else()
target_link_libraries(graphar PRIVATE graphar_thirdparty ${CMAKE_DL_LIBS})
endif()

if(APPLE)
if(USE_STATIC_ARROW)
Expand Down Expand Up @@ -346,7 +361,8 @@ macro(build_graphar)
endmacro()

macro(build_graphar_with_arrow_bundled)
file(GLOB_RECURSE CORE_SRC_FILES "src/graphar/*.cc" ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/mini-yaml/yaml/*.cpp)
build_graphar_thirdparty()
file(GLOB_RECURSE CORE_SRC_FILES "src/graphar/*.cc")
if(GRAPHAR_BUILD_STATIC)
add_library(graphar STATIC ${CORE_SRC_FILES})
else()
Expand All @@ -356,7 +372,11 @@ macro(build_graphar_with_arrow_bundled)
target_compile_features(graphar PRIVATE cxx_std_${GAR_CXX_STANDARD})
target_include_directories(graphar PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty)
target_include_directories(graphar SYSTEM BEFORE PRIVATE ${GAR_ARROW_INCLUDE_DIR})
target_link_libraries(graphar PRIVATE ${CMAKE_DL_LIBS})
if(GRAPHAR_BUILD_STATIC)
target_link_libraries(graphar PUBLIC graphar_thirdparty ${CMAKE_DL_LIBS})
else()
target_link_libraries(graphar PRIVATE graphar_thirdparty ${CMAKE_DL_LIBS})
endif()

set(GAR_BUNDLED_DEPS_STATIC_LIBS)
list(APPEND GAR_BUNDLED_DEPS_STATIC_LIBS
Expand Down
6 changes: 4 additions & 2 deletions cpp/examples/mid_level_reader_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ void vertex_property_chunk_reader(
specific_table = specific_result.value();
std::cout << "rows number of specified vertex properties chunk: "
<< specific_table->num_rows() << std::endl;
ASSERT(specific_table->num_columns() == specific_cols.size() + 1);
ASSERT(specific_table->num_columns() ==
static_cast<int>(specific_cols.size()) + 1);
std::cout << "schema of specified vertex properties chunk: " << std::endl
<< specific_table->schema()->ToString() << std::endl;
index_col =
Expand Down Expand Up @@ -159,7 +160,8 @@ void vertex_property_chunk_reader(
specific_table = specific_result.value();
std::cout << "rows number of specified vertex properties chunk (V2): "
<< specific_table->num_rows() << std::endl;
ASSERT(specific_table->num_columns() == specific_cols.size() + 1);
ASSERT(specific_table->num_columns() ==
static_cast<int>(specific_cols.size()) + 1);
std::cout << "schema of specified vertex properties chunk (V2): " << std::endl
<< specific_table->schema()->ToString() << std::endl;
index_col =
Expand Down
38 changes: 38 additions & 0 deletions cpp/src/graphar/arrow/chunk_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,23 @@ AdjListArrowChunkReader::AdjListArrowChunkReader(
base_dir_(other.base_dir_),
fs_(other.fs_) {}

AdjListArrowChunkReader& AdjListArrowChunkReader::operator=(
const AdjListArrowChunkReader& other) {
if (this != &other) {
edge_info_ = other.edge_info_;
adj_list_type_ = other.adj_list_type_;
vertex_chunk_index_ = other.vertex_chunk_index_;
chunk_index_ = other.chunk_index_;
seek_offset_ = other.seek_offset_;
chunk_table_ = nullptr;
vertex_chunk_num_ = other.vertex_chunk_num_;
chunk_num_ = other.chunk_num_;
base_dir_ = other.base_dir_;
fs_ = other.fs_;
Comment on lines +555 to +564
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

AdjListArrowChunkReader::operator=() does not copy prefix_ (but copy-ctor does). After assignment, prefix_ can be stale while base_dir_/fs_ refer to the new object, and methods like seek_src/seek_dst use prefix_ to compute paths, leading to incorrect reads. Copy prefix_ as well (and keep base_dir_ consistent with it).

Copilot uses AI. Check for mistakes.
}
return *this;
}

Status AdjListArrowChunkReader::seek_src(IdType id) {
if (adj_list_type_ != AdjListType::unordered_by_source &&
adj_list_type_ != AdjListType::ordered_by_source) {
Expand Down Expand Up @@ -879,6 +896,27 @@ AdjListPropertyArrowChunkReader::AdjListPropertyArrowChunkReader(
base_dir_(other.base_dir_),
fs_(other.fs_) {}

AdjListPropertyArrowChunkReader& AdjListPropertyArrowChunkReader::operator=(
const AdjListPropertyArrowChunkReader& other) {
if (this != &other) {
edge_info_ = other.edge_info_;
property_group_ = other.property_group_;
adj_list_type_ = other.adj_list_type_;
prefix_ = other.prefix_;
vertex_chunk_index_ = other.vertex_chunk_index_;
chunk_index_ = other.chunk_index_;
seek_offset_ = other.seek_offset_;
schema_ = other.schema_;
chunk_table_ = nullptr;
filter_options_ = other.filter_options_;
vertex_chunk_num_ = other.vertex_chunk_num_;
chunk_num_ = other.chunk_num_;
base_dir_ = other.base_dir_;
fs_ = other.fs_;
}
return *this;
}

Status AdjListPropertyArrowChunkReader::seek_src(IdType id) {
if (adj_list_type_ != AdjListType::unordered_by_source &&
adj_list_type_ != AdjListType::ordered_by_source) {
Expand Down
11 changes: 11 additions & 0 deletions cpp/src/graphar/arrow/chunk_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ class AdjListArrowChunkReader {
*/
AdjListArrowChunkReader(const AdjListArrowChunkReader& other);

/**
* @brief Copy assignment operator.
*/
AdjListArrowChunkReader& operator=(const AdjListArrowChunkReader& other);

/**
* @brief Sets chunk position indicator for reader by source vertex id.
*
Expand Down Expand Up @@ -494,6 +499,12 @@ class AdjListPropertyArrowChunkReader {
*/
AdjListPropertyArrowChunkReader(const AdjListPropertyArrowChunkReader& other);

/**
* @brief Copy assignment operator.
*/
AdjListPropertyArrowChunkReader& operator=(
const AdjListPropertyArrowChunkReader& other);

/**
* @brief Sets chunk position indicator for reader by source vertex id.
*
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/graphar/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ class Status {

template <typename... Args>
static Status FromArgs(StatusCode code, Args... args) {
return Status(code,
std::move(util::StringBuilder(std::forward<Args>(args)...)));
return Status(code, util::StringBuilder(std::forward<Args>(args)...));
}

/** Returns an error status when some IO-related operation failed. */
Expand Down
1 change: 1 addition & 0 deletions rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fn link_libraries() {
.expect("Arrow development files not found via pkg-config. Set PKG_CONFIG_PATH if needed.");

println!("cargo:rustc-link-lib=graphar");
println!("cargo:rustc-link-lib=graphar_thirdparty");
}

fn build_ffi(bridge_file: &str, out_name: &str, source_file: &str, include_paths: &[PathBuf]) {
Expand Down
Loading