Compare commits

...

2 Commits

Author SHA1 Message Date
Andi Skrgat
c66eb5c207 Add cpp23 2024-02-20 08:28:58 +01:00
Andi Skrgat
47cdca4f6e Add cpp23 2024-02-20 08:24:43 +01:00
4 changed files with 28 additions and 22 deletions

View File

@ -2,7 +2,7 @@
BasedOnStyle: Google
---
Language: Cpp
Standard: "c++20"
Standard: c++20
UseTab: Never
DerivePointerAlignment: false
PointerAlignment: Right

View File

@ -17,9 +17,10 @@ repos:
name: isort (python)
args: ["--profile", "black"]
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v13.0.0
rev: v17.0.6
hooks:
- id: clang-format
types_or: [c++, c]
# - repo: local
# hooks:
# - id: clang-tidy

2
init
View File

@ -120,7 +120,7 @@ fi
# develop on them -> pre-commit hook not required -> we can use latest
# packages.
if [ "${DISTRO}" != "centos-7" ] && [ "$DISTRO" != "debian-10" ] && [ "${DISTRO}" != "ubuntu-18.04" ] && [ "${DISTRO}" != "amzn-2" ]; then
python3 -m pip install pre-commit
python3 -m pip install pre-commit==3.5.*
python3 -m pre_commit install
# Install py format tools for usage during the development.
echo "Install black formatter"

View File

@ -1,4 +1,4 @@
// Copyright 2023 Memgraph Ltd.
// Copyright 2024 Memgraph Ltd.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
@ -15,6 +15,8 @@
#include "utils/flag_validation.hpp"
#include <type_traits>
// NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables)
DEFINE_VALIDATED_uint64(delta_chain_cache_threshold, 128,
"The threshold for when to cache long delta chains. This is used for heavy read + write "
@ -31,6 +33,7 @@ auto FetchHelper(VertexInfoCache const &caches, Func &&getCache, View view, Keys
// check empty first, cheaper than the relative cost of doing an actual hash + find
if (cache.empty()) return std::nullopt;
return std::nullopt;
// defer building the key, maybe a cost at construction
using key_type = typename std::remove_cvref_t<decltype(cache)>::key_type;
auto const it = cache.find(key_type{std::forward<Keys>(keys)...});
@ -76,8 +79,8 @@ void VertexInfoCache::Invalidate(Vertex const *vertex) {
new_.outDegreeCache_.erase(vertex);
// aggressive cache invalidation, TODO: be smarter
new_.hasLabelCache_.clear();
new_.propertyValueCache_.clear();
// new_.hasLabelCache_.clear();
// new_.propertyValueCache_.clear();
new_.inEdgesCache_.clear();
new_.outEdgesCache_.clear();
}
@ -87,36 +90,38 @@ auto VertexInfoCache::GetLabels(View view, Vertex const *vertex) const
return FetchHelper<std::vector<LabelId>>(*this, std::mem_fn(&VertexInfoCache::Caches::labelCache_), view, vertex);
}
void VertexInfoCache::StoreLabels(View view, Vertex const *vertex, const std::vector<LabelId> &res) {
Store(res, *this, std::mem_fn(&Caches::labelCache_), view, vertex);
// Store(res, *this, std::mem_fn(&Caches::labelCache_), view, vertex);
}
auto VertexInfoCache::GetHasLabel(View view, Vertex const *vertex, LabelId label) const -> std::optional<bool> {
return FetchHelper<bool>(*this, std::mem_fn(&Caches::hasLabelCache_), view, vertex, label);
// return FetchHelper<bool>(*this, std::mem_fn(&Caches::hasLabelCache_), view, vertex, label);
return std::nullopt;
}
void VertexInfoCache::StoreHasLabel(View view, Vertex const *vertex, LabelId label, bool res) {
Store(res, *this, std::mem_fn(&Caches::hasLabelCache_), view, vertex, label);
// Store(res, *this, std::mem_fn(&Caches::hasLabelCache_), view, vertex, label);
}
void VertexInfoCache::Invalidate(Vertex const *vertex, LabelId label) {
new_.labelCache_.erase(vertex);
new_.hasLabelCache_.erase(std::tuple{vertex, label});
// new_.hasLabelCache_.erase(std::tuple{vertex, label});
}
auto VertexInfoCache::GetProperty(View view, Vertex const *vertex, PropertyId property) const
-> std::optional<std::reference_wrapper<PropertyValue const>> {
return FetchHelper<PropertyValue>(*this, std::mem_fn(&Caches::propertyValueCache_), view, vertex, property);
// return FetchHelper<PropertyValue>(*this, std::mem_fn(&Caches::propertyValueCache_), view, vertex, property);
return std::nullopt;
}
void VertexInfoCache::StoreProperty(View view, Vertex const *vertex, PropertyId property, PropertyValue value) {
Store(std::move(value), *this, std::mem_fn(&Caches::propertyValueCache_), view, vertex, property);
// Store(std::move(value), *this, std::mem_fn(&Caches::propertyValueCache_), view, vertex, property);
}
auto VertexInfoCache::GetProperties(View view, Vertex const *vertex) const
-> std::optional<std::reference_wrapper<std::map<PropertyId, PropertyValue> const>> {
return FetchHelper<std::map<PropertyId, PropertyValue>>(*this, std::mem_fn(&Caches::propertiesCache_), view, vertex);
}
void VertexInfoCache::StoreProperties(View view, Vertex const *vertex, std::map<PropertyId, PropertyValue> properties) {
Store(std::move(properties), *this, std::mem_fn(&Caches::propertiesCache_), view, vertex);
// Store(std::move(properties), *this, std::mem_fn(&Caches::propertiesCache_), view, vertex);
}
void VertexInfoCache::Invalidate(Vertex const *vertex, PropertyId property_key) {
new_.propertiesCache_.erase(vertex);
new_.propertyValueCache_.erase(std::tuple{vertex, property_key});
// new_.propertyValueCache_.erase(std::tuple{vertex, property_key});
}
auto VertexInfoCache::GetInEdges(View view, Vertex const *src_vertex, Vertex const *dst_vertex,
@ -126,8 +131,8 @@ auto VertexInfoCache::GetInEdges(View view, Vertex const *src_vertex, Vertex con
}
void VertexInfoCache::StoreInEdges(View view, Vertex const *src_vertex, Vertex const *dst_vertex,
std::vector<EdgeTypeId> edge_types, EdgeStore in_edges) {
Store(std::move(in_edges), *this, std::mem_fn(&Caches::inEdgesCache_), view, src_vertex, dst_vertex,
std::move(edge_types));
// Store(std::move(in_edges), *this, std::mem_fn(&Caches::inEdgesCache_), view, src_vertex, dst_vertex,
// std::move(edge_types));
}
auto VertexInfoCache::GetOutEdges(View view, Vertex const *src_vertex, Vertex const *dst_vertex,
const std::vector<EdgeTypeId> &edge_types) const
@ -136,8 +141,8 @@ auto VertexInfoCache::GetOutEdges(View view, Vertex const *src_vertex, Vertex co
}
void VertexInfoCache::StoreOutEdges(View view, Vertex const *src_vertex, Vertex const *dst_vertex,
std::vector<EdgeTypeId> edge_types, EdgeStore out_edges) {
Store(std::move(out_edges), *this, std::mem_fn(&Caches::outEdgesCache_), view, src_vertex, dst_vertex,
std::move(edge_types));
// Store(std::move(out_edges), *this, std::mem_fn(&Caches::outEdgesCache_), view, src_vertex, dst_vertex,
// std::move(edge_types));
}
auto VertexInfoCache::GetInDegree(View view, Vertex const *vertex) const -> std::optional<std::size_t> {
@ -145,7 +150,7 @@ auto VertexInfoCache::GetInDegree(View view, Vertex const *vertex) const -> std:
}
void VertexInfoCache::StoreInDegree(View view, Vertex const *vertex, std::size_t in_degree) {
Store(in_degree, *this, std::mem_fn(&Caches::inDegreeCache_), view, vertex);
// Store(in_degree, *this, std::mem_fn(&Caches::inDegreeCache_), view, vertex);
}
auto VertexInfoCache::GetOutDegree(View view, Vertex const *vertex) const -> std::optional<std::size_t> {
@ -153,7 +158,7 @@ auto VertexInfoCache::GetOutDegree(View view, Vertex const *vertex) const -> std
}
void VertexInfoCache::StoreOutDegree(View view, Vertex const *vertex, std::size_t out_degree) {
Store(out_degree, *this, std::mem_fn(&Caches::outDegreeCache_), view, vertex);
// Store(out_degree, *this, std::mem_fn(&Caches::outDegreeCache_), view, vertex);
}
void VertexInfoCache::Invalidate(Vertex const *vertex, EdgeTypeId /*unused*/, EdgeDirection direction) {
@ -175,8 +180,8 @@ void VertexInfoCache::Clear() {
void VertexInfoCache::Caches::Clear() {
existsCache_.clear();
deletedCache_.clear();
hasLabelCache_.clear();
propertyValueCache_.clear();
// hasLabelCache_.clear();
// propertyValueCache_.clear();
labelCache_.clear();
propertiesCache_.clear();
inEdgesCache_.clear();