Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add counter for SetPropertiesCursor #1460

Merged
merged 6 commits into from Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/query/plan/operator.cpp
Expand Up @@ -2896,6 +2896,8 @@ void SetPropertiesOnRecord(TRecordAccessor *record, const TypedValue &rhs, SetPr

auto update_props = [&, record](PropertiesMap &new_properties) {
auto updated_properties = UpdatePropertiesChecked(record, new_properties);
// NOLINTNEXTLINE(bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions)
context->execution_stats[ExecutionStats::Key::UPDATED_PROPERTIES] += new_properties.size();

if (should_register_change) {
for (const auto &[id, old_value, new_value] : updated_properties) {
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/interpreter.cpp
Expand Up @@ -27,6 +27,7 @@
#include "query/exceptions.hpp"
#include "query/interpreter.hpp"
#include "query/interpreter_context.hpp"
#include "query/metadata.hpp"
#include "query/stream.hpp"
#include "query/typed_value.hpp"
#include "query_common.hpp"
Expand Down Expand Up @@ -1274,6 +1275,24 @@ TYPED_TEST(InterpreterTest, ExecutionStatsValues) {
}
}

TYPED_TEST(InterpreterTest, ExecutionStatsValuesPropertiesSet) {
{
auto [stream, qid] = this->Prepare(
"CREATE (u:Employee {Uid: 'EMP_AAAAA', FirstName: 'Bong', LastName: 'Revilla'}) RETURN u.name AS name;");
this->Pull(&stream);
}
{
auto [stream, qid] = this->Prepare(
"MATCH (node:Employee) WHERE node.Uid='EMP_AAAAA' SET node={FirstName: 'James', LastName: 'Revilla', Uid: "
"'EMP_AAAAA', CreatedOn: 'null', CreatedBy: 'null', LastModifiedOn: '1698226931701', LastModifiedBy: 'null', "
"Description: 'null'};");
this->Pull(&stream);
auto stats = stream.GetSummary().at("stats").ValueMap();
auto key = memgraph::query::ExecutionStatsKeyToString(memgraph::query::ExecutionStats::Key::UPDATED_PROPERTIES);
ASSERT_EQ(stats[key].ValueInt(), 8);
}
}

TYPED_TEST(InterpreterTest, NotificationsValidStructure) {
{
auto [stream, qid] = this->Prepare("MATCH (n) DELETE n;");
Expand Down