Fix clang-tidy warnings

This commit is contained in:
kostas kyrimis 2022-09-19 13:35:03 +00:00
parent 708e745410
commit 9c9d0343a9
9 changed files with 81 additions and 58 deletions

View File

@ -383,7 +383,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
template <typename VertexAccessor, typename TTag = Tag,
typename TReturnType = std::enable_if_t<std::is_same_v<TTag, StorageTag>, bool>>
TReturnType HasLabelImpl(const VertexAccessor &vertex, StorageTag tag, const LabelIx &label) {
TReturnType HasLabelImpl(const VertexAccessor &vertex, const LabelIx &label, StorageTag /*tag*/) {
auto has_label = vertex.HasLabel(view_, GetLabel(label));
if (has_label.HasError() && has_label.GetError() == Error::NONEXISTENT_OBJECT) {
// This is a very nasty and temporary hack in order to make MERGE
@ -407,15 +407,12 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
throw ExpressionRuntimeException("Unexpected error when accessing labels.");
}
}
if (!*has_label) {
return true;
}
return false;
return *has_label;
}
template <typename VertexAccessor, typename TTag = Tag,
typename TReturnType = std::enable_if_t<std::is_same_v<TTag, QueryEngineTag>, bool>>
TReturnType HasLabelImpl(const VertexAccessor &vertex, QueryEngineTag tag, const LabelIx &label_ix) {
TReturnType HasLabelImpl(const VertexAccessor &vertex, const LabelIx &label_ix, QueryEngineTag /*tag*/) {
auto label = requests::Label{.id = LabelId::FromUint(label_ix.ix)};
auto has_label = vertex.HasLabel(label);
return !has_label;
@ -429,7 +426,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
case TypedValue::Type::Vertex: {
const auto &vertex = expression_result.ValueVertex();
for (const auto &label : labels_test.labels_) {
if (HasLabelImpl(vertex, Tag{}, label)) {
if (HasLabelImpl(vertex, label, Tag{})) {
return TypedValue(false, ctx_->memory);
}
}

View File

@ -59,15 +59,15 @@ std::map<requests::PropertyId, Value> VertexAccessor::Properties() const {
Value VertexAccessor::GetProperty(requests::PropertyId prop_id) const {
MG_ASSERT(properties.contains(prop_id));
return Value(properties[prop_id]);
return properties[prop_id];
// return ValueToTypedValue(properties[prop_name]);
}
Value VertexAccessor::GetProperty(const std::string &prop_name) const {
Value VertexAccessor::GetProperty(const std::string & /*prop_name*/) const {
// TODO(kostasrim) Add string mapping
auto prop_id = requests::PropertyId::FromUint(0);
MG_ASSERT(properties.contains(prop_id));
return Value(properties[prop_id]);
return properties[prop_id];
// return ValueToTypedValue(properties[prop_name]);
}

View File

@ -43,6 +43,7 @@ class EdgeAccessor final {
requests::Edge GetEdge() const;
// Dummy function
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
inline size_t CypherId() const { return 10; }
// bool HasSrcAccessor const { return src == nullptr; }
@ -51,11 +52,11 @@ class EdgeAccessor final {
VertexAccessor To() const;
VertexAccessor From() const;
friend bool operator==(const EdgeAccessor &lhs, const EdgeAccessor &rhs) noexcept {
friend bool operator==(const EdgeAccessor &lhs, const EdgeAccessor &rhs) {
return lhs.edge == rhs.edge && lhs.properties == rhs.properties;
}
friend bool operator!=(const EdgeAccessor &lhs, const EdgeAccessor &rhs) noexcept { return !(lhs == rhs); }
friend bool operator!=(const EdgeAccessor &lhs, const EdgeAccessor &rhs) { return !(lhs == rhs); }
private:
Edge edge;
@ -73,12 +74,13 @@ class VertexAccessor final {
std::map<PropertyId, Value> Properties() const;
Value GetProperty(PropertyId prop_name) const;
Value GetProperty(PropertyId prop_id) const;
Value GetProperty(const std::string &prop_name) const;
requests::Vertex GetVertex() const;
// Dummy function
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
inline size_t CypherId() const { return 10; }
// auto InEdges(storage::View view, const std::vector<storage::EdgeTypeId> &edge_types) const
@ -120,11 +122,11 @@ class VertexAccessor final {
// storage::Result<size_t> OutDegree(storage::View view) const { return impl_.OutDegree(view); }
//
friend bool operator==(const VertexAccessor lhs, const VertexAccessor &rhs) noexcept {
friend bool operator==(const VertexAccessor &lhs, const VertexAccessor &rhs) {
return lhs.vertex == rhs.vertex && lhs.properties == rhs.properties;
}
friend bool operator!=(const VertexAccessor lhs, const VertexAccessor &rhs) noexcept { return !(lhs == rhs); }
friend bool operator!=(const VertexAccessor &lhs, const VertexAccessor &rhs) { return !(lhs == rhs); }
private:
Vertex vertex;
@ -139,24 +141,40 @@ class VertexAccessor final {
class Path {
public:
// Empty for now
explicit Path(const VertexAccessor &vertex, utils::MemoryResource *memory = utils::NewDeleteResource())
explicit Path(const VertexAccessor & /*vertex*/, utils::MemoryResource *memory = utils::NewDeleteResource())
: mem(memory) {}
template <typename... TOthers>
explicit Path(const VertexAccessor &vertex, const TOthers &...others) {}
template <typename... TOthers>
Path(std::allocator_arg_t, utils::MemoryResource *memory, const VertexAccessor &vertex, const TOthers &...others) {}
Path(std::allocator_arg_t /*unused*/, utils::MemoryResource *memory, const VertexAccessor &vertex,
const TOthers &...others) {}
Path(const Path &other) {}
Path(const Path & /*other*/) {}
Path(const Path &other, utils::MemoryResource *memory) : mem(memory) {}
Path(const Path & /*other*/, utils::MemoryResource *memory) : mem(memory) {}
Path(Path &&other) noexcept {}
Path(Path && /*other*/) noexcept {}
Path(Path &&other, utils::MemoryResource *memory) : mem(memory) {}
Path &operator=(const Path &path) { return *this; }
friend bool operator==(const Path &lhs, const Path &rhs) { return true; };
Path(Path && /*other*/, utils::MemoryResource *memory) : mem(memory) {}
Path &operator=(const Path &path) {
if (this == &path) {
return *this;
}
return *this;
}
Path &operator=(Path &&path) noexcept {
if (this == &path) {
return *this;
}
return *this;
}
~Path() {}
friend bool operator==(const Path & /*lhs*/, const Path & /*rhs*/) { return true; };
utils::MemoryResource *GetMemoryResource() { return mem; }
private:

View File

@ -388,7 +388,7 @@ TypedValue Last(const TypedValue *args, int64_t nargs, const FunctionContext &ct
return TypedValue(list.back(), ctx.memory);
}
TypedValue Properties(const TypedValue *args, int64_t nargs, const FunctionContext &ctx) { return {}; }
TypedValue Properties(const TypedValue * /*args*/, int64_t /*nargs*/, const FunctionContext & /*ctx*/) { return {}; }
TypedValue Size(const TypedValue *args, int64_t nargs, const FunctionContext &ctx) {
FType<Or<Null, List, String, Map, Path>>("size", args, nargs);
@ -560,27 +560,27 @@ TypedValue ValueType(const TypedValue *args, int64_t nargs, const FunctionContex
}
// TODO: How is Keys different from Properties function?
TypedValue Keys(const TypedValue *args, int64_t nargs, const FunctionContext &ctx) {
TypedValue Keys(const TypedValue *args, int64_t nargs, const FunctionContext & /*ctx*/) {
FType<Or<Null, Vertex, Edge>>("keys", args, nargs);
return TypedValue{};
return {};
}
TypedValue Labels(const TypedValue *args, int64_t nargs, const FunctionContext &ctx) {
FType<Or<Null, Vertex>>("labels", args, nargs);
if (args[0].IsNull()) return TypedValue(ctx.memory);
return TypedValue();
return {};
}
TypedValue Nodes(const TypedValue *args, int64_t nargs, const FunctionContext &ctx) {
FType<Or<Null, Path>>("nodes", args, nargs);
if (args[0].IsNull()) return TypedValue(ctx.memory);
return TypedValue();
return {};
}
TypedValue Relationships(const TypedValue *args, int64_t nargs, const FunctionContext &ctx) {
FType<Or<Null, Path>>("relationships", args, nargs);
if (args[0].IsNull()) return TypedValue(ctx.memory);
return TypedValue();
return {};
}
TypedValue Range(const TypedValue *args, int64_t nargs, const FunctionContext &ctx) {

View File

@ -504,6 +504,7 @@ void Expand::ExpandCursor::Reset() {
out_edges_it_ = std::nullopt;
}
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
bool Expand::ExpandCursor::InitEdges(Frame & /*frame*/, ExecutionContext & /*context*/) { return true; }
ExpandVariable::ExpandVariable(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol, Symbol node_symbol,
@ -624,6 +625,7 @@ class ExpandVariableCursor : public Cursor {
* case no more expansions are available from the current input
* vertex and another Pull from the input cursor should be performed.
*/
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
bool Expand(Frame & /*frame*/, ExecutionContext & /*context*/) { return false; }
};

View File

@ -24,12 +24,10 @@
#include "storage/v3/id_types.hpp"
#include "storage/v3/property_value.hpp"
using memgraph::coordinator::Hlc;
using memgraph::storage::v3::LabelId;
namespace requests {
struct Label {
using LabelId = memgraph::storage::v3::LabelId;
LabelId id;
friend bool operator==(const Label &lhs, const Label &rhs) { return lhs.id == rhs.id; }
};
@ -324,6 +322,7 @@ struct OrderBy {
enum class StorageView { OLD = 0, NEW = 1 };
struct ScanVerticesRequest {
using Hlc = memgraph::coordinator::Hlc;
Hlc transaction_id;
VertexId start_id;
std::optional<std::vector<std::string>> props_to_return;
@ -347,6 +346,7 @@ struct ScanVerticesResponse {
using VertexOrEdgeIds = std::variant<VertexId, EdgeId>;
struct GetPropertiesRequest {
using Hlc = memgraph::coordinator::Hlc;
Hlc transaction_id;
VertexOrEdgeIds vertex_or_edge_ids;
std::vector<PropertyId> property_ids;
@ -369,6 +369,7 @@ struct VertexEdgeId {
std::optional<EdgeId> next_id;
};
using Hlc = memgraph::coordinator::Hlc;
struct ExpandOneRequest {
Hlc transaction_id;
std::vector<VertexId> src_vertices;
@ -426,6 +427,7 @@ struct NewVertexLabel {
};
struct CreateVerticesRequest {
using Hlc = memgraph::coordinator::Hlc;
std::string label;
Hlc transaction_id;
std::vector<NewVertex> new_vertices;

View File

@ -48,6 +48,9 @@ class RsmStorageClientManager {
RsmStorageClientManager() = default;
RsmStorageClientManager(const RsmStorageClientManager &) = delete;
RsmStorageClientManager(RsmStorageClientManager &&) = delete;
RsmStorageClientManager& operator=(const RsmStorageClientManager &) = delete;
RsmStorageClientManager& operator=(RsmStorageClientManager &&) = delete;
~RsmStorageClientManager() = default;
void AddClient(const LabelId label_id, Shard key, TStorageClient client) {
cli_cache_[label_id].insert({std::move(key), std::move(client)});
@ -92,17 +95,21 @@ class ShardRequestManagerInterface {
public:
using VertexAccessor = memgraph::query::v2::accessors::VertexAccessor;
ShardRequestManagerInterface() = default;
ShardRequestManagerInterface(const ShardRequestManagerInterface &) = delete;
ShardRequestManagerInterface(ShardRequestManagerInterface &&) = delete;
ShardRequestManagerInterface &operator=(const ShardRequestManagerInterface &) = delete;
ShardRequestManagerInterface &&operator=(ShardRequestManagerInterface &&) = delete;
virtual ~ShardRequestManagerInterface() = default;
virtual void StartTransaction() = 0;
virtual std::vector<VertexAccessor> Request(ExecutionState<ScanVerticesRequest> &state) = 0;
virtual std::vector<CreateVerticesResponse> Request(ExecutionState<CreateVerticesRequest> &state,
std::vector<requests::NewVertex> new_vertices) = 0;
virtual std::vector<ExpandOneResponse> Request(ExecutionState<ExpandOneRequest> &state) = 0;
virtual ~ShardRequestManagerInterface() {}
virtual memgraph::storage::v3::PropertyId NameToProperty(const std::string &name) const = 0;
virtual memgraph::storage::v3::LabelId LabelNameToLabelId(const std::string &name) const = 0;
virtual bool IsPrimaryKey(const PropertyId name) const = 0;
ShardRequestManagerInterface(const ShardRequestManagerInterface &) = delete;
ShardRequestManagerInterface(ShardRequestManagerInterface &&) = delete;
virtual bool IsPrimaryKey(PropertyId name) const = 0;
};
// TODO(kostasrim)rename this class template
@ -121,11 +128,14 @@ class ShardRequestManager : public ShardRequestManagerInterface {
using ShardMap = memgraph::coordinator::ShardMap;
using CompoundKey = memgraph::coordinator::CompoundKey;
using VertexAccessor = memgraph::query::v2::accessors::VertexAccessor;
using LabelId = Label::LabelId;
ShardRequestManager(CoordinatorClient coord, memgraph::io::Io<TTransport> &&io)
: coord_cli_(std::move(coord)), io_(std::move(io)) {}
ShardRequestManager(const ShardRequestManager &) = delete;
ShardRequestManager(ShardRequestManager &&) = delete;
ShardRequestManager &operator=(const ShardRequestManager &) = delete;
ShardRequestManager &operator=(ShardRequestManager &&) = delete;
~ShardRequestManager() override {}
@ -177,7 +187,7 @@ class ShardRequestManager : public ShardRequestManagerInterface {
throw std::runtime_error("ScanAll request timedout");
}
auto &response = std::get<ScanVerticesResponse>(read_response_result.GetValue());
if (response.success == false) {
if (!response.success) {
throw std::runtime_error("ScanAll request did not succeed");
}
if (!response.next_start_id) {
@ -213,7 +223,7 @@ class ShardRequestManager : public ShardRequestManagerInterface {
if (write_response_result.HasError()) {
throw std::runtime_error("CreateVertices request timedout");
}
if (write_response_result.GetValue().success == false) {
if (!write_response_result.GetValue().success) {
throw std::runtime_error("CreateVertices request did not succeed");
}
responses.push_back(write_response_result.GetValue());
@ -314,12 +324,12 @@ class ShardRequestManager : public ShardRequestManagerInterface {
return;
}
state.transaction_id = transaction_id_;
const auto shards = shards_map_.GetShards(*state.label);
for (const auto &[key, shard] : shards) {
auto shards = shards_map_.GetShards(*state.label);
for (auto &[key, shard] : shards) {
state.shard_cache.push_back(std::move(shard));
ScanVerticesRequest rqst;
rqst.transaction_id = transaction_id_;
rqst.start_id.primary_key = std::move(key);
rqst.start_id.primary_key = key;
state.requests.push_back(std::move(rqst));
}
state.state = ExecutionState<ScanVerticesRequest>::EXECUTING;

View File

@ -216,15 +216,13 @@ namespace detail {
bool SetVertexLabel::IsValid() const { return object.IsVisible(storage::v3::View::OLD); }
std::map<std::string, TypedValue> SetVertexLabel::ToMap(DbAccessor *dba) const {
// return {{"vertex", TypedValue{object}}, {"label", TypedValue{dba->LabelToName(label_id)}}};
return {};
return {{"vertex", TypedValue{object}}, {"label", TypedValue{dba->LabelToName(label_id)}}};
}
bool RemovedVertexLabel::IsValid() const { return object.IsVisible(storage::v3::View::OLD); }
std::map<std::string, TypedValue> RemovedVertexLabel::ToMap(DbAccessor *dba) const {
// return {{"vertex", TypedValue{object}}, {"label", TypedValue{dba->LabelToName(label_id)}}};
return {};
return {{"vertex", TypedValue{object}}, {"label", TypedValue{dba->LabelToName(label_id)}}};
}
} // namespace detail

View File

@ -47,8 +47,7 @@ struct CreatedObject {
bool IsValid() const { return object.IsVisible(storage::v3::View::OLD); }
std::map<std::string, TypedValue> ToMap([[maybe_unused]] DbAccessor *dba) const {
// return {{ObjectString<TAccessor>(), TypedValue{object}}};
return {};
return {{ObjectString<TAccessor>(), TypedValue{object}}};
}
TAccessor object;
@ -60,8 +59,7 @@ struct DeletedObject {
bool IsValid() const { return object.IsVisible(storage::v3::View::OLD); }
std::map<std::string, TypedValue> ToMap([[maybe_unused]] DbAccessor *dba) const {
// return {{ObjectString<TAccessor>(), TypedValue{object}}};
return {};
return {{ObjectString<TAccessor>(), TypedValue{object}}};
}
TAccessor object;
@ -74,11 +72,10 @@ struct SetObjectProperty {
: object{object}, key{key}, old_value{std::move(old_value)}, new_value{std::move(new_value)} {}
std::map<std::string, TypedValue> ToMap(DbAccessor *dba) const {
return {};
// return {{ObjectString<TAccessor>(), TypedValue{object}},
// {"key", TypedValue{dba->PropertyToName(key)}},
// {"old", old_value},
// {"new", new_value}};
return {{ObjectString<TAccessor>(), TypedValue{object}},
{"key", TypedValue{dba->PropertyToName(key)}},
{"old", old_value},
{"new", new_value}};
}
bool IsValid() const { return object.IsVisible(storage::v3::View::OLD); }
@ -95,10 +92,9 @@ struct RemovedObjectProperty {
: object{object}, key{key}, old_value{std::move(old_value)} {}
std::map<std::string, TypedValue> ToMap(DbAccessor *dba) const {
return {};
// return {{ObjectString<TAccessor>(), TypedValue{object}},
// {"key", TypedValue{dba->PropertyToName(key)}},
// {"old", old_value}};
return {{ObjectString<TAccessor>(), TypedValue{object}},
{"key", TypedValue{dba->PropertyToName(key)}},
{"old", old_value}};
}
bool IsValid() const { return object.IsVisible(storage::v3::View::OLD); }