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
26 changes: 8 additions & 18 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,16 @@ include(ExternalProject)
include(cugraph)

# Install testing dependencies (gtest)
set(GTEST_ROOT ${PROJECT_BINARY_DIR}/gtest)
ExternalProject_Add(gtest-proj
PREFIX ${GTEST_ROOT}
INSTALL_DIR ${GTEST_ROOT}
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.16.0
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
set(GTEST_INCLUDE_DIR ${GTEST_ROOT}/include)
set(GTEST_LIBRARY_PATH ${GTEST_ROOT}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a)
set(GTEST_DEBUG_LIBRARY_PATH ${GTEST_ROOT}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtestd.a)
add_library(mage_gtest STATIC IMPORTED)
set_target_properties(mage_gtest PROPERTIES
IMPORTED_LOCATION "${GTEST_LIBRARY_PATH}"
IMPORTED_LOCATION_DEBUG "${GTEST_DEBUG_LIBRARY_PATH}"
INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
include_directories("${GTEST_INCLUDE_DIR}")
add_dependencies(mage_gtest gtest-proj)
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# Create an alias for consistency with existing code
add_library(mage_gtest ALIAS gtest)

# Add OpenMP compiling option
find_package(OpenMP)
Expand Down
14 changes: 6 additions & 8 deletions cpp/betweenness_centrality_module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,23 @@ endif()
set(betweenness_centrality_online_src
betweenness_centrality_online_module.cpp
algorithm/betweenness_centrality.cpp
algorithm_online/betweenness_centrality_online.cpp
../biconnected_components_module/algorithm/biconnected_components.cpp)
algorithm_online/betweenness_centrality_online.cpp)

add_query_module(betweenness_centrality_online 1 "${betweenness_centrality_online_src}")

# Link external libraries
target_link_libraries(betweenness_centrality_online PRIVATE mg_utility)
target_link_libraries(betweenness_centrality_online PRIVATE mg_utility biconnected_components_algorithm)
target_include_directories(betweenness_centrality_online PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# Module tests
if (NOT MAGE_CUGRAPH_ENABLE)
include(GoogleTest)
set(betweenness_centrality_online_src
set(betweenness_centrality_online_test_src
betweenness_centrality_online_test.cpp
algorithm/betweenness_centrality.cpp
algorithm_online/betweenness_centrality_online.cpp
../biconnected_components_module/algorithm/biconnected_components.cpp)
algorithm_online/betweenness_centrality_online.cpp)

add_executable(betweenness_centrality_online_test "${betweenness_centrality_online_src}")
target_link_libraries(betweenness_centrality_online_test PRIVATE mg_utility mage_gtest)
add_executable(betweenness_centrality_online_test "${betweenness_centrality_online_test_src}")
target_link_libraries(betweenness_centrality_online_test PRIVATE mg_utility mage_gtest biconnected_components_algorithm)
gtest_add_tests(TARGET betweenness_centrality_online_test)
endif()
18 changes: 11 additions & 7 deletions cpp/biconnected_components_module/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
set(biconnected_components_module_src
biconnected_components_module.cpp
# Create a static library for the shared algorithm code
add_library(biconnected_components_algorithm STATIC
algorithm/biconnected_components.cpp)
target_include_directories(biconnected_components_algorithm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(biconnected_components_algorithm PRIVATE mg_utility)

set(biconnected_components_module_src
biconnected_components_module.cpp)

add_query_module(biconnected_components 1 "${biconnected_components_module_src}")

# Link external libraries
target_link_libraries(biconnected_components PRIVATE mg_utility)
target_link_libraries(biconnected_components PRIVATE mg_utility biconnected_components_algorithm)
target_include_directories(biconnected_components PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# Module tests
if (NOT MAGE_CUGRAPH_ENABLE)
include(GoogleTest)
set(biconnected_components_test_src
biconnected_components_test.cpp
algorithm/biconnected_components.cpp)
biconnected_components_test.cpp)

add_executable(biconnected_components_test "${biconnected_components_test_src}")
target_link_libraries(biconnected_components_test PRIVATE mg_utility mage_gtest)
target_link_libraries(biconnected_components_test PRIVATE mg_utility mage_gtest biconnected_components_algorithm)
gtest_add_tests(TARGET biconnected_components_test)
endif()
endif()
25 changes: 15 additions & 10 deletions rust/rsmgp-sys/src/temporal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ impl Date {
}

pub fn to_naive_date(&self) -> NaiveDate {
NaiveDate::from_ymd(self.year(), self.month(), self.day())
NaiveDate::from_ymd_opt(self.year(), self.month(), self.day())
.expect("Invalid date parameters from Memgraph")
}

pub fn mgp_ptr(&self) -> *mut mgp_date {
Expand Down Expand Up @@ -106,12 +107,13 @@ fn create_naive_time(
millisecond: u32,
microsecond: u32,
) -> NaiveTime {
NaiveTime::from_hms_micro(
NaiveTime::from_hms_micro_opt(
hour,
minute,
second,
millisecond * MICROS_PER_MILLIS + microsecond,
)
.expect("Invalid time parameters from Memgraph")
}

fn create_mgp_local_time_parameters(from: &NaiveTime) -> mgp_local_time_parameters {
Expand Down Expand Up @@ -177,7 +179,8 @@ impl LocalTime {
let timestamp = self.timestamp();
let seconds = (timestamp / MICROS_PER_SECOND) as u32;
let micros = (timestamp % MICROS_PER_SECOND) as u32;
NaiveTime::from_num_seconds_from_midnight(seconds, micros * NANOS_PER_MICROS)
NaiveTime::from_num_seconds_from_midnight_opt(seconds, micros * NANOS_PER_MICROS)
.expect("Invalid time parameters from Memgraph")
}

pub fn mgp_ptr(&self) -> *mut mgp_local_time {
Expand Down Expand Up @@ -272,13 +275,15 @@ impl LocalDateTime {
}

pub fn to_naive_date_time(&self) -> NaiveDateTime {
NaiveDate::from_ymd(self.year(), self.month(), self.day()).and_time(create_naive_time(
self.hour(),
self.minute(),
self.second(),
self.millisecond(),
self.microsecond(),
))
NaiveDate::from_ymd_opt(self.year(), self.month(), self.day())
.expect("Invalid date parameters from Memgraph")
.and_time(create_naive_time(
self.hour(),
self.minute(),
self.second(),
self.millisecond(),
self.microsecond(),
))
}

pub fn mgp_ptr(&self) -> *mut mgp_local_date_time {
Expand Down
9 changes: 4 additions & 5 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -191,24 +191,23 @@ def build_and_copy_cpp_modules(args: Dict[str, Any]) -> bool:
os.makedirs(CPP_BUILD_DIRECTORY, exist_ok=True)

# Prepare CMake flags
os.chdir(CPP_BUILD_DIRECTORY)
cmake_args = [".."]
os.chdir(CPP_DIRECTORY)
cmake_args = [".", "-B", CPP_BUILD_DIRECTORY]
if args[Parameter.GPU.value]:
cmake_args.append(f"-D{MAGE_GPU_BUILD}")
if args[Parameter.CPP_BUILD_FLAGS.value] is not None:
cmake_args += [f"-D{flag}" for flag in args[Parameter.CPP_BUILD_FLAGS.value]]
else:
cmake_args += [f"-DCMAKE_BUILD_TYPE={BuildType.RELEASE}"]

cmake_command = ["cmake"] + cmake_args
cmake_command = ["cmake"] + cmake_args + ["-GNinja"]

cmake_status = run_command(cmake_command)
if not cmake_status:
logger.error("[Terminal] (1/7) Building C++ modules failed.")
return False

core_count = mp.cpu_count()
make_command = ["make", f"-j{core_count}"]
make_command = ["cmake", "--build", CPP_BUILD_DIRECTORY]

make_status = run_command(make_command)
if not make_status:
Expand Down