Compare commits

...

5 Commits

Author SHA1 Message Date
Marko Budiselic
76690bf904 Add libc++ flag to gtest 2022-09-25 16:35:41 +02:00
Marko Budiselic
ec03fb0456 Add working version of Memgraph compiled with LLVM stdlib 2022-09-23 16:38:16 +02:00
Jure Bajic
9eb87bcf3e Update release process (#564)
* Fix centos 7 virtualenv issue
* Fix ubuntu release issue
* Fix architecture check
2022-09-20 18:42:15 +02:00
Jure Bajic
a9491d3e68 Update license date (#561) 2022-09-20 14:23:24 +02:00
Marko Budiselić
b42e47b0be Reduce the size of TypedValue (#560)
- Reduce the size of TypedValue
- Fix double allocation
- Add `Graph` to `TypedValue` unit tests
- Fix allocator usage in `TypedValue`
- Add graph projection to `long_running.cpp` stress test
2022-09-20 14:21:34 +02:00
33 changed files with 186 additions and 95 deletions

View File

@@ -184,7 +184,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall \
-Werror=switch -Werror=switch-bool -Werror=return-type \
-Werror=return-stack-address \
-Wno-c99-designator \
-Wno-c99-designator -stdlib=libc++ \
-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT")
# Don't omit frame pointer in RelWithDebInfo, for additional callchain debug.
@@ -197,7 +197,10 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
# Last checked for gcc-10.2 which we are using on the build machines.
# ** If we change versions, recheck this! **
# ** Static linking is allowed only for executables! **
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
# message(STATUS "${CMAKE_CXX_STANDARD_LIBRARIES}")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++experimental")
# Use gold linker to speedup build
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")

View File

@@ -6,7 +6,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "$DIR/../util.sh"
check_operating_system "debian-11"
check_architecture "arm64"
check_architecture "arm64" "aarch64"
TOOLCHAIN_BUILD_DEPS=(
coreutils gcc g++ build-essential make # generic build tools

View File

@@ -1,11 +1,11 @@
#!/bin/bash
operating_system() {
function operating_system() {
grep -E '^(VERSION_)?ID=' /etc/os-release | \
sort | cut -d '=' -f 2- | sed 's/"//g' | paste -s -d '-'
}
check_operating_system() {
function check_operating_system() {
if [ "$(operating_system)" != "$1" ]; then
echo "Not the right operating system!"
exit 1
@@ -14,20 +14,22 @@ check_operating_system() {
fi
}
architecture() {
function architecture() {
uname -m
}
check_architecture() {
if [ "$(architecture)" != "$1" ]; then
echo "Not the right architecture!"
exit 1
else
echo "The right architecture."
fi
for arch in "$@"; do
if [ "$(architecture)" = "$arch" ]; then
echo "The right architecture!"
exit 0
fi
done
echo "Not the right architecture!"
exit 1
}
check_all_yum() {
function check_all_yum() {
local missing=""
for pkg in $1; do
if ! yum list installed "$pkg" >/dev/null 2>/dev/null; then
@@ -40,7 +42,7 @@ check_all_yum() {
fi
}
check_all_dpkg() {
function check_all_dpkg() {
local missing=""
for pkg in $1; do
if ! dpkg -s "$pkg" >/dev/null 2>/dev/null; then
@@ -53,7 +55,7 @@ check_all_dpkg() {
fi
}
check_all_dnf() {
function check_all_dnf() {
local missing=""
for pkg in $1; do
if ! dnf list installed "$pkg" >/dev/null 2>/dev/null; then
@@ -65,7 +67,8 @@ check_all_dnf() {
exit 1
fi
}
install_all_apt() {
function install_all_apt() {
for pkg in $1; do
apt install -y "$pkg"
done

11
init
View File

@@ -5,6 +5,9 @@ cd "$DIR"
source "$DIR/environment/util.sh"
DISTRO=$(operating_system)
ARCHITECTURE=$(architecture)
function print_help () {
echo "Usage: $0 [OPTION]"
echo -e "Check for missing packages and setup the project.\n"
@@ -64,8 +67,6 @@ else
done
fi
DISTRO=$(operating_system)
ARCHITECTURE=$(architecture)
if [ "${ARCHITECTURE}" = "arm64" ] || [ "${ARCHITECTURE}" = "aarch64" ]; then
OS_SCRIPT=$DIR/environment/os/$DISTRO-arm.sh
else
@@ -111,6 +112,12 @@ if [[ "$setup_libs" == "true" ]]; then
cd ..
fi
# Fix for centos 7 during release
if [ "${ARCHITECTURE}" = "centos-7" ]; then
python3 -m pip uninstall virtualenv
python3 -m pip install virtualenv
fi
# setup gql_behave dependencies
setup_virtualenv tests/gql_behave

View File

@@ -103,7 +103,7 @@ import_external_library(antlr4 STATIC
${CMAKE_CURRENT_SOURCE_DIR}/antlr4/runtime/Cpp/include/antlr4-runtime
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/antlr4/runtime/Cpp
CMAKE_ARGS # http://stackoverflow.com/questions/37096062/get-a-basic-c-program-to-compile-using-clang-on-ubuntu-16/38385967#38385967
-DWITH_LIBCXX=OFF # because of debian bug
-DWITH_LIBCXX=ON # because of debian bug
-DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=true
-DCMAKE_CXX_STANDARD=20
-DANTLR_BUILD_CPP_TESTS=OFF
@@ -127,7 +127,9 @@ mark_as_advanced(RC_ENABLE_GTEST RC_ENABLE_GMOCK)
add_subdirectory(rapidcheck EXCLUDE_FROM_ALL)
# setup google test
add_external_project(gtest SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
add_external_project(gtest
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest
CMAKE_ARGS -DCMAKE_CXX_FLAGS="-stdlib=libc++")
set(GTEST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest/include
CACHE PATH "Path to gtest and gmock include directory" FORCE)
set(GMOCK_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/googletest/lib/libgmock.a
@@ -155,6 +157,7 @@ import_external_library(rocksdb STATIC
${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/lib/librocksdb.a
${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/include
CMAKE_ARGS -DUSE_RTTI=ON
-DCMAKE_CXX_FLAGS="-stdlib=libc++"
-DWITH_TESTS=OFF
-DGFLAGS_NOTHREADS=OFF
-DCMAKE_INSTALL_LIBDIR=lib
@@ -207,6 +210,7 @@ import_external_library(librdkafka STATIC
-DWITH_ZSTD=OFF
-DENABLE_LZ4_EXT=OFF
-DCMAKE_INSTALL_LIBDIR=lib
-DCMAKE_CXX_FLAGS="-stdlib=libc++"
-DWITH_SSL=ON
# If we want SASL, we need to install it on build machines
-DWITH_SASL=OFF)
@@ -223,7 +227,8 @@ import_external_library(protobuf STATIC
${PROTOBUF_ROOT}/lib/libprotobuf.a
${PROTOBUF_ROOT}/include
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND true)
CONFIGURE_COMMAND true
BUILD_COMMAND $(MAKE))
import_external_library(pulsar STATIC
${CMAKE_CURRENT_SOURCE_DIR}/pulsar/pulsar-client-cpp/lib/libpulsarwithdeps.a
@@ -233,6 +238,7 @@ import_external_library(pulsar STATIC
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/pulsar/install
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_FLAGS=-stdlib=libc++\ -I/opt/toolchain-v4/include
-DBUILD_DYNAMIC_LIB=OFF
-DBUILD_STATIC_LIB=ON
-DBUILD_TESTS=OFF

View File

@@ -222,7 +222,7 @@ repo_clone_try_double "${primary_urls[librdkafka]}" "${secondary_urls[librdkafka
protobuf_tag="v3.12.4"
repo_clone_try_double "${primary_urls[protobuf]}" "${secondary_urls[protobuf]}" "protobuf" "$protobuf_tag" true
pushd protobuf
./autogen.sh && ./configure CC=clang CXX=clang++ --prefix=$(pwd)/lib
./autogen.sh && CXXFLAGS="-stdlib=libc++ -isystem /opt/toolchain-v4/include" ./configure CC=clang CXX=clang++ --prefix=$(pwd)/lib
popd
#pulsar

View File

@@ -36,7 +36,7 @@ ADDITIONAL USE GRANT: You may use the Licensed Work in accordance with the
3. using the Licensed Work to create a work or solution
which competes (or might reasonably be expected to
compete) with the Licensed Work.
CHANGE DATE: 2026-27-04
CHANGE DATE: 2026-20-09
CHANGE LICENSE: Apache License, Version 2.0
For information about alternative licensing arrangements, please visit: https://memgraph.com/legal.

View File

@@ -72,6 +72,8 @@ make_package () {
docker exec "$build_container" bash -c "/memgraph/environment/os/$os.sh install MEMGRAPH_BUILD_DEPS"
echo "Building targeted package..."
# Fix issue with git marking directory as not safe
docker exec "$build_container" bash -c "cd /memgraph && git config --global --add safe.directory '*'"
docker exec "$build_container" bash -c "cd /memgraph && $ACTIVATE_TOOLCHAIN && ./init"
docker exec "$build_container" bash -c "cd $container_build_dir && rm -rf ./*"
if [[ "$os" == "debian-11-arm" ]]; then

View File

@@ -51,7 +51,14 @@ class IOContextThreadPool final {
running_ = false;
}
void AwaitShutdown() { background_threads_.clear(); }
void AwaitShutdown() {
for (auto &thread : background_threads_) {
if (thread.joinable()) {
thread.join();
}
}
background_threads_.clear();
}
bool IsRunning() const noexcept { return running_; }
@@ -62,7 +69,7 @@ class IOContextThreadPool final {
IOContext io_context_;
IOContextGuard guard_;
size_t pool_size_;
std::vector<std::jthread> background_threads_;
std::vector<std::thread> background_threads_;
bool running_{false};
};
} // namespace memgraph::communication::v2

View File

@@ -118,7 +118,7 @@ void TryToConsumeBatch(TConsumer &consumer, const ConsumerInfo &info, const Cons
return false;
};
if (std::ranges::any_of(batch, has_message_failed)) {
if (std::any_of(batch.begin(), batch.end(), has_message_failed)) {
throw ConsumerAcknowledgeMessagesFailedException(info.consumer_name);
}
}

View File

@@ -13,6 +13,7 @@
#include <fcntl.h>
#include <netinet/tcp.h>
#include <poll.h>
#include <unistd.h>
#include "io/network/addrinfo.hpp"
#include "io/network/socket.hpp"

View File

@@ -13,6 +13,7 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <climits>
#include <cstdlib>

View File

@@ -15,6 +15,7 @@
#include <optional>
#include <ostream>
#include <sstream>
#include <string_view>
// Define to use Py_ssize_t for API returning length of something. Some future

View File

@@ -599,7 +599,8 @@ void SymbolGenerator::VisitWithIdentifiers(Expression *expr, const std::vector<I
}
bool SymbolGenerator::HasSymbol(const std::string &name) const {
return std::ranges::any_of(scopes_, [&name](const auto &scope) { return scope.symbols.contains(name); });
return std::any_of(scopes_.begin(), scopes_.end(),
[&name](const auto &scope) { return scope.symbols.contains(name); });
}
bool SymbolGenerator::HasSymbolLocalScope(const std::string &name) const {

View File

@@ -793,18 +793,14 @@ Callback HandleStreamQuery(StreamQuery *stream_query, const Parameters &paramete
auto streams_status = interpreter_context->streams.GetStreamInfo();
std::vector<std::vector<TypedValue>> results;
results.reserve(streams_status.size());
auto stream_info_as_typed_stream_info_emplace_in = [](auto &typed_status, const auto &stream_info) {
typed_status.emplace_back(stream_info.batch_interval.count());
typed_status.emplace_back(stream_info.batch_size);
typed_status.emplace_back(stream_info.transformation_name);
};
for (const auto &status : streams_status) {
std::vector<TypedValue> typed_status;
typed_status.reserve(7);
typed_status.emplace_back(status.name);
typed_status.emplace_back(StreamSourceTypeToString(status.type));
stream_info_as_typed_stream_info_emplace_in(typed_status, status.info);
typed_status.emplace_back(status.info.batch_interval.count());
typed_status.emplace_back(status.info.batch_size);
typed_status.emplace_back(status.info.transformation_name);
if (status.owner.has_value()) {
typed_status.emplace_back(*status.owner);
} else {

View File

@@ -469,7 +469,7 @@ class ScanAllCursor : public Cursor {
const Symbol output_symbol_;
const UniqueCursorPtr input_cursor_;
TVerticesFun get_vertices_;
std::optional<typename std::result_of<TVerticesFun(Frame &, ExecutionContext &)>::type::value_type> vertices_;
std::optional<typename std::invoke_result<TVerticesFun, Frame &, ExecutionContext &>::type::value_type> vertices_;
std::optional<decltype(vertices_.value().begin())> vertices_it_;
const char *op_name_;
};

View File

@@ -326,11 +326,6 @@ class VariableStartPlanner {
},
VaryQueryMatching(query_parts, *context_->symbol_table));
}
/// @brief The result of plan generation is an iterable of roots to multiple
/// generated operator trees.
using PlanResult = typename std::result_of<decltype (&VariableStartPlanner<TPlanningContext>::Plan)(
VariableStartPlanner<TPlanningContext>, std::vector<SingleQueryPart> &)>::type;
};
} // namespace memgraph::query::plan

View File

@@ -342,13 +342,13 @@ struct mgp_list {
explicit mgp_list(memgraph::utils::MemoryResource *memory) : elems(memory) {}
mgp_list(memgraph::utils::pmr::vector<mgp_value> &&elems, memgraph::utils::MemoryResource *memory)
: elems(std::move(elems), memory) {}
: elems(elems, memory) {}
mgp_list(const mgp_list &other, memgraph::utils::MemoryResource *memory) : elems(other.elems, memory) {}
mgp_list(mgp_list &&other, memgraph::utils::MemoryResource *memory) : elems(std::move(other.elems), memory) {}
mgp_list(mgp_list &&other, memgraph::utils::MemoryResource *memory) : elems(other.elems, memory) {}
mgp_list(mgp_list &&other) noexcept : elems(std::move(other.elems)) {}
mgp_list(mgp_list &&other) noexcept : elems(other.elems) {}
/// Copy construction without memgraph::utils::MemoryResource is not allowed.
mgp_list(const mgp_list &) = delete;
@@ -544,9 +544,9 @@ struct mgp_path {
: vertices(other.vertices, memory), edges(other.edges, memory) {}
mgp_path(mgp_path &&other, memgraph::utils::MemoryResource *memory)
: vertices(std::move(other.vertices), memory), edges(std::move(other.edges), memory) {}
: vertices(other.vertices, memory), edges(other.edges, memory) {}
mgp_path(mgp_path &&other) noexcept : vertices(std::move(other.vertices)), edges(std::move(other.edges)) {}
mgp_path(mgp_path &&other) noexcept : vertices(other.vertices), edges(other.edges) {}
/// Copy construction without memgraph::utils::MemoryResource is not allowed.
mgp_path(const mgp_path &) = delete;

View File

@@ -22,6 +22,7 @@
#include "storage/v2/temporal.hpp"
#include "utils/exceptions.hpp"
#include "utils/fnv.hpp"
#include "utils/memory.hpp"
namespace memgraph::query {
@@ -215,7 +216,8 @@ TypedValue::TypedValue(const TypedValue &other, utils::MemoryResource *memory) :
new (&duration_v) utils::Duration(other.duration_v);
return;
case Type::Graph:
new (&graph_v) Graph(other.graph_v, memory_);
auto *graph_ptr = utils::Allocator<Graph>(memory_).new_object<Graph>(*other.graph_v);
new (&graph_v) std::unique_ptr<Graph>(graph_ptr);
return;
}
LOG_FATAL("Unsupported TypedValue::Type");
@@ -267,7 +269,12 @@ TypedValue::TypedValue(TypedValue &&other, utils::MemoryResource *memory) : memo
new (&duration_v) utils::Duration(other.duration_v);
break;
case Type::Graph:
new (&graph_v) Graph(std::move(other.graph_v), memory_);
if (other.GetMemoryResource() == memory_) {
new (&graph_v) std::unique_ptr<Graph>(std::move(other.graph_v));
} else {
auto *graph_ptr = utils::Allocator<Graph>(memory_).new_object<Graph>(std::move(*other.graph_v));
new (&graph_v) std::unique_ptr<Graph>(graph_ptr);
}
}
other.DestroyValue();
}
@@ -336,7 +343,22 @@ DEFINE_VALUE_AND_TYPE_GETTERS(utils::Date, Date, date_v)
DEFINE_VALUE_AND_TYPE_GETTERS(utils::LocalTime, LocalTime, local_time_v)
DEFINE_VALUE_AND_TYPE_GETTERS(utils::LocalDateTime, LocalDateTime, local_date_time_v)
DEFINE_VALUE_AND_TYPE_GETTERS(utils::Duration, Duration, duration_v)
DEFINE_VALUE_AND_TYPE_GETTERS(Graph, Graph, graph_v)
Graph &TypedValue::ValueGraph() {
if (type_ != Type::Graph) {
throw TypedValueException("TypedValue is of type '{}', not '{}'", type_, Type::Graph);
}
return *graph_v;
}
const Graph &TypedValue::ValueGraph() const {
if (type_ != Type::Graph) {
throw TypedValueException("TypedValue is of type '{}', not '{}'", type_, Type::Graph);
}
return *graph_v;
}
bool TypedValue::IsGraph() const { return type_ == Type::Graph; }
#undef DEFINE_VALUE_AND_TYPE_GETTERS
@@ -530,9 +552,11 @@ TypedValue &TypedValue::operator=(const TypedValue &other) {
case TypedValue::Type::Path:
new (&path_v) Path(other.path_v, memory_);
return *this;
case TypedValue::Type::Graph:
new (&graph_v) Graph(other.graph_v, memory_);
case TypedValue::Type::Graph: {
auto *graph_ptr = utils::Allocator<Graph>(memory_).new_object<Graph>(*other.graph_v);
new (&graph_v) std::unique_ptr<Graph>(graph_ptr);
return *this;
}
case Type::Date:
new (&date_v) utils::Date(other.date_v);
return *this;
@@ -605,7 +629,12 @@ TypedValue &TypedValue::operator=(TypedValue &&other) noexcept(false) {
new (&duration_v) utils::Duration(other.duration_v);
break;
case Type::Graph:
new (&graph_v) Graph(std::move(other.graph_v), memory_);
if (other.GetMemoryResource() == memory_) {
new (&graph_v) std::unique_ptr<Graph>(std::move(other.graph_v));
} else {
auto *graph_ptr = utils::Allocator<Graph>(memory_).new_object<Graph>(std::move(*other.graph_v));
new (&graph_v) std::unique_ptr<Graph>(graph_ptr);
}
break;
}
other.DestroyValue();
@@ -625,31 +654,36 @@ void TypedValue::DestroyValue() {
// we need to call destructors for non primitive types since we used
// placement new
case Type::String:
string_v.~TString();
std::destroy_at(&string_v);
break;
case Type::List:
list_v.~TVector();
std::destroy_at(&list_v);
break;
case Type::Map:
map_v.~TMap();
std::destroy_at(&map_v);
break;
case Type::Vertex:
vertex_v.~VertexAccessor();
std::destroy_at(&vertex_v);
break;
case Type::Edge:
edge_v.~EdgeAccessor();
std::destroy_at(&edge_v);
break;
case Type::Path:
path_v.~Path();
std::destroy_at(&path_v);
break;
case Type::Date:
case Type::LocalTime:
case Type::LocalDateTime:
case Type::Duration:
break;
case Type::Graph:
graph_v.~Graph();
case Type::Graph: {
auto *graph = graph_v.release();
std::destroy_at(&graph_v);
if (graph) {
utils::Allocator<Graph>(memory_).delete_object(graph);
}
break;
}
}
type_ = TypedValue::Type::Null;

View File

@@ -148,6 +148,11 @@ class TypedValue {
int_v = value;
}
explicit TypedValue(long long value, utils::MemoryResource *memory = utils::NewDeleteResource())
: memory_(memory), type_(Type::Int) {
int_v = value;
}
explicit TypedValue(double value, utils::MemoryResource *memory = utils::NewDeleteResource())
: memory_(memory), type_(Type::Double) {
double_v = value;
@@ -416,7 +421,8 @@ class TypedValue {
* element-wise move and graph is not guaranteed to be empty.
*/
TypedValue(Graph &&graph, utils::MemoryResource *memory) : memory_(memory), type_(Type::Graph) {
new (&graph_v) Graph(std::move(graph), memory_);
auto *graph_ptr = utils::Allocator<Graph>(memory_).new_object<Graph>(std::move(graph));
new (&graph_v) std::unique_ptr<Graph>(graph_ptr);
}
/**
@@ -547,7 +553,8 @@ class TypedValue {
utils::LocalTime local_time_v;
utils::LocalDateTime local_date_time_v;
utils::Duration duration_v;
Graph graph_v;
// As the unique_ptr is not allocator aware, it requires special attention when copying or moving graphs
std::unique_ptr<Graph> graph_v;
};
/**

View File

@@ -104,7 +104,7 @@ std::optional<std::vector<WalDurabilityInfo>> GetWalFiles(const std::filesystem:
}
MG_ASSERT(!error_code, "Couldn't recover data because an error occurred: {}!", error_code.message());
std::sort(wal_files.begin(), wal_files.end());
// std::sort(wal_files.begin(), wal_files.end());
return std::move(wal_files);
}
@@ -182,7 +182,7 @@ std::optional<RecoveryInfo> RecoverData(const std::filesystem::path &snapshot_di
if (!snapshot_files.empty()) {
spdlog::info("Try recovering from snapshot directory {}.", snapshot_directory);
// Order the files by name
std::sort(snapshot_files.begin(), snapshot_files.end());
// std::sort(snapshot_files.begin(), snapshot_files.end());
// UUID used for durability is the UUID of the last snapshot file.
*uuid = snapshot_files.back().uuid;
@@ -230,7 +230,7 @@ std::optional<RecoveryInfo> RecoverData(const std::filesystem::path &snapshot_di
std::string uuid;
std::string epoch_id;
auto operator<=>(const WalFileInfo &) const = default;
// auto operator<=>(const WalFileInfo &) const = default;
};
std::vector<WalFileInfo> wal_files;
for (const auto &item : std::filesystem::directory_iterator(wal_directory, error_code)) {
@@ -247,7 +247,7 @@ std::optional<RecoveryInfo> RecoverData(const std::filesystem::path &snapshot_di
spdlog::warn(utils::MessageWithLink("No snapshot or WAL file found.", "https://memgr.ph/durability"));
return std::nullopt;
}
std::sort(wal_files.begin(), wal_files.end());
// std::sort(wal_files.begin(), wal_files.end());
// UUID used for durability is the UUID of the last WAL file.
// Same for the epoch id.
*uuid = std::move(wal_files.back().uuid);

View File

@@ -44,7 +44,7 @@ struct SnapshotDurabilityInfo {
std::string uuid;
uint64_t start_timestamp;
auto operator<=>(const SnapshotDurabilityInfo &) const = default;
// auto operator<=>(const SnapshotDurabilityInfo &) const = default;
};
/// Get list of snapshot files with their UUID.
@@ -74,7 +74,7 @@ struct WalDurabilityInfo {
std::string epoch_id;
std::filesystem::path path;
auto operator<=>(const WalDurabilityInfo &) const = default;
// auto operator<=>(const WalDurabilityInfo &) const = default;
};
/// Get list of WAL files ordered by the sequence number

View File

@@ -11,6 +11,7 @@
#pragma once
#include <bit>
#include <map>
#include "storage/v2/id_types.hpp"

View File

@@ -378,7 +378,7 @@ std::vector<Storage::ReplicationClient::RecoveryStep> Storage::ReplicationClient
auto snapshot_files = durability::GetSnapshotFiles(storage_->snapshot_directory_, storage_->uuid_);
std::optional<durability::SnapshotDurabilityInfo> latest_snapshot;
if (!snapshot_files.empty()) {
std::sort(snapshot_files.begin(), snapshot_files.end());
// std::sort(snapshot_files.begin(), snapshot_files.end());
latest_snapshot.emplace(std::move(snapshot_files.back()));
}

View File

@@ -12,6 +12,7 @@
#include "storage/v2/replication/replication_server.hpp"
#include <atomic>
#include <filesystem>
#include <sstream>
#include "storage/v2/durability/durability.hpp"
#include "storage/v2/durability/paths.hpp"

View File

@@ -22,7 +22,7 @@ find_package(gflags REQUIRED)
find_package(Threads REQUIRED)
add_library(mg-utils STATIC ${utils_src_files})
target_link_libraries(mg-utils PUBLIC Boost::headers fmt::fmt spdlog::spdlog)
target_link_libraries(mg-utils PUBLIC Boost::headers fmt::fmt spdlog::spdlog c++experimental)
target_link_libraries(mg-utils PRIVATE librdtsc stdc++fs Threads::Threads gflags uuid rt)
set(settings_src_files
@@ -35,4 +35,3 @@ set(license_src_files
license.cpp)
add_library(mg-license STATIC ${license_src_files})
target_link_libraries(mg-license mg-settings mg-utils)

View File

@@ -11,6 +11,8 @@
#include "utils/async_timer.hpp"
#include <sys/syscall.h>
#include <unistd.h>
#include <csignal>
#include <algorithm>

View File

@@ -277,7 +277,8 @@ std::optional<License> Decode(std::string_view license_key) {
}
try {
slk::Reader reader(std::bit_cast<uint8_t *>(decoded->c_str()), decoded->size());
// TODO(gitbuda): Bitcast comes in clang 14
slk::Reader reader((uint8_t *)(decoded->c_str()), decoded->size());
std::string organization_name;
slk::Load(&organization_name, &reader);
int64_t valid_until{0};

View File

@@ -23,13 +23,12 @@
#include <type_traits>
#include <utility>
#include <vector>
// Although <memory_resource> is in C++17, gcc libstdc++ still needs to
// implement it fully. It should be available in the next major release
// version, i.e. gcc 9.x.
#if _GLIBCXX_RELEASE < 9
#if __clang__
#include <experimental/memory_resource>
namespace std_pmr = std::experimental::fundamentals_v1::pmr;
#else
#include <memory_resource>
namespace std_pmr = std::pmr;
#endif
#include "utils/logging.hpp"
@@ -251,12 +250,8 @@ bool operator!=(const Allocator<T> &a, const Allocator<U> &b) {
/// Wraps std::pmr::memory_resource for use with out MemoryResource
class StdMemoryResource final : public MemoryResource {
public:
#if _GLIBCXX_RELEASE < 9
StdMemoryResource(std::experimental::pmr::memory_resource *memory) : memory_(memory) {}
#else
/// Implicitly convert std::pmr::memory_resource to StdMemoryResource
StdMemoryResource(std::pmr::memory_resource *memory) : memory_(memory) {}
#endif
StdMemoryResource(std_pmr::memory_resource *memory) : memory_(memory) {}
private:
void *DoAllocate(size_t bytes, size_t alignment) override {
@@ -282,19 +277,11 @@ class StdMemoryResource final : public MemoryResource {
return *memory_ == *other_std->memory_;
}
#if _GLIBCXX_RELEASE < 9
std::experimental::pmr::memory_resource *memory_;
#else
std::pmr::memory_resource *memory_;
#endif
std_pmr::memory_resource *memory_;
};
inline MemoryResource *NewDeleteResource() noexcept {
#if _GLIBCXX_RELEASE < 9
static StdMemoryResource memory(std::experimental::pmr::new_delete_resource());
#else
static StdMemoryResource memory(std::pmr::new_delete_resource());
#endif
static StdMemoryResource memory(std_pmr::new_delete_resource());
return &memory;
}

View File

@@ -15,6 +15,7 @@
#include <execinfo.h>
#include <fmt/format.h>
#include <stdexcept>
#include <vector>
#include "utils/on_scope_exit.hpp"

View File

@@ -37,10 +37,10 @@ std::optional<T> ParseNumber(const std::string_view string, const size_t size) {
}
T value{};
if (const auto [p, ec] = std::from_chars(string.data(), string.data() + size, value);
ec != std::errc() || p != string.data() + size) {
return std::nullopt;
}
// if (const auto [p, ec] = std::from_chars(string.data(), string.data() + size, value);
// ec != std::errc() || p != string.data() + size) {
// return std::nullopt;
// }
return value;
}

View File

@@ -254,6 +254,22 @@ class GraphSession {
Execute(fmt::format("MATCH ()-[e]->() WHERE e.id > {} AND e.id < {} SET e.value = {}", lo, hi, num));
}
void CheckGraphProjection() {
uint64_t vertex_id = *vertices_.rbegin();
uint64_t lo = std::floor(GetRandom() * vertex_id);
uint64_t hi = std::floor(lo + vertex_id * 0.01);
Execute(fmt::format(
"MATCH p=()-[e]->() WHERE e.id > {} AND e.id < {} WITH project(p) as graph WITH graph.nodes as nodes "
"UNWIND nodes as n RETURN n.x "
"as x ORDER BY x DESC",
lo, hi));
Execute(fmt::format(
"MATCH p=()-[e]->() WHERE e.id > {} AND e.id < {} WITH project(p) as graph WITH graph.edges as edges "
"UNWIND edges as e RETURN e.prop as y ORDER BY y DESC",
lo, hi));
}
/** Checks if the local info corresponds to DB state */
void VerifyGraph() {
// helper lambda for set verification
@@ -357,6 +373,7 @@ class GraphSession {
} else {
CreateVertices(1);
}
CheckGraphProjection();
}
// final verification

View File

@@ -20,6 +20,7 @@
#include "gtest/gtest.h"
#include "query/graph.hpp"
#include "query/typed_value.hpp"
#include "storage/v2/storage.hpp"
@@ -48,8 +49,13 @@ class AllTypesFixture : public testing::Test {
{"e", TypedValue()}});
auto vertex = dba.InsertVertex();
values_.emplace_back(vertex);
values_.emplace_back(*dba.InsertEdge(&vertex, &vertex, dba.NameToEdgeType("et")));
auto edge = *dba.InsertEdge(&vertex, &vertex, dba.NameToEdgeType("et"));
values_.emplace_back(edge);
values_.emplace_back(memgraph::query::Path(dba.InsertVertex()));
memgraph::query::Graph graph{memgraph::utils::NewDeleteResource()};
graph.InsertVertex(vertex);
graph.InsertEdge(edge);
values_.emplace_back(std::move(graph));
}
};
@@ -533,6 +539,18 @@ TEST_F(AllTypesFixture, PropagationOfMemoryOnConstruction) {
EXPECT_EQ(copied.vertices(), original.vertices());
EXPECT_EQ(copied.edges(), original.edges());
EXPECT_EQ(copied.GetMemoryResource(), &monotonic_memory);
} else if (value.type() == TypedValue::Type::Graph) {
ASSERT_EQ(move_constructed_value.type(), value.type());
const auto &original = value.ValueGraph();
const auto &moved = move_constructed_value.ValueGraph();
const auto &copied = copy_constructed_value.ValueGraph();
EXPECT_EQ(original.GetMemoryResource(), memgraph::utils::NewDeleteResource());
EXPECT_EQ(moved.vertices(), original.vertices());
EXPECT_EQ(moved.edges(), original.edges());
EXPECT_EQ(moved.GetMemoryResource(), &monotonic_memory);
EXPECT_EQ(copied.vertices(), original.vertices());
EXPECT_EQ(copied.edges(), original.edges());
EXPECT_EQ(copied.GetMemoryResource(), &monotonic_memory);
}
}
}