diff --git a/CMakeLists.txt b/CMakeLists.txt index a12a61721..1fddb3cb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,6 +128,9 @@ if (USE_READLINE) endif() endif() +set(Boost_USE_STATIC_LIBS ON) +find_package(Boost REQUIRED COMPONENTS serialization) + set(libs_dir ${CMAKE_SOURCE_DIR}/libs) add_subdirectory(libs EXCLUDE_FROM_ALL) diff --git a/init b/init index d65133386..23a31a1f0 100755 --- a/init +++ b/init @@ -1,10 +1,14 @@ #!/bin/bash -e +# TODO: Consider putting boost library in libs/setup.sh, since the license +# allows source modification and static compilation. Unfortunately, it is quite +# a pain to set up the boost build process. required_pkgs=(git arcanist # source code control cmake clang-3.8 llvm-3.8 pkg-config # build system curl wget # for downloading libs uuid-dev default-jre-headless # required by antlr libreadline-dev # for memgraph console + libboost-serialization-dev python3 python-virtualenv python3-pip # for qa, macro_benchmark and stress tests ) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 0d4dca5d3..59ac57995 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -167,3 +167,6 @@ import_header_library(json ${CMAKE_CURRENT_SOURCE_DIR}) # Setup cereal import_header_library(cereal "${CMAKE_CURRENT_SOURCE_DIR}/cereal/include") +# Make cereal multithreaded by passing -DCEREAL_THREAD_SAFE=1 (note that -D is omitted below). +set_property(TARGET cereal PROPERTY + INTERFACE_COMPILE_DEFINITIONS CEREAL_THREAD_SAFE=1) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f5b7859d8..4028355d4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,7 +54,7 @@ set(memgraph_src_files # memgraph_lib depend on these libraries set(MEMGRAPH_ALL_LIBS stdc++fs Threads::Threads fmt cppitertools cereal - antlr_opencypher_parser_lib dl glog gflags) + antlr_opencypher_parser_lib dl glog gflags Boost::serialization) if (USE_LTALLOC) list(APPEND MEMGRAPH_ALL_LIBS ltalloc) diff --git a/src/database/graph_db_datatypes.hpp b/src/database/graph_db_datatypes.hpp index aadbf6d6d..b53deb3cf 100644 --- a/src/database/graph_db_datatypes.hpp +++ b/src/database/graph_db_datatypes.hpp @@ -2,6 +2,9 @@ #include +#include "boost/serialization/base_object.hpp" +#include "cereal/types/base_class.hpp" + #include "utils/total_ordering.hpp" namespace GraphDbTypes { @@ -33,18 +36,67 @@ class Common : TotalOrdering { private: StorageT storage_{0}; + + friend class boost::serialization::access; + + template + void serialize(TArchive &ar, const unsigned int) { + ar & storage_; + } }; class Label : public Common