2024-01-06 00:42:54 +08:00
|
|
|
// Copyright 2024 Memgraph Ltd.
|
2021-10-26 14:53:56 +08:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// License, and you may not use this file except in compliance with the Business Source License.
|
|
|
|
//
|
|
|
|
// As of the Change Date specified in that file, in accordance with
|
|
|
|
// the Business Source License, use of this software will be governed
|
|
|
|
// by the Apache License, Version 2.0, included in the file
|
|
|
|
// licenses/APL.txt.
|
|
|
|
|
2019-09-24 22:48:36 +08:00
|
|
|
#include <gmock/gmock.h>
|
2019-07-08 21:10:05 +08:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
#include "storage/v2/inmemory/storage.hpp"
|
2019-07-08 21:10:05 +08:00
|
|
|
#include "storage/v2/storage.hpp"
|
|
|
|
|
2024-01-23 17:59:11 +08:00
|
|
|
using memgraph::replication_coordination_glue::ReplicationRole;
|
2019-11-06 19:12:08 +08:00
|
|
|
using testing::UnorderedElementsAre;
|
|
|
|
|
2019-09-24 22:48:36 +08:00
|
|
|
class StorageEdgeTest : public ::testing::TestWithParam<bool> {};
|
|
|
|
|
2021-02-18 22:32:43 +08:00
|
|
|
INSTANTIATE_TEST_CASE_P(EdgesWithProperties, StorageEdgeTest, ::testing::Values(true));
|
|
|
|
INSTANTIATE_TEST_CASE_P(EdgesWithoutProperties, StorageEdgeTest, ::testing::Values(false));
|
2019-09-24 22:48:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeCreateFromSmallerCommit) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertices
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->CreateVertex();
|
|
|
|
auto vertex_to = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_from = vertex_from.Gid();
|
|
|
|
gid_to = vertex_to.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex_from, &*vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeCreateFromLargerCommit) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertices
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_to = acc->CreateVertex();
|
|
|
|
auto vertex_from = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_to = vertex_to.Gid();
|
|
|
|
gid_from = vertex_from.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex_from, &*vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeCreateFromSameCommit) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_vertex = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertex
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_vertex = vertex.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex, &*vertex, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeCreateFromSmallerAbort) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertices
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->CreateVertex();
|
|
|
|
auto vertex_to = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_from = vertex_from.Gid();
|
|
|
|
gid_to = vertex_to.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge, but abort the transaction
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex_from, &*vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex_from, &*vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeCreateFromLargerAbort) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertices
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_to = acc->CreateVertex();
|
|
|
|
auto vertex_from = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_to = vertex_to.Gid();
|
|
|
|
gid_from = vertex_from.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge, but abort the transaction
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex_from, &*vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex_from, &*vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeCreateFromSameAbort) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_vertex = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertex
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_vertex = vertex.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge, but abort the transaction
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex, &*vertex, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex, &*vertex, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerCommit) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertices
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->CreateVertex();
|
|
|
|
auto vertex_to = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_from = vertex_from.Gid();
|
|
|
|
gid_to = vertex_to.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex_from, &*vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->DeleteEdge(&edge);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
ASSERT_TRUE(res.GetValue());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeDeleteFromLargerCommit) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertices
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_to = acc->CreateVertex();
|
|
|
|
auto vertex_from = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_from = vertex_from.Gid();
|
|
|
|
gid_to = vertex_to.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex_from, &*vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->DeleteEdge(&edge);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
ASSERT_TRUE(res.GetValue());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeDeleteFromSameCommit) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_vertex = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertex
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_vertex = vertex.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex, &*vertex, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->DeleteEdge(&edge);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
ASSERT_TRUE(res.GetValue());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Check edges without filters
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeDeleteFromSmallerAbort) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertices
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->CreateVertex();
|
|
|
|
auto vertex_to = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_from = vertex_from.Gid();
|
|
|
|
gid_to = vertex_to.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex_from, &*vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the edge, but abort the transaction
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->DeleteEdge(&edge);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
ASSERT_TRUE(res.GetValue());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->DeleteEdge(&edge);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
ASSERT_TRUE(res.GetValue());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeDeleteFromLargerAbort) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertices
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->CreateVertex();
|
|
|
|
auto vertex_to = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_from = vertex_from.Gid();
|
|
|
|
gid_to = vertex_to.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex_from, &*vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the edge, but abort the transaction
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->DeleteEdge(&edge);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
ASSERT_TRUE(res.GetValue());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex_from->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->DeleteEdge(&edge);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
ASSERT_TRUE(res.GetValue());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_from)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD, {}, &*vertex_to)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, EdgeDeleteFromSameAbort) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_vertex = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create vertex
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
gid_vertex = vertex.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&*vertex, &*vertex, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), *vertex);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the edge, but abort the transaction
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->DeleteEdge(&edge);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
ASSERT_TRUE(res.GetValue());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Check edges without filters
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges without filters
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the edge
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->DeleteEdge(&edge);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
ASSERT_TRUE(res.GetValue());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Check edges without filters
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_et = acc->NameToEdgeType("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges with filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et})->edges.size(), 0);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {et, other_et})->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {}, &*vertex)->edges.size(), 1);
|
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD, {other_et}, &*vertex)->edges.size(), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the edge exists
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid_vertex, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
|
|
|
|
|
|
|
// Check edges without filters
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create dataset
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->CreateVertex();
|
|
|
|
auto vertex_to = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&vertex_from, &vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), vertex_to);
|
|
|
|
|
|
|
|
gid_from = vertex_from.Gid();
|
|
|
|
gid_to = vertex_to.Gid();
|
|
|
|
|
|
|
|
// Check edges
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from.InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from.InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from.OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from.OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to.InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to.InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to.OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to.OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Delete must fail
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DeleteVertex(&*vertex_from);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasError());
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DetachDeleteVertex(&*vertex_from);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(*ret);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check edges
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex_from->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex_from->OutDegree(memgraph::storage::View::NEW).GetError(),
|
|
|
|
memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check dataset
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_FALSE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
|
|
|
// Check edges
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleCommit) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_vertex1 = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_vertex2 = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create dataset
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex1 = acc->CreateVertex();
|
|
|
|
auto vertex2 = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
gid_vertex1 = vertex1.Gid();
|
|
|
|
gid_vertex2 = vertex2.Gid();
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et1 = acc->NameToEdgeType("et1");
|
|
|
|
auto et2 = acc->NameToEdgeType("et2");
|
|
|
|
auto et3 = acc->NameToEdgeType("et3");
|
|
|
|
auto et4 = acc->NameToEdgeType("et4");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res1 = acc->CreateEdge(&vertex1, &vertex2, et1);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res1.HasValue());
|
|
|
|
auto edge1 = res1.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge1.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge1.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(edge1.ToVertex(), vertex2);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res2 = acc->CreateEdge(&vertex2, &vertex1, et2);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res2.HasValue());
|
|
|
|
auto edge2 = res2.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge2.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge2.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(edge2.ToVertex(), vertex1);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res3 = acc->CreateEdge(&vertex1, &vertex1, et3);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res3.HasValue());
|
|
|
|
auto edge3 = res3.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge3.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge3.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(edge3.ToVertex(), vertex1);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res4 = acc->CreateEdge(&vertex2, &vertex2, et4);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res4.HasValue());
|
|
|
|
auto edge4 = res4.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge4.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge4.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(edge4.ToVertex(), vertex2);
|
|
|
|
|
|
|
|
// Check edges
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1.InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1.InDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1.OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1.OutDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2.InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2.InDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2.OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2.OutDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex1 = acc->FindVertex(gid_vertex1, memgraph::storage::View::NEW);
|
|
|
|
auto vertex2 = acc->FindVertex(gid_vertex2, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex1);
|
|
|
|
ASSERT_TRUE(vertex2);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et1 = acc->NameToEdgeType("et1");
|
|
|
|
auto et2 = acc->NameToEdgeType("et2");
|
|
|
|
auto et3 = acc->NameToEdgeType("et3");
|
|
|
|
auto et4 = acc->NameToEdgeType("et4");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Delete must fail
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DeleteVertex(&*vertex1);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasError());
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DetachDeleteVertex(&*vertex1);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(*ret);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check edges
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1->InDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
}
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(vertex1->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex1->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1->OutDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
}
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(vertex1->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex1->OutDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check dataset
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex1 = acc->FindVertex(gid_vertex1, memgraph::storage::View::NEW);
|
|
|
|
auto vertex2 = acc->FindVertex(gid_vertex2, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_FALSE(vertex1);
|
|
|
|
ASSERT_TRUE(vertex2);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et4 = acc->NameToEdgeType("et4");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, VertexDetachDeleteSingleAbort) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_from = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_to = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create dataset
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->CreateVertex();
|
|
|
|
auto vertex_to = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res = acc->CreateEdge(&vertex_from, &vertex_to, et);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasValue());
|
|
|
|
auto edge = res.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), vertex_from);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), vertex_to);
|
|
|
|
|
|
|
|
gid_from = vertex_from.Gid();
|
|
|
|
gid_to = vertex_to.Gid();
|
|
|
|
|
|
|
|
// Check edges
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from.InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from.InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from.OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from.OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to.InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to.InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to.OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to.OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex, but abort the transaction
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Delete must fail
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DeleteVertex(&*vertex_from);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasError());
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DetachDeleteVertex(&*vertex_from);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(*ret);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check edges
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex_from->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex_from->OutDegree(memgraph::storage::View::NEW).GetError(),
|
|
|
|
memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check dataset
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Delete must fail
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DeleteVertex(&*vertex_from);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasError());
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DetachDeleteVertex(&*vertex_from);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(*ret);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check edges
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->InDegree(memgraph::storage::View::OLD), 0);
|
|
|
|
ASSERT_EQ(vertex_from->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex_from->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_from->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_from->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(vertex_from->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex_from->OutDegree(memgraph::storage::View::NEW).GetError(),
|
|
|
|
memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex_to->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex_from);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex_to);
|
|
|
|
}
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check dataset
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex_from = acc->FindVertex(gid_from, memgraph::storage::View::NEW);
|
|
|
|
auto vertex_to = acc->FindVertex(gid_to, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_FALSE(vertex_from);
|
|
|
|
ASSERT_TRUE(vertex_to);
|
|
|
|
|
|
|
|
// Check edges
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->InEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->InDegree(memgraph::storage::View::NEW), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::OLD)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::OLD), 0);
|
2023-09-08 23:12:25 +08:00
|
|
|
ASSERT_EQ(vertex_to->OutEdges(memgraph::storage::View::NEW)->edges.size(), 0);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex_to->OutDegree(memgraph::storage::View::NEW), 0);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST_P(StorageEdgeTest, VertexDetachDeleteMultipleAbort) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = GetParam()}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid_vertex1 = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
|
|
|
memgraph::storage::Gid gid_vertex2 = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
// Create dataset
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex1 = acc->CreateVertex();
|
|
|
|
auto vertex2 = acc->CreateVertex();
|
2019-07-08 21:10:05 +08:00
|
|
|
|
|
|
|
gid_vertex1 = vertex1.Gid();
|
|
|
|
gid_vertex2 = vertex2.Gid();
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et1 = acc->NameToEdgeType("et1");
|
|
|
|
auto et2 = acc->NameToEdgeType("et2");
|
|
|
|
auto et3 = acc->NameToEdgeType("et3");
|
|
|
|
auto et4 = acc->NameToEdgeType("et4");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res1 = acc->CreateEdge(&vertex1, &vertex2, et1);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res1.HasValue());
|
|
|
|
auto edge1 = res1.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge1.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge1.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(edge1.ToVertex(), vertex2);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res2 = acc->CreateEdge(&vertex2, &vertex1, et2);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res2.HasValue());
|
|
|
|
auto edge2 = res2.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge2.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge2.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(edge2.ToVertex(), vertex1);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res3 = acc->CreateEdge(&vertex1, &vertex1, et3);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res3.HasValue());
|
|
|
|
auto edge3 = res3.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge3.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge3.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(edge3.ToVertex(), vertex1);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto res4 = acc->CreateEdge(&vertex2, &vertex2, et4);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res4.HasValue());
|
|
|
|
auto edge4 = res4.GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge4.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edge4.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(edge4.ToVertex(), vertex2);
|
|
|
|
|
|
|
|
// Check edges
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1.InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1.InDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1.OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1.OutDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2.InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2.InDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2.OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2.OutDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex, but abort the transaction
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex1 = acc->FindVertex(gid_vertex1, memgraph::storage::View::NEW);
|
|
|
|
auto vertex2 = acc->FindVertex(gid_vertex2, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex1);
|
|
|
|
ASSERT_TRUE(vertex2);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et1 = acc->NameToEdgeType("et1");
|
|
|
|
auto et2 = acc->NameToEdgeType("et2");
|
|
|
|
auto et3 = acc->NameToEdgeType("et3");
|
|
|
|
auto et4 = acc->NameToEdgeType("et4");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Delete must fail
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DeleteVertex(&*vertex1);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasError());
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DetachDeleteVertex(&*vertex1);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(*ret);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check edges
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1->InDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
}
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(vertex1->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex1->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1->OutDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
}
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(vertex1->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex1->OutDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check dataset
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex1 = acc->FindVertex(gid_vertex1, memgraph::storage::View::NEW);
|
|
|
|
auto vertex2 = acc->FindVertex(gid_vertex2, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex1);
|
|
|
|
ASSERT_TRUE(vertex2);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et1 = acc->NameToEdgeType("et1");
|
|
|
|
auto et2 = acc->NameToEdgeType("et2");
|
|
|
|
auto et3 = acc->NameToEdgeType("et3");
|
|
|
|
auto et4 = acc->NameToEdgeType("et4");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1->InDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1->InDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1->OutDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1->OutDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex1 = acc->FindVertex(gid_vertex1, memgraph::storage::View::NEW);
|
|
|
|
auto vertex2 = acc->FindVertex(gid_vertex2, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_TRUE(vertex1);
|
|
|
|
ASSERT_TRUE(vertex2);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et1 = acc->NameToEdgeType("et1");
|
|
|
|
auto et2 = acc->NameToEdgeType("et2");
|
|
|
|
auto et3 = acc->NameToEdgeType("et3");
|
|
|
|
auto et4 = acc->NameToEdgeType("et4");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Delete must fail
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DeleteVertex(&*vertex1);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasError());
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(ret.GetError(), memgraph::storage::Error::VERTEX_HAS_EDGES);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Detach delete vertex
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto ret = acc->DetachDeleteVertex(&*vertex1);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(*ret);
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check edges
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1->InDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
}
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(vertex1->InEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex1->InDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex1->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex1->OutDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et3);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
}
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(vertex1->OutEdges(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
|
|
|
ASSERT_EQ(vertex1->OutDegree(memgraph::storage::View::NEW).GetError(), memgraph::storage::Error::DELETED_OBJECT);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et1);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex1);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2021-02-18 22:32:43 +08:00
|
|
|
std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.EdgeType() < b.EdgeType(); });
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 2);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 2);
|
2019-07-08 21:10:05 +08:00
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et2);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex1);
|
|
|
|
}
|
|
|
|
{
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[1];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check dataset
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex1 = acc->FindVertex(gid_vertex1, memgraph::storage::View::NEW);
|
|
|
|
auto vertex2 = acc->FindVertex(gid_vertex2, memgraph::storage::View::NEW);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_FALSE(vertex1);
|
|
|
|
ASSERT_TRUE(vertex2);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et4 = acc->NameToEdgeType("et4");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:10:05 +08:00
|
|
|
// Check edges
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->InEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->InDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::OLD);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::OLD), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto ret = vertex2->OutEdges(memgraph::storage::View::NEW);
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(ret.HasValue());
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edges = ret.GetValue().edges;
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(edges.size(), 1);
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(*vertex2->OutDegree(memgraph::storage::View::NEW), 1);
|
2019-07-12 19:29:06 +08:00
|
|
|
auto e = edges[0];
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(e.EdgeType(), et4);
|
2019-07-08 21:10:05 +08:00
|
|
|
ASSERT_EQ(e.FromVertex(), *vertex2);
|
|
|
|
ASSERT_EQ(e.ToVertex(), *vertex2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-08 21:36:06 +08:00
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST(StorageWithProperties, EdgePropertyCommit) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = true}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->CreateVertex();
|
2019-07-08 21:36:06 +08:00
|
|
|
gid = vertex.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
|
|
|
auto edge = acc->CreateEdge(&vertex, &vertex, et).GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), vertex);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), vertex);
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("temporary"));
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_TRUE(old_value->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "temporary");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "temporary");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("nandare"));
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_FALSE(old_value->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_property = acc->NameToProperty("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue());
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_FALSE(old_value->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue());
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_TRUE(old_value->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0);
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_property = acc->NameToProperty("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST(StorageWithProperties, EdgePropertyAbort) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = true}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:36:06 +08:00
|
|
|
|
|
|
|
// Create the vertex.
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->CreateVertex();
|
2019-07-08 21:36:06 +08:00
|
|
|
gid = vertex.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
|
|
|
auto edge = acc->CreateEdge(&vertex, &vertex, et).GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), vertex);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), vertex);
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set property 5 to "nandare", but abort the transaction.
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("temporary"));
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_TRUE(old_value->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "temporary");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "temporary");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("nandare"));
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_FALSE(old_value->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check that property 5 is null.
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0);
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_property = acc->NameToProperty("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set property 5 to "nandare".
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("temporary"));
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_TRUE(old_value->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "temporary");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "temporary");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue("nandare"));
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_FALSE(old_value->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check that property 5 is "nandare".
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_property = acc->NameToProperty("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set property 5 to null, but abort the transaction.
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue());
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_FALSE(old_value->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check that property 5 is "nandare".
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_property = acc->NameToProperty("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set property 5 to null.
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::NEW)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property, memgraph::storage::PropertyValue());
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_FALSE(old_value->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property, memgraph::storage::View::OLD)->ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property].ValueString(), "nandare");
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check that property 5 is null.
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0);
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_property = acc->NameToProperty("other");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
2019-09-24 22:48:36 +08:00
|
|
|
TEST(StorageWithProperties, EdgePropertySerializationError) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = true}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->CreateVertex();
|
2019-07-08 21:36:06 +08:00
|
|
|
gid = vertex.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
|
|
|
auto edge = acc->CreateEdge(&vertex, &vertex, et).GetValue();
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(edge.FromVertex(), vertex);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), vertex);
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc1 = store->Access(ReplicationRole::MAIN);
|
|
|
|
auto acc2 = store->Access(ReplicationRole::MAIN);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
|
|
|
// Set property 1 to 123 in accessor 1.
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc1->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property1 = acc1->NameToProperty("property1");
|
|
|
|
auto property2 = acc1->NameToProperty("property2");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0);
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property1, memgraph::storage::PropertyValue(123));
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_TRUE(old_value->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_EQ(edge.GetProperty(property1, memgraph::storage::View::NEW)->ValueInt(), 123);
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property1].ValueInt(), 123);
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set property 2 to "nandare" in accessor 2.
|
|
|
|
{
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc2->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property1 = acc2->NameToProperty("property1");
|
|
|
|
auto property2 = acc2->NameToProperty("property2");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0);
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-07-08 21:36:06 +08:00
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto res = edge.SetProperty(property2, memgraph::storage::PropertyValue("nandare"));
|
2019-07-17 16:32:06 +08:00
|
|
|
ASSERT_TRUE(res.HasError());
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(res.GetError(), memgraph::storage::Error::SERIALIZATION_ERROR);
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finalize both accessors.
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc1->Commit().HasError());
|
|
|
|
acc2->Abort();
|
2019-07-08 21:36:06 +08:00
|
|
|
|
|
|
|
// Check which properties exist.
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-07-08 21:36:06 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property1 = acc->NameToProperty("property1");
|
|
|
|
auto property2 = acc->NameToProperty("property2");
|
2019-07-22 19:35:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property1, memgraph::storage::View::OLD)->ValueInt(), 123);
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::OLD)->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::OLD).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property1].ValueInt(), 123);
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property1, memgraph::storage::View::NEW)->ValueInt(), 123);
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull());
|
2019-07-08 21:36:06 +08:00
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto properties = edge.Properties(memgraph::storage::View::NEW).GetValue();
|
2019-07-08 21:36:06 +08:00
|
|
|
ASSERT_EQ(properties.size(), 1);
|
2019-07-22 19:35:36 +08:00
|
|
|
ASSERT_EQ(properties[property1].ValueInt(), 123);
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-07-08 21:36:06 +08:00
|
|
|
}
|
|
|
|
}
|
2019-09-24 22:48:36 +08:00
|
|
|
|
2019-11-06 19:12:08 +08:00
|
|
|
TEST(StorageWithProperties, EdgePropertyClear) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = true}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid;
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property1 = store->NameToProperty("property1");
|
|
|
|
auto property2 = store->NameToProperty("property2");
|
2019-11-06 19:12:08 +08:00
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->CreateVertex();
|
2019-11-06 19:12:08 +08:00
|
|
|
gid = vertex.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
|
|
|
auto edge = acc->CreateEdge(&vertex, &vertex, et).GetValue();
|
2019-11-06 19:12:08 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
|
|
|
ASSERT_EQ(edge.FromVertex(), vertex);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), vertex);
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property1, memgraph::storage::PropertyValue("value"));
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_TRUE(old_value->IsNull());
|
2019-11-06 19:12:08 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-11-06 19:12:08 +08:00
|
|
|
}
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-11-06 19:12:08 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-11-06 19:12:08 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property1, memgraph::storage::View::OLD)->ValueString(), "value");
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_THAT(edge.Properties(memgraph::storage::View::OLD).GetValue(),
|
|
|
|
UnorderedElementsAre(std::pair(property1, memgraph::storage::PropertyValue("value"))));
|
2019-11-06 19:12:08 +08:00
|
|
|
|
|
|
|
{
|
2021-05-10 16:10:01 +08:00
|
|
|
auto old_values = edge.ClearProperties();
|
|
|
|
ASSERT_TRUE(old_values.HasValue());
|
|
|
|
ASSERT_FALSE(old_values->empty());
|
2019-11-06 19:12:08 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW).GetValue().size(), 0);
|
2019-11-06 19:12:08 +08:00
|
|
|
|
|
|
|
{
|
2021-05-10 16:10:01 +08:00
|
|
|
auto old_values = edge.ClearProperties();
|
|
|
|
ASSERT_TRUE(old_values.HasValue());
|
|
|
|
ASSERT_TRUE(old_values->empty());
|
2019-11-06 19:12:08 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW).GetValue().size(), 0);
|
2019-11-06 19:12:08 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-11-06 19:12:08 +08:00
|
|
|
}
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-11-06 19:12:08 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-11-06 19:12:08 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
auto old_value = edge.SetProperty(property2, memgraph::storage::PropertyValue(42));
|
2021-05-10 16:10:01 +08:00
|
|
|
ASSERT_TRUE(old_value.HasValue());
|
|
|
|
ASSERT_TRUE(old_value->IsNull());
|
2019-11-06 19:12:08 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-11-06 19:12:08 +08:00
|
|
|
}
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-11-06 19:12:08 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-11-06 19:12:08 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.GetProperty(property1, memgraph::storage::View::OLD)->ValueString(), "value");
|
|
|
|
ASSERT_EQ(edge.GetProperty(property2, memgraph::storage::View::OLD)->ValueInt(), 42);
|
|
|
|
ASSERT_THAT(edge.Properties(memgraph::storage::View::OLD).GetValue(),
|
|
|
|
UnorderedElementsAre(std::pair(property1, memgraph::storage::PropertyValue("value")),
|
|
|
|
std::pair(property2, memgraph::storage::PropertyValue(42))));
|
2019-11-06 19:12:08 +08:00
|
|
|
|
|
|
|
{
|
2021-05-10 16:10:01 +08:00
|
|
|
auto old_values = edge.ClearProperties();
|
|
|
|
ASSERT_TRUE(old_values.HasValue());
|
|
|
|
ASSERT_FALSE(old_values->empty());
|
2019-11-06 19:12:08 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW).GetValue().size(), 0);
|
2019-11-06 19:12:08 +08:00
|
|
|
|
|
|
|
{
|
2021-05-10 16:10:01 +08:00
|
|
|
auto old_values = edge.ClearProperties();
|
|
|
|
ASSERT_TRUE(old_values.HasValue());
|
|
|
|
ASSERT_TRUE(old_values->empty());
|
2019-11-06 19:12:08 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW).GetValue().size(), 0);
|
2019-11-06 19:12:08 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-11-06 19:12:08 +08:00
|
|
|
}
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-11-06 19:12:08 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-11-06 19:12:08 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property1, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(property2, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW).GetValue().size(), 0);
|
2019-11-06 19:12:08 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-11-06 19:12:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-24 22:48:36 +08:00
|
|
|
// NOLINTNEXTLINE(hicpp-special-member-functions)
|
|
|
|
TEST(StorageWithoutProperties, EdgePropertyAbort) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = false}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid = memgraph::storage::Gid::FromUint(std::numeric_limits<uint64_t>::max());
|
2019-09-24 22:48:36 +08:00
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->CreateVertex();
|
2019-09-24 22:48:36 +08:00
|
|
|
gid = vertex.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
|
|
|
auto edge = acc->CreateEdge(&vertex, &vertex, et).GetValue();
|
2019-09-24 22:48:36 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
|
|
|
ASSERT_EQ(edge.FromVertex(), vertex);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), vertex);
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-09-24 22:48:36 +08:00
|
|
|
}
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-09-24 22:48:36 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-09-24 22:48:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-09-24 22:48:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-09-24 22:48:36 +08:00
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto res = edge.SetProperty(property, memgraph::storage::PropertyValue("temporary"));
|
2019-09-24 22:48:36 +08:00
|
|
|
ASSERT_TRUE(res.HasError());
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(res.GetError(), memgraph::storage::Error::PROPERTIES_DISABLED);
|
2019-09-24 22:48:36 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-09-24 22:48:36 +08:00
|
|
|
|
|
|
|
{
|
2022-02-22 20:33:45 +08:00
|
|
|
auto res = edge.SetProperty(property, memgraph::storage::PropertyValue("nandare"));
|
2019-09-24 22:48:36 +08:00
|
|
|
ASSERT_TRUE(res.HasError());
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(res.GetError(), memgraph::storage::Error::PROPERTIES_DISABLED);
|
2019-09-24 22:48:36 +08:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-09-24 22:48:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-09-24 22:48:36 +08:00
|
|
|
}
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-09-24 22:48:36 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-09-24 22:48:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = acc->NameToProperty("property5");
|
2019-09-24 22:48:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::OLD)->size(), 0);
|
2019-09-24 22:48:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(property, memgraph::storage::View::NEW)->IsNull());
|
|
|
|
ASSERT_EQ(edge.Properties(memgraph::storage::View::NEW)->size(), 0);
|
2019-09-24 22:48:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto other_property = acc->NameToProperty("other");
|
2019-09-24 22:48:36 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::OLD)->IsNull());
|
|
|
|
ASSERT_TRUE(edge.GetProperty(other_property, memgraph::storage::View::NEW)->IsNull());
|
2019-09-24 22:48:36 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-09-24 22:48:36 +08:00
|
|
|
}
|
|
|
|
}
|
2019-11-06 19:12:08 +08:00
|
|
|
|
|
|
|
TEST(StorageWithoutProperties, EdgePropertyClear) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = false}}}));
|
2022-02-22 20:33:45 +08:00
|
|
|
memgraph::storage::Gid gid;
|
2019-11-06 19:12:08 +08:00
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->CreateVertex();
|
2019-11-06 19:12:08 +08:00
|
|
|
gid = vertex.Gid();
|
2023-06-29 17:44:55 +08:00
|
|
|
auto et = acc->NameToEdgeType("et5");
|
|
|
|
auto edge = acc->CreateEdge(&vertex, &vertex, et).GetValue();
|
2019-11-06 19:12:08 +08:00
|
|
|
ASSERT_EQ(edge.EdgeType(), et);
|
|
|
|
ASSERT_EQ(edge.FromVertex(), vertex);
|
|
|
|
ASSERT_EQ(edge.ToVertex(), vertex);
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-11-06 19:12:08 +08:00
|
|
|
}
|
|
|
|
{
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->FindVertex(gid, memgraph::storage::View::OLD);
|
2019-11-06 19:12:08 +08:00
|
|
|
ASSERT_TRUE(vertex);
|
2023-09-08 23:12:25 +08:00
|
|
|
auto edge = vertex->OutEdges(memgraph::storage::View::NEW).GetValue().edges[0];
|
2019-11-06 19:12:08 +08:00
|
|
|
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge.ClearProperties().GetError(), memgraph::storage::Error::PROPERTIES_DISABLED);
|
2019-11-06 19:12:08 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
acc->Abort();
|
2019-11-06 19:12:08 +08:00
|
|
|
}
|
|
|
|
}
|
2019-11-14 23:47:59 +08:00
|
|
|
|
|
|
|
TEST(StorageWithProperties, EdgeNonexistentPropertyAPI) {
|
2023-06-29 17:44:55 +08:00
|
|
|
std::unique_ptr<memgraph::storage::Storage> store(
|
2024-01-23 19:06:10 +08:00
|
|
|
new memgraph::storage::InMemoryStorage({.salient = {.items = {.properties_on_edges = true}}}));
|
2019-11-14 23:47:59 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
auto property = store->NameToProperty("property");
|
2019-11-14 23:47:59 +08:00
|
|
|
|
2024-01-06 00:42:54 +08:00
|
|
|
auto acc = store->Access(ReplicationRole::MAIN);
|
2023-06-29 17:44:55 +08:00
|
|
|
auto vertex = acc->CreateVertex();
|
|
|
|
auto edge = acc->CreateEdge(&vertex, &vertex, acc->NameToEdgeType("edge"));
|
2019-11-14 23:47:59 +08:00
|
|
|
ASSERT_TRUE(edge.HasValue());
|
|
|
|
|
|
|
|
// Check state before (OLD view).
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge->Properties(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT);
|
|
|
|
ASSERT_EQ(edge->GetProperty(property, memgraph::storage::View::OLD).GetError(),
|
|
|
|
memgraph::storage::Error::NONEXISTENT_OBJECT);
|
2019-11-14 23:47:59 +08:00
|
|
|
|
|
|
|
// Check state before (NEW view).
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge->Properties(memgraph::storage::View::NEW)->size(), 0);
|
|
|
|
ASSERT_EQ(*edge->GetProperty(property, memgraph::storage::View::NEW), memgraph::storage::PropertyValue());
|
2019-11-14 23:47:59 +08:00
|
|
|
|
|
|
|
// Modify edge.
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_TRUE(edge->SetProperty(property, memgraph::storage::PropertyValue("value"))->IsNull());
|
2019-11-14 23:47:59 +08:00
|
|
|
|
|
|
|
// Check state after (OLD view).
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge->Properties(memgraph::storage::View::OLD).GetError(), memgraph::storage::Error::NONEXISTENT_OBJECT);
|
|
|
|
ASSERT_EQ(edge->GetProperty(property, memgraph::storage::View::OLD).GetError(),
|
|
|
|
memgraph::storage::Error::NONEXISTENT_OBJECT);
|
2019-11-14 23:47:59 +08:00
|
|
|
|
|
|
|
// Check state after (NEW view).
|
2022-02-22 20:33:45 +08:00
|
|
|
ASSERT_EQ(edge->Properties(memgraph::storage::View::NEW)->size(), 1);
|
|
|
|
ASSERT_EQ(*edge->GetProperty(property, memgraph::storage::View::NEW), memgraph::storage::PropertyValue("value"));
|
2019-11-14 23:47:59 +08:00
|
|
|
|
2023-06-29 17:44:55 +08:00
|
|
|
ASSERT_FALSE(acc->Commit().HasError());
|
2019-11-14 23:47:59 +08:00
|
|
|
}
|