From d201e69679655805e441d0ab9a12625b079bbd9a Mon Sep 17 00:00:00 2001 From: antoniofilipovic <filipovicantonio1998@gmail.com> Date: Sun, 21 Aug 2022 13:52:54 +0200 Subject: [PATCH] fix more clang tidy errors --- src/query/db_accessor.cpp | 7 +++++-- src/query/graph.cpp | 12 +++++++----- src/query/graph.hpp | 23 ++++++++++++++++++++++- src/query/plan/operator.cpp | 1 + 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/query/db_accessor.cpp b/src/query/db_accessor.cpp index 66c6ecefe..5994d3926 100644 --- a/src/query/db_accessor.cpp +++ b/src/query/db_accessor.cpp @@ -71,7 +71,8 @@ storage::Result<EdgeAccessor> SubgraphDbAccessor::InsertEdge(SubgraphVertexAcces } storage::Result<std::optional<std::pair<VertexAccessor, std::vector<EdgeAccessor>>>> -SubgraphDbAccessor::DetachRemoveVertex(VertexAccessor *) { +SubgraphDbAccessor::DetachRemoveVertex( + VertexAccessor *) { // NOLINT(hicpp-named-parameter, readability-convert-member-functions-to-static) throw std::logic_error{"Such operation not possible on subgraph"}; } @@ -91,7 +92,9 @@ SubgraphVertexAccessor SubgraphDbAccessor::InsertVertex() { return SubgraphVertexAccessor(vertex, this->getGraph()); } -VerticesIterable SubgraphDbAccessor::Vertices(storage::View) { return VerticesIterable(graph_->vertices()); } +VerticesIterable SubgraphDbAccessor::Vertices(storage::View) { + return VerticesIterable(graph_->vertices()); +} // NOLINT(hicpp-named-parameter) std::optional<VertexAccessor> SubgraphDbAccessor::FindVertex(storage::Gid gid, storage::View view) { std::optional<VertexAccessor> maybe_vertex = db_accessor_->FindVertex(gid, view); diff --git a/src/query/graph.cpp b/src/query/graph.cpp index 7e6947493..87fc5aa90 100644 --- a/src/query/graph.cpp +++ b/src/query/graph.cpp @@ -21,6 +21,11 @@ Graph::Graph(const Graph &other, utils::MemoryResource *memory) Graph::Graph(Graph &&other) noexcept : Graph(std::move(other), other.GetMemoryResource()) {} +Graph::Graph(const Graph &other) + : Graph(other, + std::allocator_traits<allocator_type>::select_on_container_copy_construction(other.GetMemoryResource()) + .GetMemoryResource()) {} + Graph::Graph(Graph &&other, utils::MemoryResource *memory) : vertices_(std::move(other.vertices_), memory), edges_(std::move(other.edges_), memory) {} @@ -36,10 +41,7 @@ void Graph::InsertVertex(const VertexAccessor &vertex) { vertices_.insert(vertex void Graph::InsertEdge(const EdgeAccessor &edge) { edges_.insert(edge); } bool Graph::ContainsVertex(const VertexAccessor &vertex) { - if (std::find(begin(vertices_), end(vertices_), vertex) != std::end(vertices_)) { - return true; - } - return false; + return std::find(begin(vertices_), end(vertices_), vertex) != std::end(vertices_); } std::optional<VertexAccessor> Graph::RemoveVertex(const VertexAccessor &vertex) { @@ -75,7 +77,7 @@ std::vector<EdgeAccessor> Graph::OutEdges(VertexAccessor vertex_accessor) { Graph &Graph::operator=(const Graph &) = default; /** Move assign other, utils::MemoryResource of `this` is used. */ -Graph &Graph::operator=(Graph &&) = default; +Graph &Graph::operator=(Graph &&) noexcept = default; Graph::~Graph() = default; diff --git a/src/query/graph.hpp b/src/query/graph.hpp index 4fb6d230e..2cc9fcdc7 100644 --- a/src/query/graph.hpp +++ b/src/query/graph.hpp @@ -37,6 +37,16 @@ class Graph final { */ explicit Graph(utils::MemoryResource *memory); + /** + * Construct a copy of other. + * utils::MemoryResource is obtained by calling + * std::allocator_traits<>:: + * select_on_container_copy_construction(other.GetMemoryResource()). + * Since we use utils::Allocator, which does not propagate, this means that we + * will default to utils::NewDeleteResource(). + */ + Graph(const Graph &other); + /** Construct a copy using the given utils::MemoryResource */ Graph(const Graph &other, utils::MemoryResource *memory); @@ -57,19 +67,30 @@ class Graph final { /** Expands the graph with the given path. */ void Expand(const Path &path); + + /** Inserts the vertex in the graph. */ void InsertVertex(const VertexAccessor &vertex); + + /** Inserts the edge in the graph. */ void InsertEdge(const EdgeAccessor &edge); + + /** Checks whether the graph contains the vertex. */ bool ContainsVertex(const VertexAccessor &vertex); + + /** Removes the vertex from the graph if the vertex is in the graph. */ std::optional<VertexAccessor> RemoveVertex(const VertexAccessor &vertex); + + /** Removes the vertex from the graph if the vertex is in the graph. */ std::optional<EdgeAccessor> RemoveEdge(const EdgeAccessor &edge); + /** Return the out edges of the given vertex. */ std::vector<EdgeAccessor> OutEdges(VertexAccessor vertex_accessor); /** Copy assign other, utils::MemoryResource of `this` is used */ Graph &operator=(const Graph &); /** Move assign other, utils::MemoryResource of `this` is used. */ - Graph &operator=(Graph &&); + Graph &operator=(Graph &&) noexcept; ~Graph(); diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index 5f6f964b5..3a2585b29 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -2913,6 +2913,7 @@ class AggregateCursor : public Cursor { /** Checks if the given TypedValue is legal in PROJECT and PROJECT_TRANSITIVE. If not * an appropriate exception is thrown. */ + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) void EnsureOkForProject(const TypedValue &value) const { switch (value.type()) { case TypedValue::Type::Path: