diff --git a/src/storage/v2/delta.hpp b/src/storage/v2/delta.hpp index 81da955a6..1323d6f96 100644 --- a/src/storage/v2/delta.hpp +++ b/src/storage/v2/delta.hpp @@ -4,6 +4,7 @@ #include +#include "storage/v2/id_types.hpp" #include "storage/v2/property_value.hpp" namespace storage { @@ -128,49 +129,49 @@ struct Delta { timestamp(timestamp), command_id(command_id) {} - Delta(AddLabelTag, uint64_t label, std::atomic *timestamp, + Delta(AddLabelTag, LabelId label, std::atomic *timestamp, uint64_t command_id) : action(Action::ADD_LABEL), timestamp(timestamp), command_id(command_id), label(label) {} - Delta(RemoveLabelTag, uint64_t label, std::atomic *timestamp, + Delta(RemoveLabelTag, LabelId label, std::atomic *timestamp, uint64_t command_id) : action(Action::REMOVE_LABEL), timestamp(timestamp), command_id(command_id), label(label) {} - Delta(SetPropertyTag, uint64_t key, const PropertyValue &value, + Delta(SetPropertyTag, PropertyId key, const PropertyValue &value, std::atomic *timestamp, uint64_t command_id) : action(Action::SET_PROPERTY), timestamp(timestamp), command_id(command_id), property({key, value}) {} - Delta(AddInEdgeTag, uint64_t edge_type, Vertex *vertex, Edge *edge, + Delta(AddInEdgeTag, EdgeTypeId edge_type, Vertex *vertex, Edge *edge, std::atomic *timestamp, uint64_t command_id) : action(Action::ADD_IN_EDGE), timestamp(timestamp), command_id(command_id), vertex_edge({edge_type, vertex, edge}) {} - Delta(AddOutEdgeTag, uint64_t edge_type, Vertex *vertex, Edge *edge, + Delta(AddOutEdgeTag, EdgeTypeId edge_type, Vertex *vertex, Edge *edge, std::atomic *timestamp, uint64_t command_id) : action(Action::ADD_OUT_EDGE), timestamp(timestamp), command_id(command_id), vertex_edge({edge_type, vertex, edge}) {} - Delta(RemoveInEdgeTag, uint64_t edge_type, Vertex *vertex, Edge *edge, + Delta(RemoveInEdgeTag, EdgeTypeId edge_type, Vertex *vertex, Edge *edge, std::atomic *timestamp, uint64_t command_id) : action(Action::REMOVE_IN_EDGE), timestamp(timestamp), command_id(command_id), vertex_edge({edge_type, vertex, edge}) {} - Delta(RemoveOutEdgeTag, uint64_t edge_type, Vertex *vertex, Edge *edge, + Delta(RemoveOutEdgeTag, EdgeTypeId edge_type, Vertex *vertex, Edge *edge, std::atomic *timestamp, uint64_t command_id) : action(Action::REMOVE_OUT_EDGE), timestamp(timestamp), @@ -223,13 +224,13 @@ struct Delta { std::atomic next{nullptr}; union { - uint64_t label; + LabelId label; struct { - uint64_t key; + PropertyId key; storage::PropertyValue value; } property; struct { - uint64_t edge_type; + EdgeTypeId edge_type; Vertex *vertex; Edge *edge; } vertex_edge; diff --git a/src/storage/v2/edge.hpp b/src/storage/v2/edge.hpp index f4b91f535..ca8d7df4b 100644 --- a/src/storage/v2/edge.hpp +++ b/src/storage/v2/edge.hpp @@ -6,7 +6,7 @@ #include "utils/spin_lock.hpp" #include "storage/v2/delta.hpp" -#include "storage/v2/gid.hpp" +#include "storage/v2/id_types.hpp" namespace storage { @@ -20,7 +20,7 @@ struct Edge { Gid gid; - std::map properties; + std::map properties; utils::SpinLock lock; bool deleted; diff --git a/src/storage/v2/edge_accessor.cpp b/src/storage/v2/edge_accessor.cpp index bbfa8eb7f..bd0a610d5 100644 --- a/src/storage/v2/edge_accessor.cpp +++ b/src/storage/v2/edge_accessor.cpp @@ -15,7 +15,7 @@ VertexAccessor EdgeAccessor::ToVertex() { return VertexAccessor{to_vertex_, transaction_}; } -Result EdgeAccessor::SetProperty(uint64_t property, +Result EdgeAccessor::SetProperty(PropertyId property, const PropertyValue &value) { std::lock_guard guard(edge_->lock); @@ -47,7 +47,8 @@ Result EdgeAccessor::SetProperty(uint64_t property, return Result{existed}; } -Result EdgeAccessor::GetProperty(uint64_t property, View view) { +Result EdgeAccessor::GetProperty(PropertyId property, + View view) { bool deleted = false; PropertyValue value; Delta *delta = nullptr; @@ -90,8 +91,9 @@ Result EdgeAccessor::GetProperty(uint64_t property, View view) { return Result{std::move(value)}; } -Result> EdgeAccessor::Properties(View view) { - std::map properties; +Result> EdgeAccessor::Properties( + View view) { + std::map properties; bool deleted = false; Delta *delta = nullptr; { @@ -136,9 +138,9 @@ Result> EdgeAccessor::Properties(View view) { } }); if (deleted) { - return Result>{Error::DELETED_OBJECT}; + return Result>{Error::DELETED_OBJECT}; } - return Result>{std::move(properties)}; + return Result>{std::move(properties)}; } } // namespace storage diff --git a/src/storage/v2/edge_accessor.hpp b/src/storage/v2/edge_accessor.hpp index c0e27afd9..24144ff08 100644 --- a/src/storage/v2/edge_accessor.hpp +++ b/src/storage/v2/edge_accessor.hpp @@ -19,7 +19,7 @@ class EdgeAccessor final { friend class Storage; public: - EdgeAccessor(Edge *edge, uint64_t edge_type, Vertex *from_vertex, + EdgeAccessor(Edge *edge, EdgeTypeId edge_type, Vertex *from_vertex, Vertex *to_vertex, Transaction *transaction) : edge_(edge), edge_type_(edge_type), @@ -31,13 +31,13 @@ class EdgeAccessor final { VertexAccessor ToVertex(); - uint64_t EdgeType() const { return edge_type_; } + EdgeTypeId EdgeType() const { return edge_type_; } - Result SetProperty(uint64_t property, const PropertyValue &value); + Result SetProperty(PropertyId property, const PropertyValue &value); - Result GetProperty(uint64_t property, View view); + Result GetProperty(PropertyId property, View view); - Result> Properties(View view); + Result> Properties(View view); Gid Gid() const { return edge_->gid; } @@ -48,7 +48,7 @@ class EdgeAccessor final { private: Edge *edge_; - uint64_t edge_type_; + EdgeTypeId edge_type_; Vertex *from_vertex_; Vertex *to_vertex_; Transaction *transaction_; diff --git a/src/storage/v2/gid.hpp b/src/storage/v2/gid.hpp deleted file mode 100644 index 7c18be9f0..000000000 --- a/src/storage/v2/gid.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include "utils/cast.hpp" - -namespace storage { - -class Gid final { - private: - explicit Gid(uint64_t gid) : gid_(gid) {} - - public: - static Gid FromUint(uint64_t gid) { return Gid{gid}; } - - static Gid FromInt(int64_t gid) { - return Gid{utils::MemcpyCast(gid)}; - } - - uint64_t AsUint() const { return gid_; } - - int64_t AsInt() const { return utils::MemcpyCast(gid_); } - - private: - uint64_t gid_; -}; - -inline bool operator==(const Gid &first, const Gid &second) { - return first.AsUint() == second.AsUint(); -} -inline bool operator!=(const Gid &first, const Gid &second) { - return first.AsUint() != second.AsUint(); -} -inline bool operator<(const Gid &first, const Gid &second) { - return first.AsUint() < second.AsUint(); -} -inline bool operator>(const Gid &first, const Gid &second) { - return first.AsUint() > second.AsUint(); -} -inline bool operator<=(const Gid &first, const Gid &second) { - return first.AsUint() <= second.AsUint(); -} -inline bool operator>=(const Gid &first, const Gid &second) { - return first.AsUint() >= second.AsUint(); -} - -} // namespace storage diff --git a/src/storage/v2/id_types.hpp b/src/storage/v2/id_types.hpp new file mode 100644 index 000000000..21191c109 --- /dev/null +++ b/src/storage/v2/id_types.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include + +#include "utils/cast.hpp" + +namespace storage { + +#define STORAGE_DEFINE_ID_TYPE(name) \ + class name final { \ + private: \ + explicit name(uint64_t id) : id_(id) {} \ + \ + public: \ + static name FromUint(uint64_t id) { return name{id}; } \ + static name FromInt(int64_t id) { \ + return name{utils::MemcpyCast(id)}; \ + } \ + uint64_t AsUint() const { return id_; } \ + int64_t AsInt() const { return utils::MemcpyCast(id_); } \ + \ + private: \ + uint64_t id_; \ + }; \ + static_assert(std::is_trivially_copyable::value, \ + "storage::" #name " must be trivially copyable!"); \ + inline bool operator==(const name &first, const name &second) { \ + return first.AsUint() == second.AsUint(); \ + } \ + inline bool operator!=(const name &first, const name &second) { \ + return first.AsUint() != second.AsUint(); \ + } \ + inline bool operator<(const name &first, const name &second) { \ + return first.AsUint() < second.AsUint(); \ + } \ + inline bool operator>(const name &first, const name &second) { \ + return first.AsUint() > second.AsUint(); \ + } \ + inline bool operator<=(const name &first, const name &second) { \ + return first.AsUint() <= second.AsUint(); \ + } \ + inline bool operator>=(const name &first, const name &second) { \ + return first.AsUint() >= second.AsUint(); \ + } + +STORAGE_DEFINE_ID_TYPE(Gid); +STORAGE_DEFINE_ID_TYPE(LabelId); +STORAGE_DEFINE_ID_TYPE(PropertyId); +STORAGE_DEFINE_ID_TYPE(EdgeTypeId); + +#undef STORAGE_DEFINE_ID_TYPE + +} // namespace storage diff --git a/src/storage/v2/storage.cpp b/src/storage/v2/storage.cpp index f711fa029..dda82bde5 100644 --- a/src/storage/v2/storage.cpp +++ b/src/storage/v2/storage.cpp @@ -91,8 +91,8 @@ Result Storage::Accessor::DetachDeleteVertex(VertexAccessor *vertex) { "accessor when deleting a vertex!"; auto vertex_ptr = vertex->vertex_; - std::vector> in_edges; - std::vector> out_edges; + std::vector> in_edges; + std::vector> out_edges; { std::lock_guard guard(vertex_ptr->lock); @@ -146,7 +146,7 @@ Result Storage::Accessor::DetachDeleteVertex(VertexAccessor *vertex) { Result Storage::Accessor::CreateEdge(VertexAccessor *from, VertexAccessor *to, - uint64_t edge_type) { + EdgeTypeId edge_type) { CHECK(from->transaction_ == to->transaction_) << "VertexAccessors must be from the same transaction when creating " "an edge!"; @@ -251,7 +251,8 @@ Result Storage::Accessor::DeleteEdge(EdgeAccessor *edge) { CreateAndLinkDelta(&transaction_, from_vertex, Delta::AddOutEdgeTag(), edge_type, to_vertex, edge_ptr); { - std::tuple link{edge_type, to_vertex, edge_ptr}; + std::tuple link{edge_type, to_vertex, + edge_ptr}; auto it = std::find(from_vertex->out_edges.begin(), from_vertex->out_edges.end(), link); CHECK(it != from_vertex->out_edges.end()) << "Invalid database state!"; @@ -262,8 +263,8 @@ Result Storage::Accessor::DeleteEdge(EdgeAccessor *edge) { CreateAndLinkDelta(&transaction_, to_vertex, Delta::AddInEdgeTag(), edge_type, from_vertex, edge_ptr); { - std::tuple link{edge_type, from_vertex, - edge_ptr}; + std::tuple link{edge_type, from_vertex, + edge_ptr}; auto it = std::find(to_vertex->in_edges.begin(), to_vertex->in_edges.end(), link); CHECK(it != to_vertex->in_edges.end()) << "Invalid database state!"; @@ -274,24 +275,24 @@ Result Storage::Accessor::DeleteEdge(EdgeAccessor *edge) { return Result{true}; } -const std::string &Storage::Accessor::LabelToName(uint64_t label) { - return storage_->name_id_mapper_.IdToName(label); +const std::string &Storage::Accessor::LabelToName(LabelId label) { + return storage_->name_id_mapper_.IdToName(label.AsUint()); } -const std::string &Storage::Accessor::PropertyToName(uint64_t property) { - return storage_->name_id_mapper_.IdToName(property); +const std::string &Storage::Accessor::PropertyToName(PropertyId property) { + return storage_->name_id_mapper_.IdToName(property.AsUint()); } -const std::string &Storage::Accessor::EdgeTypeToName(uint64_t edge_type) { - return storage_->name_id_mapper_.IdToName(edge_type); +const std::string &Storage::Accessor::EdgeTypeToName(EdgeTypeId edge_type) { + return storage_->name_id_mapper_.IdToName(edge_type.AsUint()); } -uint64_t Storage::Accessor::NameToLabel(const std::string &name) { - return storage_->name_id_mapper_.NameToId(name); +LabelId Storage::Accessor::NameToLabel(const std::string &name) { + return LabelId::FromUint(storage_->name_id_mapper_.NameToId(name)); } -uint64_t Storage::Accessor::NameToProperty(const std::string &name) { - return storage_->name_id_mapper_.NameToId(name); +PropertyId Storage::Accessor::NameToProperty(const std::string &name) { + return PropertyId::FromUint(storage_->name_id_mapper_.NameToId(name)); } -uint64_t Storage::Accessor::NameToEdgeType(const std::string &name) { - return storage_->name_id_mapper_.NameToId(name); +EdgeTypeId Storage::Accessor::NameToEdgeType(const std::string &name) { + return EdgeTypeId::FromUint(storage_->name_id_mapper_.NameToId(name)); } void Storage::Accessor::AdvanceCommand() { ++transaction_.command_id; } @@ -392,7 +393,7 @@ void Storage::Accessor::Abort() { break; } case Delta::Action::ADD_IN_EDGE: { - std::tuple link{ + std::tuple link{ current->vertex_edge.edge_type, current->vertex_edge.vertex, current->vertex_edge.edge}; auto it = std::find(vertex->in_edges.begin(), @@ -402,7 +403,7 @@ void Storage::Accessor::Abort() { break; } case Delta::Action::ADD_OUT_EDGE: { - std::tuple link{ + std::tuple link{ current->vertex_edge.edge_type, current->vertex_edge.vertex, current->vertex_edge.edge}; auto it = std::find(vertex->out_edges.begin(), @@ -412,7 +413,7 @@ void Storage::Accessor::Abort() { break; } case Delta::Action::REMOVE_IN_EDGE: { - std::tuple link{ + std::tuple link{ current->vertex_edge.edge_type, current->vertex_edge.vertex, current->vertex_edge.edge}; auto it = std::find(vertex->in_edges.begin(), @@ -423,7 +424,7 @@ void Storage::Accessor::Abort() { break; } case Delta::Action::REMOVE_OUT_EDGE: { - std::tuple link{ + std::tuple link{ current->vertex_edge.edge_type, current->vertex_edge.vertex, current->vertex_edge.edge}; auto it = std::find(vertex->out_edges.begin(), diff --git a/src/storage/v2/storage.hpp b/src/storage/v2/storage.hpp index 37e2d4a80..504a8f9d7 100644 --- a/src/storage/v2/storage.hpp +++ b/src/storage/v2/storage.hpp @@ -76,17 +76,17 @@ class Storage final { Result DetachDeleteVertex(VertexAccessor *vertex); Result CreateEdge(VertexAccessor *from, VertexAccessor *to, - uint64_t edge_type); + EdgeTypeId edge_type); Result DeleteEdge(EdgeAccessor *edge); - const std::string &LabelToName(uint64_t label); - const std::string &PropertyToName(uint64_t property); - const std::string &EdgeTypeToName(uint64_t edge_type); + const std::string &LabelToName(LabelId label); + const std::string &PropertyToName(PropertyId property); + const std::string &EdgeTypeToName(EdgeTypeId edge_type); - uint64_t NameToLabel(const std::string &name); - uint64_t NameToProperty(const std::string &name); - uint64_t NameToEdgeType(const std::string &name); + LabelId NameToLabel(const std::string &name); + PropertyId NameToProperty(const std::string &name); + EdgeTypeId NameToEdgeType(const std::string &name); void AdvanceCommand(); diff --git a/src/storage/v2/vertex.hpp b/src/storage/v2/vertex.hpp index c2ff5877b..3c606f53f 100644 --- a/src/storage/v2/vertex.hpp +++ b/src/storage/v2/vertex.hpp @@ -9,7 +9,7 @@ #include "storage/v2/delta.hpp" #include "storage/v2/edge.hpp" -#include "storage/v2/gid.hpp" +#include "storage/v2/id_types.hpp" namespace storage { @@ -21,11 +21,11 @@ struct Vertex { Gid gid; - std::vector labels; - std::map properties; + std::vector labels; + std::map properties; - std::vector> in_edges; - std::vector> out_edges; + std::vector> in_edges; + std::vector> out_edges; utils::SpinLock lock; bool deleted; diff --git a/src/storage/v2/vertex_accessor.cpp b/src/storage/v2/vertex_accessor.cpp index e2f5d89df..82d75bb9f 100644 --- a/src/storage/v2/vertex_accessor.cpp +++ b/src/storage/v2/vertex_accessor.cpp @@ -42,7 +42,7 @@ std::optional VertexAccessor::Create(Vertex *vertex, return VertexAccessor{vertex, transaction}; } -Result VertexAccessor::AddLabel(uint64_t label) { +Result VertexAccessor::AddLabel(LabelId label) { std::lock_guard guard(vertex_->lock); if (!PrepareForWrite(transaction_, vertex_)) @@ -60,7 +60,7 @@ Result VertexAccessor::AddLabel(uint64_t label) { return Result{true}; } -Result VertexAccessor::RemoveLabel(uint64_t label) { +Result VertexAccessor::RemoveLabel(LabelId label) { std::lock_guard guard(vertex_->lock); if (!PrepareForWrite(transaction_, vertex_)) @@ -78,7 +78,7 @@ Result VertexAccessor::RemoveLabel(uint64_t label) { return Result{true}; } -Result VertexAccessor::HasLabel(uint64_t label, View view) { +Result VertexAccessor::HasLabel(LabelId label, View view) { bool deleted = false; bool has_label = false; Delta *delta = nullptr; @@ -126,9 +126,9 @@ Result VertexAccessor::HasLabel(uint64_t label, View view) { return Result{has_label}; } -Result> VertexAccessor::Labels(View view) { +Result> VertexAccessor::Labels(View view) { bool deleted = false; - std::vector labels; + std::vector labels; Delta *delta = nullptr; { std::lock_guard guard(vertex_->lock); @@ -170,11 +170,11 @@ Result> VertexAccessor::Labels(View view) { break; } }); - if (deleted) return Result>{Error::DELETED_OBJECT}; - return Result>{std::move(labels)}; + if (deleted) return Result>{Error::DELETED_OBJECT}; + return Result>{std::move(labels)}; } -Result VertexAccessor::SetProperty(uint64_t property, +Result VertexAccessor::SetProperty(PropertyId property, const PropertyValue &value) { std::lock_guard guard(vertex_->lock); @@ -206,7 +206,7 @@ Result VertexAccessor::SetProperty(uint64_t property, return Result{existed}; } -Result VertexAccessor::GetProperty(uint64_t property, +Result VertexAccessor::GetProperty(PropertyId property, View view) { bool deleted = false; PropertyValue value; @@ -250,9 +250,9 @@ Result VertexAccessor::GetProperty(uint64_t property, return Result{std::move(value)}; } -Result> VertexAccessor::Properties( +Result> VertexAccessor::Properties( View view) { - std::map properties; + std::map properties; bool deleted = false; Delta *delta = nullptr; { @@ -297,14 +297,14 @@ Result> VertexAccessor::Properties( } }); if (deleted) { - return Result>{Error::DELETED_OBJECT}; + return Result>{Error::DELETED_OBJECT}; } - return Result>{std::move(properties)}; + return Result>{std::move(properties)}; } -Result> -VertexAccessor::InEdges(const std::vector &edge_types, View view) { - std::vector> in_edges; +Result> VertexAccessor::InEdges( + const std::vector &edge_types, View view) { + std::vector> in_edges; bool deleted = false; Delta *delta = nullptr; { @@ -318,7 +318,7 @@ VertexAccessor::InEdges(const std::vector &edge_types, View view) { switch (delta.action) { case Delta::Action::ADD_IN_EDGE: { // Add the edge because we don't see the removal. - std::tuple link{ + std::tuple link{ delta.vertex_edge.edge_type, delta.vertex_edge.vertex, delta.vertex_edge.edge}; auto it = std::find(in_edges.begin(), in_edges.end(), link); @@ -328,7 +328,7 @@ VertexAccessor::InEdges(const std::vector &edge_types, View view) { } case Delta::Action::REMOVE_IN_EDGE: { // Remove the label because we don't see the addition. - std::tuple link{ + std::tuple link{ delta.vertex_edge.edge_type, delta.vertex_edge.vertex, delta.vertex_edge.edge}; auto it = std::find(in_edges.begin(), in_edges.end(), link); @@ -368,9 +368,9 @@ VertexAccessor::InEdges(const std::vector &edge_types, View view) { return Result(std::move(ret)); } -Result> -VertexAccessor::OutEdges(const std::vector &edge_types, View view) { - std::vector> out_edges; +Result> VertexAccessor::OutEdges( + const std::vector &edge_types, View view) { + std::vector> out_edges; bool deleted = false; Delta *delta = nullptr; { @@ -384,7 +384,7 @@ VertexAccessor::OutEdges(const std::vector &edge_types, View view) { switch (delta.action) { case Delta::Action::ADD_OUT_EDGE: { // Add the edge because we don't see the removal. - std::tuple link{ + std::tuple link{ delta.vertex_edge.edge_type, delta.vertex_edge.vertex, delta.vertex_edge.edge}; auto it = std::find(out_edges.begin(), out_edges.end(), link); @@ -394,7 +394,7 @@ VertexAccessor::OutEdges(const std::vector &edge_types, View view) { } case Delta::Action::REMOVE_OUT_EDGE: { // Remove the label because we don't see the addition. - std::tuple link{ + std::tuple link{ delta.vertex_edge.edge_type, delta.vertex_edge.vertex, delta.vertex_edge.edge}; auto it = std::find(out_edges.begin(), out_edges.end(), link); diff --git a/src/storage/v2/vertex_accessor.hpp b/src/storage/v2/vertex_accessor.hpp index 98503f3a0..e557b9de5 100644 --- a/src/storage/v2/vertex_accessor.hpp +++ b/src/storage/v2/vertex_accessor.hpp @@ -25,25 +25,25 @@ class VertexAccessor final { Transaction *transaction, View view); - Result AddLabel(uint64_t label); + Result AddLabel(LabelId label); - Result RemoveLabel(uint64_t label); + Result RemoveLabel(LabelId label); - Result HasLabel(uint64_t label, View view); + Result HasLabel(LabelId label, View view); - Result> Labels(View view); + Result> Labels(View view); - Result SetProperty(uint64_t property, const PropertyValue &value); + Result SetProperty(PropertyId property, const PropertyValue &value); - Result GetProperty(uint64_t property, View view); + Result GetProperty(PropertyId property, View view); - Result> Properties(View view); + Result> Properties(View view); - Result> - InEdges(const std::vector &edge_types, View view); + Result> InEdges( + const std::vector &edge_types, View view); - Result> - OutEdges(const std::vector &edge_types, View view); + Result> OutEdges( + const std::vector &edge_types, View view); Gid Gid() const { return vertex_->gid; } diff --git a/tests/benchmark/storage_v2_gc.cpp b/tests/benchmark/storage_v2_gc.cpp index 83ff84bd7..55358516d 100644 --- a/tests/benchmark/storage_v2_gc.cpp +++ b/tests/benchmark/storage_v2_gc.cpp @@ -44,7 +44,8 @@ void UpdateLabelFunc(int thread_id, storage::Storage *storage, acc.FindVertex(gid, storage::View::OLD); CHECK(vertex.has_value()) << "Vertex with GID " << gid.AsUint() << " doesn't exist"; - if (vertex->AddLabel(label_dist(gen)).HasValue()) { + if (vertex->AddLabel(storage::LabelId::FromUint(label_dist(gen))) + .HasValue()) { acc.Commit(); } else { acc.Abort(); diff --git a/tests/unit/storage_v2.cpp b/tests/unit/storage_v2.cpp index ee0b26387..c2aa638e4 100644 --- a/tests/unit/storage_v2.cpp +++ b/tests/unit/storage_v2.cpp @@ -461,31 +461,33 @@ TEST(StorageV2, VertexDeleteLabel) { auto vertex = acc.FindVertex(gid, storage::View::NEW); ASSERT_TRUE(vertex); + auto label = acc.NameToLabel("label5"); + // Check whether label 5 exists - ASSERT_FALSE(vertex->HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); // Add label 5 - ASSERT_TRUE(vertex->AddLabel(5).GetValue()); + ASSERT_TRUE(vertex->AddLabel(label).GetValue()); // Check whether label 5 exists - ASSERT_FALSE(vertex->HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); { auto labels = vertex->Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } // Delete the vertex ASSERT_TRUE(acc.DeleteVertex(&*vertex).GetValue()); // Check whether label 5 exists - ASSERT_FALSE(vertex->HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_EQ(vertex->HasLabel(5, storage::View::NEW).GetError(), + ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_EQ(vertex->HasLabel(label, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Labels(storage::View::NEW).GetError(), @@ -493,14 +495,14 @@ TEST(StorageV2, VertexDeleteLabel) { // Try to add the label { - auto ret = vertex->AddLabel(5); + auto ret = vertex->AddLabel(label); ASSERT_TRUE(ret.HasError()); ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); } // Try to remove the label { - auto ret = vertex->RemoveLabel(5); + auto ret = vertex->RemoveLabel(label); ASSERT_TRUE(ret.HasError()); ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); } @@ -514,53 +516,55 @@ TEST(StorageV2, VertexDeleteLabel) { auto vertex = acc.FindVertex(gid, storage::View::NEW); ASSERT_TRUE(vertex); + auto label = acc.NameToLabel("label5"); + // Check whether label 5 exists - ASSERT_FALSE(vertex->HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); // Add label 5 - ASSERT_TRUE(vertex->AddLabel(5).GetValue()); + ASSERT_TRUE(vertex->AddLabel(label).GetValue()); // Check whether label 5 exists - ASSERT_FALSE(vertex->HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); { auto labels = vertex->Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } // Advance command acc.AdvanceCommand(); // Check whether label 5 exists - ASSERT_TRUE(vertex->HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex->Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } { auto labels = vertex->Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } // Delete the vertex ASSERT_TRUE(acc.DeleteVertex(&*vertex).GetValue()); // Check whether label 5 exists - ASSERT_TRUE(vertex->HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_EQ(vertex->HasLabel(5, storage::View::NEW).GetError(), + ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_EQ(vertex->HasLabel(label, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); { auto labels = vertex->Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } ASSERT_EQ(vertex->Labels(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); @@ -569,9 +573,9 @@ TEST(StorageV2, VertexDeleteLabel) { acc.AdvanceCommand(); // Check whether label 5 exists - ASSERT_EQ(vertex->HasLabel(5, storage::View::OLD).GetError(), + ASSERT_EQ(vertex->HasLabel(label, storage::View::OLD).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex->HasLabel(5, storage::View::NEW).GetError(), + ASSERT_EQ(vertex->HasLabel(label, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); ASSERT_EQ(vertex->Labels(storage::View::OLD).GetError(), storage::Error::DELETED_OBJECT); @@ -580,14 +584,14 @@ TEST(StorageV2, VertexDeleteLabel) { // Try to add the label { - auto ret = vertex->AddLabel(5); + auto ret = vertex->AddLabel(label); ASSERT_TRUE(ret.HasError()); ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); } // Try to remove the label { - auto ret = vertex->RemoveLabel(5); + auto ret = vertex->RemoveLabel(label); ASSERT_TRUE(ret.HasError()); ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); } @@ -618,33 +622,36 @@ TEST(StorageV2, VertexDeleteProperty) { auto vertex = acc.FindVertex(gid, storage::View::NEW); ASSERT_TRUE(vertex); + auto property = acc.NameToProperty("property5"); + // Check whether property 5 exists - ASSERT_TRUE(vertex->GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); // Set property 5 to "nandare" ASSERT_FALSE( - vertex->SetProperty(5, storage::PropertyValue("nandare")).GetValue()); + vertex->SetProperty(property, storage::PropertyValue("nandare")) + .GetValue()); // Check whether property 5 exists - ASSERT_TRUE(vertex->GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } // Delete the vertex ASSERT_TRUE(acc.DeleteVertex(&*vertex).GetValue()); // Check whether label 5 exists - ASSERT_TRUE(vertex->GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW).GetError(), + ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Properties(storage::View::NEW).GetError(), @@ -652,7 +659,8 @@ TEST(StorageV2, VertexDeleteProperty) { // Try to set the property { - auto ret = vertex->SetProperty(5, storage::PropertyValue("haihai")); + auto ret = + vertex->SetProperty(property, storage::PropertyValue("haihai")); ASSERT_TRUE(ret.HasError()); ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); } @@ -667,58 +675,61 @@ TEST(StorageV2, VertexDeleteProperty) { auto vertex = acc.FindVertex(gid, storage::View::NEW); ASSERT_TRUE(vertex); + auto property = acc.NameToProperty("property5"); + // Check whether property 5 exists - ASSERT_TRUE(vertex->GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); // Set property 5 to "nandare" ASSERT_FALSE( - vertex->SetProperty(5, storage::PropertyValue("nandare")).GetValue()); + vertex->SetProperty(property, storage::PropertyValue("nandare")) + .GetValue()); // Check whether property 5 exists - ASSERT_TRUE(vertex->GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } // Advance command acc.AdvanceCommand(); // Check whether property 5 exists - ASSERT_EQ(vertex->GetProperty(5, storage::View::OLD)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } // Delete the vertex ASSERT_TRUE(acc.DeleteVertex(&*vertex).GetValue()); // Check whether property 5 exists - ASSERT_EQ(vertex->GetProperty(5, storage::View::OLD)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW).GetError(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); { auto properties = vertex->Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } ASSERT_EQ(vertex->Properties(storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); @@ -727,9 +738,9 @@ TEST(StorageV2, VertexDeleteProperty) { acc.AdvanceCommand(); // Check whether property 5 exists - ASSERT_EQ(vertex->GetProperty(5, storage::View::OLD).GetError(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD).GetError(), storage::Error::DELETED_OBJECT); - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW).GetError(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW).GetError(), storage::Error::DELETED_OBJECT); ASSERT_EQ(vertex->Properties(storage::View::OLD).GetError(), storage::Error::DELETED_OBJECT); @@ -738,7 +749,8 @@ TEST(StorageV2, VertexDeleteProperty) { // Try to set the property { - auto ret = vertex->SetProperty(5, storage::PropertyValue("haihai")); + auto ret = + vertex->SetProperty(property, storage::PropertyValue("haihai")); ASSERT_TRUE(ret.HasError()); ASSERT_EQ(ret.GetError(), storage::Error::DELETED_OBJECT); } @@ -757,24 +769,26 @@ TEST(StorageV2, VertexLabelCommit) { auto vertex = acc.CreateVertex(); gid = vertex.Gid(); - ASSERT_FALSE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + auto label = acc.NameToLabel("label5"); + + ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); { - auto res = vertex.AddLabel(5); + auto res = vertex.AddLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex.Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } { - auto res = vertex.AddLabel(5); + auto res = vertex.AddLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } @@ -786,22 +800,26 @@ TEST(StorageV2, VertexLabelCommit) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->HasLabel(5, storage::View::OLD).GetValue()); + auto label = acc.NameToLabel("label5"); + + ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); { auto labels = vertex->Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex->Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_FALSE(vertex->HasLabel(10, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(10, storage::View::NEW).GetValue()); + auto other_label = acc.NameToLabel("other"); + + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); acc.Abort(); } @@ -810,24 +828,26 @@ TEST(StorageV2, VertexLabelCommit) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); + auto label = acc.NameToLabel("label5"); + { - auto res = vertex->RemoveLabel(5); + auto res = vertex->RemoveLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex->HasLabel(5, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); { auto labels = vertex->Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_FALSE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); { - auto res = vertex->RemoveLabel(5); + auto res = vertex->RemoveLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } @@ -839,13 +859,17 @@ TEST(StorageV2, VertexLabelCommit) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_FALSE(vertex->HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + auto label = acc.NameToLabel("label5"); + + ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); - ASSERT_FALSE(vertex->HasLabel(10, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(10, storage::View::NEW).GetValue()); + auto other_label = acc.NameToLabel("other"); + + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); acc.Abort(); } @@ -871,24 +895,26 @@ TEST(StorageV2, VertexLabelAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_FALSE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + auto label = acc.NameToLabel("label5"); + + ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); { - auto res = vertex->AddLabel(5); + auto res = vertex->AddLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex->Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } { - auto res = vertex->AddLabel(5); + auto res = vertex->AddLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } @@ -902,13 +928,17 @@ TEST(StorageV2, VertexLabelAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_FALSE(vertex->HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + auto label = acc.NameToLabel("label5"); + + ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); - ASSERT_FALSE(vertex->HasLabel(10, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(10, storage::View::NEW).GetValue()); + auto other_label = acc.NameToLabel("other"); + + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); acc.Abort(); } @@ -919,24 +949,26 @@ TEST(StorageV2, VertexLabelAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_FALSE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + auto label = acc.NameToLabel("label5"); + + ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); { - auto res = vertex->AddLabel(5); + auto res = vertex->AddLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex->Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } { - auto res = vertex->AddLabel(5); + auto res = vertex->AddLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } @@ -950,22 +982,26 @@ TEST(StorageV2, VertexLabelAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->HasLabel(5, storage::View::OLD).GetValue()); + auto label = acc.NameToLabel("label5"); + + ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); { auto labels = vertex->Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex->Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_FALSE(vertex->HasLabel(10, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(10, storage::View::NEW).GetValue()); + auto other_label = acc.NameToLabel("other"); + + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); acc.Abort(); } @@ -976,24 +1012,26 @@ TEST(StorageV2, VertexLabelAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); + auto label = acc.NameToLabel("label5"); + { - auto res = vertex->RemoveLabel(5); + auto res = vertex->RemoveLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex->HasLabel(5, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); { auto labels = vertex->Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_FALSE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); { - auto res = vertex->RemoveLabel(5); + auto res = vertex->RemoveLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } @@ -1007,22 +1045,26 @@ TEST(StorageV2, VertexLabelAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->HasLabel(5, storage::View::OLD).GetValue()); + auto label = acc.NameToLabel("label5"); + + ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); { auto labels = vertex->Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex->Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_FALSE(vertex->HasLabel(10, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(10, storage::View::NEW).GetValue()); + auto other_label = acc.NameToLabel("other"); + + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); acc.Abort(); } @@ -1033,24 +1075,26 @@ TEST(StorageV2, VertexLabelAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); + auto label = acc.NameToLabel("label5"); + { - auto res = vertex->RemoveLabel(5); + auto res = vertex->RemoveLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_TRUE(vertex->HasLabel(5, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label, storage::View::OLD).GetValue()); { auto labels = vertex->Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_FALSE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); { - auto res = vertex->RemoveLabel(5); + auto res = vertex->RemoveLabel(label); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } @@ -1064,13 +1108,17 @@ TEST(StorageV2, VertexLabelAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_FALSE(vertex->HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(5, storage::View::NEW).GetValue()); + auto label = acc.NameToLabel("label5"); + + ASSERT_FALSE(vertex->HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); - ASSERT_FALSE(vertex->HasLabel(10, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(10, storage::View::NEW).GetValue()); + auto other_label = acc.NameToLabel("other"); + + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(other_label, storage::View::NEW).GetValue()); acc.Abort(); } @@ -1096,32 +1144,35 @@ TEST(StorageV2, VertexLabelSerializationError) { auto vertex = acc1.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_FALSE(vertex->HasLabel(1, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(1, storage::View::NEW).GetValue()); - ASSERT_FALSE(vertex->HasLabel(2, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(2, storage::View::NEW).GetValue()); + auto label1 = acc1.NameToLabel("label1"); + auto label2 = acc1.NameToLabel("label2"); + + ASSERT_FALSE(vertex->HasLabel(label1, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label1, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); { - auto res = vertex->AddLabel(1); + auto res = vertex->AddLabel(label1); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_FALSE(vertex->HasLabel(1, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex->HasLabel(1, storage::View::NEW).GetValue()); - ASSERT_FALSE(vertex->HasLabel(2, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(2, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label1, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label1, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); { auto labels = vertex->Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 1); + ASSERT_EQ(labels[0], label1); } { - auto res = vertex->AddLabel(1); + auto res = vertex->AddLabel(label1); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } @@ -1132,15 +1183,18 @@ TEST(StorageV2, VertexLabelSerializationError) { auto vertex = acc2.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_FALSE(vertex->HasLabel(1, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(1, storage::View::NEW).GetValue()); - ASSERT_FALSE(vertex->HasLabel(2, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(2, storage::View::NEW).GetValue()); + auto label1 = acc2.NameToLabel("label1"); + auto label2 = acc2.NameToLabel("label2"); + + ASSERT_FALSE(vertex->HasLabel(label1, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label1, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, storage::View::NEW).GetValue()); ASSERT_EQ(vertex->Labels(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Labels(storage::View::NEW)->size(), 0); { - auto res = vertex->AddLabel(1); + auto res = vertex->AddLabel(label1); ASSERT_TRUE(res.HasError()); ASSERT_EQ(res.GetError(), storage::Error::SERIALIZATION_ERROR); } @@ -1156,20 +1210,23 @@ TEST(StorageV2, VertexLabelSerializationError) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->HasLabel(1, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex->HasLabel(2, storage::View::OLD).GetValue()); + auto label1 = acc.NameToLabel("label1"); + auto label2 = acc.NameToLabel("label2"); + + ASSERT_TRUE(vertex->HasLabel(label1, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, storage::View::OLD).GetValue()); { auto labels = vertex->Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 1); + ASSERT_EQ(labels[0], label1); } - ASSERT_TRUE(vertex->HasLabel(1, storage::View::NEW).GetValue()); - ASSERT_FALSE(vertex->HasLabel(2, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex->HasLabel(label1, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex->HasLabel(label2, storage::View::NEW).GetValue()); { auto labels = vertex->Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 1); + ASSERT_EQ(labels[0], label1); } acc.Abort(); @@ -1186,35 +1243,39 @@ TEST(StorageV2, VertexPropertyCommit) { auto vertex = acc.CreateVertex(); gid = vertex.Gid(); - ASSERT_TRUE(vertex.GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); { - auto res = vertex.SetProperty(5, storage::PropertyValue("temporary")); + auto res = + vertex.SetProperty(property, storage::PropertyValue("temporary")); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } - ASSERT_EQ(vertex.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); { auto properties = vertex.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "temporary"); + ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto res = vertex.SetProperty(5, storage::PropertyValue("nandare")); + auto res = + vertex.SetProperty(property, storage::PropertyValue("nandare")); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(vertex.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = vertex.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } acc.Commit(); @@ -1224,24 +1285,30 @@ TEST(StorageV2, VertexPropertyCommit) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_EQ(vertex->GetProperty(5, storage::View::OLD)->ValueString(), + auto property = acc.NameToProperty("property5"); + + ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(vertex->GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -1250,25 +1317,27 @@ TEST(StorageV2, VertexPropertyCommit) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); + auto property = acc.NameToProperty("property5"); + { - auto res = vertex->SetProperty(5, storage::PropertyValue()); + auto res = vertex->SetProperty(property, storage::PropertyValue()); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::OLD)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(vertex->GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); { - auto res = vertex->SetProperty(5, storage::PropertyValue()); + auto res = vertex->SetProperty(property, storage::PropertyValue()); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } @@ -1280,13 +1349,19 @@ TEST(StorageV2, VertexPropertyCommit) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); - ASSERT_TRUE(vertex->GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -1312,35 +1387,39 @@ TEST(StorageV2, VertexPropertyAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); { - auto res = vertex->SetProperty(5, storage::PropertyValue("temporary")); + auto res = + vertex->SetProperty(property, storage::PropertyValue("temporary")); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "temporary"); + ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto res = vertex->SetProperty(5, storage::PropertyValue("nandare")); + auto res = + vertex->SetProperty(property, storage::PropertyValue("nandare")); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } acc.Abort(); @@ -1352,13 +1431,19 @@ TEST(StorageV2, VertexPropertyAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); - ASSERT_TRUE(vertex->GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -1369,35 +1454,39 @@ TEST(StorageV2, VertexPropertyAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); { - auto res = vertex->SetProperty(5, storage::PropertyValue("temporary")); + auto res = + vertex->SetProperty(property, storage::PropertyValue("temporary")); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "temporary"); + ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto res = vertex->SetProperty(5, storage::PropertyValue("nandare")); + auto res = + vertex->SetProperty(property, storage::PropertyValue("nandare")); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } acc.Commit(); @@ -1409,24 +1498,30 @@ TEST(StorageV2, VertexPropertyAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_EQ(vertex->GetProperty(5, storage::View::OLD)->ValueString(), + auto property = acc.NameToProperty("property5"); + + ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(vertex->GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -1437,37 +1532,39 @@ TEST(StorageV2, VertexPropertyAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_EQ(vertex->GetProperty(5, storage::View::OLD)->ValueString(), + auto property = acc.NameToProperty("property5"); + + ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } { - auto res = vertex->SetProperty(5, storage::PropertyValue()); + auto res = vertex->SetProperty(property, storage::PropertyValue()); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::OLD)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(vertex->GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); acc.Abort(); @@ -1479,24 +1576,30 @@ TEST(StorageV2, VertexPropertyAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_EQ(vertex->GetProperty(5, storage::View::OLD)->ValueString(), + auto property = acc.NameToProperty("property5"); + + ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(vertex->GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -1507,37 +1610,39 @@ TEST(StorageV2, VertexPropertyAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_EQ(vertex->GetProperty(5, storage::View::OLD)->ValueString(), + auto property = acc.NameToProperty("property5"); + + ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } { - auto res = vertex->SetProperty(5, storage::PropertyValue()); + auto res = vertex->SetProperty(property, storage::PropertyValue()); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(vertex->GetProperty(5, storage::View::OLD)->ValueString(), + ASSERT_EQ(vertex->GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = vertex->Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(vertex->GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); acc.Commit(); @@ -1549,13 +1654,19 @@ TEST(StorageV2, VertexPropertyAbort) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(vertex->GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); - ASSERT_TRUE(vertex->GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE( + vertex->GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -1581,28 +1692,32 @@ TEST(StorageV2, VertexPropertySerializationError) { auto vertex = acc1.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->GetProperty(1, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(2, storage::View::NEW)->IsNull()); + auto property1 = acc1.NameToProperty("property1"); + auto property2 = acc1.NameToProperty("property2"); + + ASSERT_TRUE(vertex->GetProperty(property1, storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property1, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); { - auto res = vertex->SetProperty(1, storage::PropertyValue(123)); + auto res = vertex->SetProperty(property1, storage::PropertyValue(123)); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } - ASSERT_TRUE(vertex->GetProperty(1, storage::View::OLD)->IsNull()); - ASSERT_EQ(vertex->GetProperty(1, storage::View::NEW)->ValueInt(), 123); - ASSERT_TRUE(vertex->GetProperty(2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(2, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property1, storage::View::OLD)->IsNull()); + ASSERT_EQ(vertex->GetProperty(property1, storage::View::NEW)->ValueInt(), + 123); + ASSERT_TRUE(vertex->GetProperty(property2, storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[1].ValueInt(), 123); + ASSERT_EQ(properties[property1].ValueInt(), 123); } } @@ -1611,15 +1726,19 @@ TEST(StorageV2, VertexPropertySerializationError) { auto vertex = acc2.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_TRUE(vertex->GetProperty(1, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex->GetProperty(2, storage::View::NEW)->IsNull()); + auto property1 = acc2.NameToProperty("property1"); + auto property2 = acc2.NameToProperty("property2"); + + ASSERT_TRUE(vertex->GetProperty(property1, storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property1, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex->Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex->Properties(storage::View::NEW)->size(), 0); { - auto res = vertex->SetProperty(2, storage::PropertyValue("nandare")); + auto res = + vertex->SetProperty(property2, storage::PropertyValue("nandare")); ASSERT_TRUE(res.HasError()); ASSERT_EQ(res.GetError(), storage::Error::SERIALIZATION_ERROR); } @@ -1635,20 +1754,25 @@ TEST(StorageV2, VertexPropertySerializationError) { auto vertex = acc.FindVertex(gid, storage::View::OLD); ASSERT_TRUE(vertex); - ASSERT_EQ(vertex->GetProperty(1, storage::View::OLD)->ValueInt(), 123); - ASSERT_TRUE(vertex->GetProperty(2, storage::View::OLD)->IsNull()); + auto property1 = acc.NameToProperty("property1"); + auto property2 = acc.NameToProperty("property2"); + + ASSERT_EQ(vertex->GetProperty(property1, storage::View::OLD)->ValueInt(), + 123); + ASSERT_TRUE(vertex->GetProperty(property2, storage::View::OLD)->IsNull()); { auto properties = vertex->Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[1].ValueInt(), 123); + ASSERT_EQ(properties[property1].ValueInt(), 123); } - ASSERT_EQ(vertex->GetProperty(1, storage::View::NEW)->ValueInt(), 123); - ASSERT_TRUE(vertex->GetProperty(2, storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex->GetProperty(property1, storage::View::NEW)->ValueInt(), + 123); + ASSERT_TRUE(vertex->GetProperty(property2, storage::View::NEW)->IsNull()); { auto properties = vertex->Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[1].ValueInt(), 123); + ASSERT_EQ(properties[property1].ValueInt(), 123); } acc.Abort(); @@ -1661,224 +1785,236 @@ TEST(StorageV2, VertexLabelPropertyMixed) { auto acc = store.Access(); auto vertex = acc.CreateVertex(); + auto label = acc.NameToLabel("label5"); + auto property = acc.NameToProperty("property5"); + // Check whether label 5 and property 5 exist - ASSERT_FALSE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); - ASSERT_TRUE(vertex.GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); // Add label 5 - ASSERT_TRUE(vertex.AddLabel(5).GetValue()); + ASSERT_TRUE(vertex.AddLabel(label).GetValue()); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex.Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex.GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); // Advance command acc.AdvanceCommand(); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex.Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } { auto labels = vertex.Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex.GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_TRUE(vertex.GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex.GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex.Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); // Set property 5 to "nandare" - ASSERT_FALSE( - vertex.SetProperty(5, storage::PropertyValue("nandare")).GetValue()); + ASSERT_FALSE(vertex.SetProperty(property, storage::PropertyValue("nandare")) + .GetValue()); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex.Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } { auto labels = vertex.Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_TRUE(vertex.GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_EQ(vertex.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_TRUE(vertex.GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); ASSERT_EQ(vertex.Properties(storage::View::OLD)->size(), 0); { auto properties = vertex.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } // Advance command acc.AdvanceCommand(); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex.Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } { auto labels = vertex.Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_EQ(vertex.GetProperty(5, storage::View::OLD)->ValueString(), + ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); - ASSERT_EQ(vertex.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = vertex.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } { auto properties = vertex.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } // Set property 5 to "haihai" - ASSERT_TRUE( - vertex.SetProperty(5, storage::PropertyValue("haihai")).GetValue()); + ASSERT_TRUE(vertex.SetProperty(property, storage::PropertyValue("haihai")) + .GetValue()); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex.Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } { auto labels = vertex.Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_EQ(vertex.GetProperty(5, storage::View::OLD)->ValueString(), + ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); - ASSERT_EQ(vertex.GetProperty(5, storage::View::NEW)->ValueString(), "haihai"); + ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), + "haihai"); { auto properties = vertex.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } { auto properties = vertex.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "haihai"); + ASSERT_EQ(properties[property].ValueString(), "haihai"); } // Advance command acc.AdvanceCommand(); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_TRUE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex.Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } { auto labels = vertex.Labels(storage::View::NEW).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } - ASSERT_EQ(vertex.GetProperty(5, storage::View::OLD)->ValueString(), "haihai"); - ASSERT_EQ(vertex.GetProperty(5, storage::View::NEW)->ValueString(), "haihai"); + ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), + "haihai"); + ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), + "haihai"); { auto properties = vertex.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "haihai"); + ASSERT_EQ(properties[property].ValueString(), "haihai"); } { auto properties = vertex.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "haihai"); + ASSERT_EQ(properties[property].ValueString(), "haihai"); } // Remove label 5 - ASSERT_TRUE(vertex.RemoveLabel(5).GetValue()); + ASSERT_TRUE(vertex.RemoveLabel(label).GetValue()); // Check whether label 5 and property 5 exist - ASSERT_TRUE(vertex.HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_TRUE(vertex.HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); { auto labels = vertex.Labels(storage::View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); - ASSERT_EQ(labels[0], 5); + ASSERT_EQ(labels[0], label); } ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex.GetProperty(5, storage::View::OLD)->ValueString(), "haihai"); - ASSERT_EQ(vertex.GetProperty(5, storage::View::NEW)->ValueString(), "haihai"); + ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), + "haihai"); + ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), + "haihai"); { auto properties = vertex.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "haihai"); + ASSERT_EQ(properties[property].ValueString(), "haihai"); } { auto properties = vertex.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "haihai"); + ASSERT_EQ(properties[property].ValueString(), "haihai"); } // Advance command acc.AdvanceCommand(); // Check whether label 5 and property 5 exist - ASSERT_FALSE(vertex.HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex.Labels(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex.GetProperty(5, storage::View::OLD)->ValueString(), "haihai"); - ASSERT_EQ(vertex.GetProperty(5, storage::View::NEW)->ValueString(), "haihai"); + ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), + "haihai"); + ASSERT_EQ(vertex.GetProperty(property, storage::View::NEW)->ValueString(), + "haihai"); { auto properties = vertex.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "haihai"); + ASSERT_EQ(properties[property].ValueString(), "haihai"); } { auto properties = vertex.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "haihai"); + ASSERT_EQ(properties[property].ValueString(), "haihai"); } // Set property 5 to null - ASSERT_TRUE(vertex.SetProperty(5, storage::PropertyValue()).GetValue()); + ASSERT_TRUE( + vertex.SetProperty(property, storage::PropertyValue()).GetValue()); // Check whether label 5 and property 5 exist - ASSERT_FALSE(vertex.HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex.Labels(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex.GetProperty(5, storage::View::OLD)->ValueString(), "haihai"); - ASSERT_TRUE(vertex.GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_EQ(vertex.GetProperty(property, storage::View::OLD)->ValueString(), + "haihai"); + ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); { auto properties = vertex.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "haihai"); + ASSERT_EQ(properties[property].ValueString(), "haihai"); } ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); @@ -1886,12 +2022,12 @@ TEST(StorageV2, VertexLabelPropertyMixed) { acc.AdvanceCommand(); // Check whether label 5 and property 5 exist - ASSERT_FALSE(vertex.HasLabel(5, storage::View::OLD).GetValue()); - ASSERT_FALSE(vertex.HasLabel(5, storage::View::NEW).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, storage::View::OLD).GetValue()); + ASSERT_FALSE(vertex.HasLabel(label, storage::View::NEW).GetValue()); ASSERT_EQ(vertex.Labels(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex.Labels(storage::View::NEW)->size(), 0); - ASSERT_TRUE(vertex.GetProperty(5, storage::View::NEW)->IsNull()); - ASSERT_TRUE(vertex.GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); + ASSERT_TRUE(vertex.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(vertex.Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(vertex.Properties(storage::View::NEW)->size(), 0); diff --git a/tests/unit/storage_v2_edge.cpp b/tests/unit/storage_v2_edge.cpp index f1742fcdc..070bb6cd9 100644 --- a/tests/unit/storage_v2_edge.cpp +++ b/tests/unit/storage_v2_edge.cpp @@ -30,10 +30,12 @@ TEST(StorageV2, EdgeCreateFromSmallerCommit) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); - auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex_from); ASSERT_EQ(edge.ToVertex(), *vertex_to); @@ -47,7 +49,7 @@ TEST(StorageV2, EdgeCreateFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -58,18 +60,22 @@ TEST(StorageV2, EdgeCreateFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -82,6 +88,8 @@ TEST(StorageV2, EdgeCreateFromSmallerCommit) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters ASSERT_EQ(vertex_from->InEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_from->InEdges({}, storage::View::NEW)->size(), 0); @@ -91,7 +99,7 @@ TEST(StorageV2, EdgeCreateFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -101,7 +109,7 @@ TEST(StorageV2, EdgeCreateFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -111,7 +119,7 @@ TEST(StorageV2, EdgeCreateFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -121,22 +129,28 @@ TEST(StorageV2, EdgeCreateFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -168,10 +182,12 @@ TEST(StorageV2, EdgeCreateFromLargerCommit) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); - auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex_from); ASSERT_EQ(edge.ToVertex(), *vertex_to); @@ -185,7 +201,7 @@ TEST(StorageV2, EdgeCreateFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -196,18 +212,22 @@ TEST(StorageV2, EdgeCreateFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -220,6 +240,8 @@ TEST(StorageV2, EdgeCreateFromLargerCommit) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters ASSERT_EQ(vertex_from->InEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_from->InEdges({}, storage::View::NEW)->size(), 0); @@ -229,7 +251,7 @@ TEST(StorageV2, EdgeCreateFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -239,7 +261,7 @@ TEST(StorageV2, EdgeCreateFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -249,7 +271,7 @@ TEST(StorageV2, EdgeCreateFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -259,22 +281,28 @@ TEST(StorageV2, EdgeCreateFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -300,10 +328,12 @@ TEST(StorageV2, EdgeCreateFromSameCommit) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); - auto res = acc.CreateEdge(&*vertex, &*vertex, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex, &*vertex, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex); ASSERT_EQ(edge.ToVertex(), *vertex); @@ -315,7 +345,7 @@ TEST(StorageV2, EdgeCreateFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -326,16 +356,18 @@ TEST(StorageV2, EdgeCreateFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::NEW)->size(), 1); acc.Commit(); } @@ -346,6 +378,8 @@ TEST(StorageV2, EdgeCreateFromSameCommit) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters { auto ret = vertex->InEdges({}, storage::View::OLD); @@ -353,7 +387,7 @@ TEST(StorageV2, EdgeCreateFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -363,7 +397,7 @@ TEST(StorageV2, EdgeCreateFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -373,7 +407,7 @@ TEST(StorageV2, EdgeCreateFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -383,20 +417,22 @@ TEST(StorageV2, EdgeCreateFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::NEW)->size(), 1); acc.Commit(); } @@ -428,10 +464,12 @@ TEST(StorageV2, EdgeCreateFromSmallerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); - auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex_from); ASSERT_EQ(edge.ToVertex(), *vertex_to); @@ -445,7 +483,7 @@ TEST(StorageV2, EdgeCreateFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -456,18 +494,22 @@ TEST(StorageV2, EdgeCreateFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Abort(); } @@ -501,10 +543,12 @@ TEST(StorageV2, EdgeCreateFromSmallerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); - auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex_from); ASSERT_EQ(edge.ToVertex(), *vertex_to); @@ -518,7 +562,7 @@ TEST(StorageV2, EdgeCreateFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -529,18 +573,22 @@ TEST(StorageV2, EdgeCreateFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -553,6 +601,8 @@ TEST(StorageV2, EdgeCreateFromSmallerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters ASSERT_EQ(vertex_from->InEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_from->InEdges({}, storage::View::NEW)->size(), 0); @@ -562,7 +612,7 @@ TEST(StorageV2, EdgeCreateFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -572,7 +622,7 @@ TEST(StorageV2, EdgeCreateFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -582,7 +632,7 @@ TEST(StorageV2, EdgeCreateFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -592,22 +642,28 @@ TEST(StorageV2, EdgeCreateFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -639,10 +695,12 @@ TEST(StorageV2, EdgeCreateFromLargerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); - auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex_from); ASSERT_EQ(edge.ToVertex(), *vertex_to); @@ -656,7 +714,7 @@ TEST(StorageV2, EdgeCreateFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -667,18 +725,22 @@ TEST(StorageV2, EdgeCreateFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Abort(); } @@ -712,10 +774,12 @@ TEST(StorageV2, EdgeCreateFromLargerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); - auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex_from); ASSERT_EQ(edge.ToVertex(), *vertex_to); @@ -729,7 +793,7 @@ TEST(StorageV2, EdgeCreateFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -740,18 +804,22 @@ TEST(StorageV2, EdgeCreateFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -764,6 +832,8 @@ TEST(StorageV2, EdgeCreateFromLargerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters ASSERT_EQ(vertex_from->InEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_from->InEdges({}, storage::View::NEW)->size(), 0); @@ -773,7 +843,7 @@ TEST(StorageV2, EdgeCreateFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -783,7 +853,7 @@ TEST(StorageV2, EdgeCreateFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -793,7 +863,7 @@ TEST(StorageV2, EdgeCreateFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -803,22 +873,28 @@ TEST(StorageV2, EdgeCreateFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -844,10 +920,12 @@ TEST(StorageV2, EdgeCreateFromSameAbort) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); - auto res = acc.CreateEdge(&*vertex, &*vertex, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex, &*vertex, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex); ASSERT_EQ(edge.ToVertex(), *vertex); @@ -859,7 +937,7 @@ TEST(StorageV2, EdgeCreateFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -870,16 +948,18 @@ TEST(StorageV2, EdgeCreateFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::NEW)->size(), 1); acc.Abort(); } @@ -905,10 +985,12 @@ TEST(StorageV2, EdgeCreateFromSameAbort) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); - auto res = acc.CreateEdge(&*vertex, &*vertex, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex, &*vertex, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex); ASSERT_EQ(edge.ToVertex(), *vertex); @@ -920,7 +1002,7 @@ TEST(StorageV2, EdgeCreateFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -931,16 +1013,18 @@ TEST(StorageV2, EdgeCreateFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::NEW)->size(), 1); acc.Commit(); } @@ -951,6 +1035,8 @@ TEST(StorageV2, EdgeCreateFromSameAbort) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters { auto ret = vertex->InEdges({}, storage::View::OLD); @@ -958,7 +1044,7 @@ TEST(StorageV2, EdgeCreateFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -968,7 +1054,7 @@ TEST(StorageV2, EdgeCreateFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -978,7 +1064,7 @@ TEST(StorageV2, EdgeCreateFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -988,20 +1074,22 @@ TEST(StorageV2, EdgeCreateFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::NEW)->size(), 1); acc.Commit(); } @@ -1033,10 +1121,12 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); - auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex_from); ASSERT_EQ(edge.ToVertex(), *vertex_to); @@ -1050,7 +1140,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1061,18 +1151,22 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -1085,6 +1179,8 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters ASSERT_EQ(vertex_from->InEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_from->InEdges({}, storage::View::NEW)->size(), 0); @@ -1094,7 +1190,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1104,7 +1200,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1114,7 +1210,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1124,22 +1220,28 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -1152,6 +1254,8 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + auto edge = vertex_from->OutEdges({}, storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); @@ -1167,7 +1271,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1178,7 +1282,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1186,11 +1290,15 @@ TEST(StorageV2, EdgeDeleteFromSmallerCommit) { ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); acc.Commit(); } @@ -1243,10 +1351,12 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); - auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex_from); ASSERT_EQ(edge.ToVertex(), *vertex_to); @@ -1260,7 +1370,7 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1271,18 +1381,22 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -1295,6 +1409,8 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters ASSERT_EQ(vertex_from->InEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_from->InEdges({}, storage::View::NEW)->size(), 0); @@ -1304,7 +1420,7 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1314,7 +1430,7 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1324,7 +1440,7 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1334,22 +1450,28 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -1362,6 +1484,8 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + auto edge = vertex_from->OutEdges({}, storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); @@ -1377,7 +1501,7 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1388,7 +1512,7 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1396,11 +1520,15 @@ TEST(StorageV2, EdgeDeleteFromLargerCommit) { ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); acc.Commit(); } @@ -1447,10 +1575,12 @@ TEST(StorageV2, EdgeDeleteFromSameCommit) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); - auto res = acc.CreateEdge(&*vertex, &*vertex, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex, &*vertex, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex); ASSERT_EQ(edge.ToVertex(), *vertex); @@ -1462,7 +1592,7 @@ TEST(StorageV2, EdgeDeleteFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -1473,16 +1603,18 @@ TEST(StorageV2, EdgeDeleteFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::NEW)->size(), 1); acc.Commit(); } @@ -1493,6 +1625,8 @@ TEST(StorageV2, EdgeDeleteFromSameCommit) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters { auto ret = vertex->InEdges({}, storage::View::OLD); @@ -1500,7 +1634,7 @@ TEST(StorageV2, EdgeDeleteFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -1510,7 +1644,7 @@ TEST(StorageV2, EdgeDeleteFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -1520,7 +1654,7 @@ TEST(StorageV2, EdgeDeleteFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -1530,20 +1664,22 @@ TEST(StorageV2, EdgeDeleteFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::NEW)->size(), 1); acc.Commit(); } @@ -1554,6 +1690,8 @@ TEST(StorageV2, EdgeDeleteFromSameCommit) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); + auto et = acc.NameToEdgeType("et5"); + auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); @@ -1567,7 +1705,7 @@ TEST(StorageV2, EdgeDeleteFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -1578,17 +1716,19 @@ TEST(StorageV2, EdgeDeleteFromSameCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } ASSERT_EQ(vertex->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::OLD)->size(), 1); acc.Commit(); } @@ -1635,10 +1775,12 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); - auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex_from); ASSERT_EQ(edge.ToVertex(), *vertex_to); @@ -1652,7 +1794,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1663,18 +1805,22 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -1687,6 +1833,8 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters ASSERT_EQ(vertex_from->InEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_from->InEdges({}, storage::View::NEW)->size(), 0); @@ -1696,7 +1844,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1706,7 +1854,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1716,7 +1864,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1726,22 +1874,28 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -1754,6 +1908,8 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + auto edge = vertex_from->OutEdges({}, storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); @@ -1769,7 +1925,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1780,7 +1936,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1788,11 +1944,15 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); acc.Abort(); } @@ -1805,6 +1965,8 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters ASSERT_EQ(vertex_from->InEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_from->InEdges({}, storage::View::NEW)->size(), 0); @@ -1814,7 +1976,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1824,7 +1986,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1834,7 +1996,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1844,22 +2006,28 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -1872,6 +2040,8 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + auto edge = vertex_from->OutEdges({}, storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); @@ -1887,7 +2057,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1898,7 +2068,7 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1906,11 +2076,15 @@ TEST(StorageV2, EdgeDeleteFromSmallerAbort) { ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); acc.Commit(); } @@ -1963,10 +2137,12 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); - auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex_from, &*vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex_from); ASSERT_EQ(edge.ToVertex(), *vertex_to); @@ -1980,7 +2156,7 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -1991,18 +2167,22 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -2015,6 +2195,8 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters ASSERT_EQ(vertex_from->InEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_from->InEdges({}, storage::View::NEW)->size(), 0); @@ -2024,7 +2206,7 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2034,7 +2216,7 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2044,7 +2226,7 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2054,22 +2236,28 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -2082,6 +2270,8 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + auto edge = vertex_from->OutEdges({}, storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); @@ -2097,7 +2287,7 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2108,7 +2298,7 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2116,11 +2306,15 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); acc.Abort(); } @@ -2133,6 +2327,8 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters ASSERT_EQ(vertex_from->InEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_from->InEdges({}, storage::View::NEW)->size(), 0); @@ -2142,7 +2338,7 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2152,7 +2348,7 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2162,7 +2358,7 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2172,22 +2368,28 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::NEW)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::NEW)->size(), + 1); acc.Commit(); } @@ -2200,6 +2402,8 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + auto edge = vertex_from->OutEdges({}, storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); @@ -2215,7 +2419,7 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2226,7 +2430,7 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2234,11 +2438,15 @@ TEST(StorageV2, EdgeDeleteFromLargerAbort) { ASSERT_EQ(vertex_to->OutEdges({}, storage::View::OLD)->size(), 0); ASSERT_EQ(vertex_to->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex_from->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_from->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex_to->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex_to->InEdges({2, 5}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex_from->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_from->OutEdges({et, other_et}, storage::View::OLD)->size(), + 1); + ASSERT_EQ(vertex_to->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex_to->InEdges({et, other_et}, storage::View::OLD)->size(), + 1); acc.Commit(); } @@ -2285,10 +2493,12 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); - auto res = acc.CreateEdge(&*vertex, &*vertex, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&*vertex, &*vertex, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), *vertex); ASSERT_EQ(edge.ToVertex(), *vertex); @@ -2300,7 +2510,7 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -2311,16 +2521,18 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::NEW)->size(), 1); acc.Commit(); } @@ -2331,6 +2543,8 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters { auto ret = vertex->InEdges({}, storage::View::OLD); @@ -2338,7 +2552,7 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -2348,7 +2562,7 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -2358,7 +2572,7 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -2368,20 +2582,22 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::NEW)->size(), 1); acc.Commit(); } @@ -2392,6 +2608,8 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); + auto et = acc.NameToEdgeType("et5"); + auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); @@ -2405,7 +2623,7 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -2416,17 +2634,19 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } ASSERT_EQ(vertex->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::OLD)->size(), 1); acc.Abort(); } @@ -2437,6 +2657,8 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); + auto et = acc.NameToEdgeType("et5"); + // Check edges without filters { auto ret = vertex->InEdges({}, storage::View::OLD); @@ -2444,7 +2666,7 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -2454,7 +2676,7 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -2464,7 +2686,7 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -2474,20 +2696,22 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->InEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::NEW)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::NEW)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::NEW)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::NEW)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::NEW)->size(), 1); acc.Commit(); } @@ -2498,6 +2722,8 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto vertex = acc.FindVertex(gid_vertex, storage::View::NEW); ASSERT_TRUE(vertex); + auto et = acc.NameToEdgeType("et5"); + auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; auto res = acc.DeleteEdge(&edge); @@ -2511,7 +2737,7 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } @@ -2522,17 +2748,19 @@ TEST(StorageV2, EdgeDeleteFromSameAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex); ASSERT_EQ(e.ToVertex(), *vertex); } ASSERT_EQ(vertex->OutEdges({}, storage::View::NEW)->size(), 0); + auto other_et = acc.NameToEdgeType("other"); + // Check edges with filters - ASSERT_EQ(vertex->InEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->InEdges({2, 5}, storage::View::OLD)->size(), 1); - ASSERT_EQ(vertex->OutEdges({2}, storage::View::OLD)->size(), 0); - ASSERT_EQ(vertex->OutEdges({2, 5}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->InEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->InEdges({et, other_et}, storage::View::OLD)->size(), 1); + ASSERT_EQ(vertex->OutEdges({other_et}, storage::View::OLD)->size(), 0); + ASSERT_EQ(vertex->OutEdges({et, other_et}, storage::View::OLD)->size(), 1); acc.Commit(); } @@ -2567,10 +2795,12 @@ TEST(StorageV2, VertexDetachDeleteSingleCommit) { auto vertex_from = acc.CreateVertex(); auto vertex_to = acc.CreateVertex(); - auto res = acc.CreateEdge(&vertex_from, &vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&vertex_from, &vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), vertex_from); ASSERT_EQ(edge.ToVertex(), vertex_to); @@ -2585,7 +2815,7 @@ TEST(StorageV2, VertexDetachDeleteSingleCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), vertex_from); ASSERT_EQ(e.ToVertex(), vertex_to); } @@ -2595,7 +2825,7 @@ TEST(StorageV2, VertexDetachDeleteSingleCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), vertex_from); ASSERT_EQ(e.ToVertex(), vertex_to); } @@ -2612,6 +2842,8 @@ TEST(StorageV2, VertexDetachDeleteSingleCommit) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Delete must fail { auto ret = acc.DeleteVertex(&*vertex_from); @@ -2636,7 +2868,7 @@ TEST(StorageV2, VertexDetachDeleteSingleCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2648,7 +2880,7 @@ TEST(StorageV2, VertexDetachDeleteSingleCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -2692,31 +2924,36 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { gid_vertex1 = vertex1.Gid(); gid_vertex2 = vertex2.Gid(); - auto res1 = acc.CreateEdge(&vertex1, &vertex2, 10); + auto et1 = acc.NameToEdgeType("et1"); + auto et2 = acc.NameToEdgeType("et2"); + auto et3 = acc.NameToEdgeType("et3"); + auto et4 = acc.NameToEdgeType("et4"); + + auto res1 = acc.CreateEdge(&vertex1, &vertex2, et1); ASSERT_TRUE(res1.HasValue()); auto edge1 = res1.GetValue(); - ASSERT_EQ(edge1.EdgeType(), 10); + ASSERT_EQ(edge1.EdgeType(), et1); ASSERT_EQ(edge1.FromVertex(), vertex1); ASSERT_EQ(edge1.ToVertex(), vertex2); - auto res2 = acc.CreateEdge(&vertex2, &vertex1, 20); + auto res2 = acc.CreateEdge(&vertex2, &vertex1, et2); ASSERT_TRUE(res2.HasValue()); auto edge2 = res2.GetValue(); - ASSERT_EQ(edge2.EdgeType(), 20); + ASSERT_EQ(edge2.EdgeType(), et2); ASSERT_EQ(edge2.FromVertex(), vertex2); ASSERT_EQ(edge2.ToVertex(), vertex1); - auto res3 = acc.CreateEdge(&vertex1, &vertex1, 30); + auto res3 = acc.CreateEdge(&vertex1, &vertex1, et3); ASSERT_TRUE(res3.HasValue()); auto edge3 = res3.GetValue(); - ASSERT_EQ(edge3.EdgeType(), 30); + ASSERT_EQ(edge3.EdgeType(), et3); ASSERT_EQ(edge3.FromVertex(), vertex1); ASSERT_EQ(edge3.ToVertex(), vertex1); - auto res4 = acc.CreateEdge(&vertex2, &vertex2, 40); + auto res4 = acc.CreateEdge(&vertex2, &vertex2, et4); ASSERT_TRUE(res4.HasValue()); auto edge4 = res4.GetValue(); - ASSERT_EQ(edge4.EdgeType(), 40); + ASSERT_EQ(edge4.EdgeType(), et4); ASSERT_EQ(edge4.FromVertex(), vertex2); ASSERT_EQ(edge4.ToVertex(), vertex2); @@ -2731,13 +2968,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), vertex2); ASSERT_EQ(e.ToVertex(), vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), vertex1); ASSERT_EQ(e.ToVertex(), vertex1); } @@ -2752,13 +2989,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), vertex1); ASSERT_EQ(e.ToVertex(), vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), vertex1); ASSERT_EQ(e.ToVertex(), vertex1); } @@ -2773,13 +3010,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), vertex1); ASSERT_EQ(e.ToVertex(), vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), vertex2); ASSERT_EQ(e.ToVertex(), vertex2); } @@ -2794,13 +3031,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), vertex2); ASSERT_EQ(e.ToVertex(), vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), vertex2); ASSERT_EQ(e.ToVertex(), vertex2); } @@ -2817,6 +3054,11 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { ASSERT_TRUE(vertex1); ASSERT_TRUE(vertex2); + auto et1 = acc.NameToEdgeType("et1"); + auto et2 = acc.NameToEdgeType("et2"); + auto et3 = acc.NameToEdgeType("et3"); + auto et4 = acc.NameToEdgeType("et4"); + // Delete must fail { auto ret = acc.DeleteVertex(&*vertex1); @@ -2842,13 +3084,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex1); } @@ -2865,13 +3107,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex1); } @@ -2888,13 +3130,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -2905,7 +3147,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -2919,13 +3161,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -2936,7 +3178,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -2952,6 +3194,8 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { ASSERT_FALSE(vertex1); ASSERT_TRUE(vertex2); + auto et4 = acc.NameToEdgeType("et4"); + // Check edges { auto ret = vertex2->InEdges({}, storage::View::OLD); @@ -2959,7 +3203,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -2969,7 +3213,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -2979,7 +3223,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -2989,7 +3233,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleCommit) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3010,10 +3254,12 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { auto vertex_from = acc.CreateVertex(); auto vertex_to = acc.CreateVertex(); - auto res = acc.CreateEdge(&vertex_from, &vertex_to, 5); + auto et = acc.NameToEdgeType("et5"); + + auto res = acc.CreateEdge(&vertex_from, &vertex_to, et); ASSERT_TRUE(res.HasValue()); auto edge = res.GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), vertex_from); ASSERT_EQ(edge.ToVertex(), vertex_to); @@ -3028,7 +3274,7 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), vertex_from); ASSERT_EQ(e.ToVertex(), vertex_to); } @@ -3038,7 +3284,7 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), vertex_from); ASSERT_EQ(e.ToVertex(), vertex_to); } @@ -3055,6 +3301,8 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Delete must fail { auto ret = acc.DeleteVertex(&*vertex_from); @@ -3079,7 +3327,7 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -3091,7 +3339,7 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -3110,6 +3358,8 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Check edges ASSERT_EQ(vertex_from->InEdges({}, storage::View::NEW)->size(), 0); { @@ -3118,7 +3368,7 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -3128,7 +3378,7 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -3145,6 +3395,8 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { ASSERT_TRUE(vertex_from); ASSERT_TRUE(vertex_to); + auto et = acc.NameToEdgeType("et5"); + // Delete must fail { auto ret = acc.DeleteVertex(&*vertex_from); @@ -3169,7 +3421,7 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -3181,7 +3433,7 @@ TEST(StorageV2, VertexDetachDeleteSingleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 5); + ASSERT_EQ(e.EdgeType(), et); ASSERT_EQ(e.FromVertex(), *vertex_from); ASSERT_EQ(e.ToVertex(), *vertex_to); } @@ -3225,31 +3477,36 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { gid_vertex1 = vertex1.Gid(); gid_vertex2 = vertex2.Gid(); - auto res1 = acc.CreateEdge(&vertex1, &vertex2, 10); + auto et1 = acc.NameToEdgeType("et1"); + auto et2 = acc.NameToEdgeType("et2"); + auto et3 = acc.NameToEdgeType("et3"); + auto et4 = acc.NameToEdgeType("et4"); + + auto res1 = acc.CreateEdge(&vertex1, &vertex2, et1); ASSERT_TRUE(res1.HasValue()); auto edge1 = res1.GetValue(); - ASSERT_EQ(edge1.EdgeType(), 10); + ASSERT_EQ(edge1.EdgeType(), et1); ASSERT_EQ(edge1.FromVertex(), vertex1); ASSERT_EQ(edge1.ToVertex(), vertex2); - auto res2 = acc.CreateEdge(&vertex2, &vertex1, 20); + auto res2 = acc.CreateEdge(&vertex2, &vertex1, et2); ASSERT_TRUE(res2.HasValue()); auto edge2 = res2.GetValue(); - ASSERT_EQ(edge2.EdgeType(), 20); + ASSERT_EQ(edge2.EdgeType(), et2); ASSERT_EQ(edge2.FromVertex(), vertex2); ASSERT_EQ(edge2.ToVertex(), vertex1); - auto res3 = acc.CreateEdge(&vertex1, &vertex1, 30); + auto res3 = acc.CreateEdge(&vertex1, &vertex1, et3); ASSERT_TRUE(res3.HasValue()); auto edge3 = res3.GetValue(); - ASSERT_EQ(edge3.EdgeType(), 30); + ASSERT_EQ(edge3.EdgeType(), et3); ASSERT_EQ(edge3.FromVertex(), vertex1); ASSERT_EQ(edge3.ToVertex(), vertex1); - auto res4 = acc.CreateEdge(&vertex2, &vertex2, 40); + auto res4 = acc.CreateEdge(&vertex2, &vertex2, et4); ASSERT_TRUE(res4.HasValue()); auto edge4 = res4.GetValue(); - ASSERT_EQ(edge4.EdgeType(), 40); + ASSERT_EQ(edge4.EdgeType(), et4); ASSERT_EQ(edge4.FromVertex(), vertex2); ASSERT_EQ(edge4.ToVertex(), vertex2); @@ -3264,13 +3521,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), vertex2); ASSERT_EQ(e.ToVertex(), vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), vertex1); ASSERT_EQ(e.ToVertex(), vertex1); } @@ -3285,13 +3542,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), vertex1); ASSERT_EQ(e.ToVertex(), vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), vertex1); ASSERT_EQ(e.ToVertex(), vertex1); } @@ -3306,13 +3563,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), vertex1); ASSERT_EQ(e.ToVertex(), vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), vertex2); ASSERT_EQ(e.ToVertex(), vertex2); } @@ -3327,13 +3584,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), vertex2); ASSERT_EQ(e.ToVertex(), vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), vertex2); ASSERT_EQ(e.ToVertex(), vertex2); } @@ -3350,6 +3607,11 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_TRUE(vertex1); ASSERT_TRUE(vertex2); + auto et1 = acc.NameToEdgeType("et1"); + auto et2 = acc.NameToEdgeType("et2"); + auto et3 = acc.NameToEdgeType("et3"); + auto et4 = acc.NameToEdgeType("et4"); + // Delete must fail { auto ret = acc.DeleteVertex(&*vertex1); @@ -3375,13 +3637,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex1); } @@ -3398,13 +3660,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex1); } @@ -3421,13 +3683,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3438,7 +3700,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3452,13 +3714,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3469,7 +3731,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3485,6 +3747,11 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_TRUE(vertex1); ASSERT_TRUE(vertex2); + auto et1 = acc.NameToEdgeType("et1"); + auto et2 = acc.NameToEdgeType("et2"); + auto et3 = acc.NameToEdgeType("et3"); + auto et4 = acc.NameToEdgeType("et4"); + // Check edges { auto ret = vertex1->InEdges({}, storage::View::OLD); @@ -3496,13 +3763,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex1); } @@ -3517,13 +3784,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex1); } @@ -3538,13 +3805,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex1); } @@ -3559,13 +3826,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex1); } @@ -3580,13 +3847,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3601,13 +3868,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3622,13 +3889,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3643,13 +3910,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3666,6 +3933,11 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_TRUE(vertex1); ASSERT_TRUE(vertex2); + auto et1 = acc.NameToEdgeType("et1"); + auto et2 = acc.NameToEdgeType("et2"); + auto et3 = acc.NameToEdgeType("et3"); + auto et4 = acc.NameToEdgeType("et4"); + // Delete must fail { auto ret = acc.DeleteVertex(&*vertex1); @@ -3691,13 +3963,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex1); } @@ -3714,13 +3986,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 30); + ASSERT_EQ(e.EdgeType(), et3); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex1); } @@ -3737,13 +4009,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 10); + ASSERT_EQ(e.EdgeType(), et1); ASSERT_EQ(e.FromVertex(), *vertex1); ASSERT_EQ(e.ToVertex(), *vertex2); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3754,7 +4026,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3768,13 +4040,13 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_EQ(edges.size(), 2); { auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 20); + ASSERT_EQ(e.EdgeType(), et2); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex1); } { auto e = edges[1]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3785,7 +4057,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3801,6 +4073,8 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { ASSERT_FALSE(vertex1); ASSERT_TRUE(vertex2); + auto et4 = acc.NameToEdgeType("et4"); + // Check edges { auto ret = vertex2->InEdges({}, storage::View::OLD); @@ -3808,7 +4082,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3818,7 +4092,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3828,7 +4102,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3838,7 +4112,7 @@ TEST(StorageV2, VertexDetachDeleteMultipleAbort) { auto edges = ret.GetValue(); ASSERT_EQ(edges.size(), 1); auto e = edges[0]; - ASSERT_EQ(e.EdgeType(), 40); + ASSERT_EQ(e.EdgeType(), et4); ASSERT_EQ(e.FromVertex(), *vertex2); ASSERT_EQ(e.ToVertex(), *vertex2); } @@ -3854,40 +4128,44 @@ TEST(StorageV2, EdgePropertyCommit) { auto acc = store.Access(); auto vertex = acc.CreateVertex(); gid = vertex.Gid(); - auto edge = acc.CreateEdge(&vertex, &vertex, 5).GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + auto et = acc.NameToEdgeType("et5"); + auto edge = acc.CreateEdge(&vertex, &vertex, et).GetValue(); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), vertex); ASSERT_EQ(edge.ToVertex(), vertex); - ASSERT_TRUE(edge.GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); { - auto res = edge.SetProperty(5, storage::PropertyValue("temporary")); + auto res = + edge.SetProperty(property, storage::PropertyValue("temporary")); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } - ASSERT_EQ(edge.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "temporary"); + ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto res = edge.SetProperty(5, storage::PropertyValue("nandare")); + auto res = edge.SetProperty(property, storage::PropertyValue("nandare")); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(edge.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } acc.Commit(); @@ -3898,24 +4176,28 @@ TEST(StorageV2, EdgePropertyCommit) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_EQ(edge.GetProperty(5, storage::View::OLD)->ValueString(), + auto property = acc.NameToProperty("property5"); + + ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(edge.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(edge.GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -3925,25 +4207,27 @@ TEST(StorageV2, EdgePropertyCommit) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; + auto property = acc.NameToProperty("property5"); + { - auto res = edge.SetProperty(5, storage::PropertyValue()); + auto res = edge.SetProperty(property, storage::PropertyValue()); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(edge.GetProperty(5, storage::View::OLD)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(edge.GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); { - auto res = edge.SetProperty(5, storage::PropertyValue()); + auto res = edge.SetProperty(property, storage::PropertyValue()); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } @@ -3956,13 +4240,17 @@ TEST(StorageV2, EdgePropertyCommit) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_TRUE(edge.GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(edge.GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); - ASSERT_TRUE(edge.GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -3979,8 +4267,9 @@ TEST(StorageV2, EdgePropertyAbort) { auto acc = store.Access(); auto vertex = acc.CreateVertex(); gid = vertex.Gid(); - auto edge = acc.CreateEdge(&vertex, &vertex, 5).GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + auto et = acc.NameToEdgeType("et5"); + auto edge = acc.CreateEdge(&vertex, &vertex, et).GetValue(); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), vertex); ASSERT_EQ(edge.ToVertex(), vertex); acc.Commit(); @@ -3993,35 +4282,38 @@ TEST(StorageV2, EdgePropertyAbort) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_TRUE(edge.GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); { - auto res = edge.SetProperty(5, storage::PropertyValue("temporary")); + auto res = + edge.SetProperty(property, storage::PropertyValue("temporary")); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } - ASSERT_EQ(edge.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "temporary"); + ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto res = edge.SetProperty(5, storage::PropertyValue("nandare")); + auto res = edge.SetProperty(property, storage::PropertyValue("nandare")); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(edge.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } acc.Abort(); @@ -4034,13 +4326,17 @@ TEST(StorageV2, EdgePropertyAbort) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_TRUE(edge.GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(edge.GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); - ASSERT_TRUE(edge.GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -4052,35 +4348,38 @@ TEST(StorageV2, EdgePropertyAbort) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_TRUE(edge.GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); { - auto res = edge.SetProperty(5, storage::PropertyValue("temporary")); + auto res = + edge.SetProperty(property, storage::PropertyValue("temporary")); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } - ASSERT_EQ(edge.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "temporary"); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "temporary"); + ASSERT_EQ(properties[property].ValueString(), "temporary"); } { - auto res = edge.SetProperty(5, storage::PropertyValue("nandare")); + auto res = edge.SetProperty(property, storage::PropertyValue("nandare")); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(edge.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } acc.Commit(); @@ -4093,24 +4392,28 @@ TEST(StorageV2, EdgePropertyAbort) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_EQ(edge.GetProperty(5, storage::View::OLD)->ValueString(), + auto property = acc.NameToProperty("property5"); + + ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(edge.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(edge.GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -4122,37 +4425,39 @@ TEST(StorageV2, EdgePropertyAbort) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_EQ(edge.GetProperty(5, storage::View::OLD)->ValueString(), + auto property = acc.NameToProperty("property5"); + + ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(edge.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } { - auto res = edge.SetProperty(5, storage::PropertyValue()); + auto res = edge.SetProperty(property, storage::PropertyValue()); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(edge.GetProperty(5, storage::View::OLD)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(edge.GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); acc.Abort(); @@ -4165,24 +4470,28 @@ TEST(StorageV2, EdgePropertyAbort) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_EQ(edge.GetProperty(5, storage::View::OLD)->ValueString(), + auto property = acc.NameToProperty("property5"); + + ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(edge.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(edge.GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -4194,37 +4503,39 @@ TEST(StorageV2, EdgePropertyAbort) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_EQ(edge.GetProperty(5, storage::View::OLD)->ValueString(), + auto property = acc.NameToProperty("property5"); + + ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_EQ(edge.GetProperty(5, storage::View::NEW)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::NEW)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } { - auto res = edge.SetProperty(5, storage::PropertyValue()); + auto res = edge.SetProperty(property, storage::PropertyValue()); ASSERT_TRUE(res.HasValue()); ASSERT_TRUE(res.GetValue()); } - ASSERT_EQ(edge.GetProperty(5, storage::View::OLD)->ValueString(), + ASSERT_EQ(edge.GetProperty(property, storage::View::OLD)->ValueString(), "nandare"); { auto properties = edge.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[5].ValueString(), "nandare"); + ASSERT_EQ(properties[property].ValueString(), "nandare"); } - ASSERT_TRUE(edge.GetProperty(5, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); acc.Commit(); @@ -4237,13 +4548,17 @@ TEST(StorageV2, EdgePropertyAbort) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_TRUE(edge.GetProperty(5, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(5, storage::View::NEW)->IsNull()); + auto property = acc.NameToProperty("property5"); + + ASSERT_TRUE(edge.GetProperty(property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); - ASSERT_TRUE(edge.GetProperty(10, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(10, storage::View::NEW)->IsNull()); + auto other_property = acc.NameToProperty("other"); + + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(other_property, storage::View::NEW)->IsNull()); acc.Abort(); } @@ -4258,8 +4573,9 @@ TEST(StorageV2, EdgePropertySerializationError) { auto acc = store.Access(); auto vertex = acc.CreateVertex(); gid = vertex.Gid(); - auto edge = acc.CreateEdge(&vertex, &vertex, 5).GetValue(); - ASSERT_EQ(edge.EdgeType(), 5); + auto et = acc.NameToEdgeType("et5"); + auto edge = acc.CreateEdge(&vertex, &vertex, et).GetValue(); + ASSERT_EQ(edge.EdgeType(), et); ASSERT_EQ(edge.FromVertex(), vertex); ASSERT_EQ(edge.ToVertex(), vertex); acc.Commit(); @@ -4274,28 +4590,31 @@ TEST(StorageV2, EdgePropertySerializationError) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_TRUE(edge.GetProperty(1, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(edge.GetProperty(2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(2, storage::View::NEW)->IsNull()); + auto property1 = acc1.NameToProperty("property1"); + auto property2 = acc1.NameToProperty("property2"); + + ASSERT_TRUE(edge.GetProperty(property1, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property1, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); { - auto res = edge.SetProperty(1, storage::PropertyValue(123)); + auto res = edge.SetProperty(property1, storage::PropertyValue(123)); ASSERT_TRUE(res.HasValue()); ASSERT_FALSE(res.GetValue()); } - ASSERT_TRUE(edge.GetProperty(1, storage::View::OLD)->IsNull()); - ASSERT_EQ(edge.GetProperty(1, storage::View::NEW)->ValueInt(), 123); - ASSERT_TRUE(edge.GetProperty(2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(2, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property1, storage::View::OLD)->IsNull()); + ASSERT_EQ(edge.GetProperty(property1, storage::View::NEW)->ValueInt(), 123); + ASSERT_TRUE(edge.GetProperty(property2, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[1].ValueInt(), 123); + ASSERT_EQ(properties[property1].ValueInt(), 123); } } @@ -4305,15 +4624,18 @@ TEST(StorageV2, EdgePropertySerializationError) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_TRUE(edge.GetProperty(1, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(1, storage::View::NEW)->IsNull()); - ASSERT_TRUE(edge.GetProperty(2, storage::View::OLD)->IsNull()); - ASSERT_TRUE(edge.GetProperty(2, storage::View::NEW)->IsNull()); + auto property1 = acc2.NameToProperty("property1"); + auto property2 = acc2.NameToProperty("property2"); + + ASSERT_TRUE(edge.GetProperty(property1, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property1, storage::View::NEW)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, storage::View::OLD)->IsNull()); + ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); ASSERT_EQ(edge.Properties(storage::View::OLD)->size(), 0); ASSERT_EQ(edge.Properties(storage::View::NEW)->size(), 0); { - auto res = edge.SetProperty(2, storage::PropertyValue("nandare")); + auto res = edge.SetProperty(property2, storage::PropertyValue("nandare")); ASSERT_TRUE(res.HasError()); ASSERT_EQ(res.GetError(), storage::Error::SERIALIZATION_ERROR); } @@ -4330,20 +4652,23 @@ TEST(StorageV2, EdgePropertySerializationError) { ASSERT_TRUE(vertex); auto edge = vertex->OutEdges({}, storage::View::NEW).GetValue()[0]; - ASSERT_EQ(edge.GetProperty(1, storage::View::OLD)->ValueInt(), 123); - ASSERT_TRUE(edge.GetProperty(2, storage::View::OLD)->IsNull()); + auto property1 = acc.NameToProperty("property1"); + auto property2 = acc.NameToProperty("property2"); + + ASSERT_EQ(edge.GetProperty(property1, storage::View::OLD)->ValueInt(), 123); + ASSERT_TRUE(edge.GetProperty(property2, storage::View::OLD)->IsNull()); { auto properties = edge.Properties(storage::View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[1].ValueInt(), 123); + ASSERT_EQ(properties[property1].ValueInt(), 123); } - ASSERT_EQ(edge.GetProperty(1, storage::View::NEW)->ValueInt(), 123); - ASSERT_TRUE(edge.GetProperty(2, storage::View::NEW)->IsNull()); + ASSERT_EQ(edge.GetProperty(property1, storage::View::NEW)->ValueInt(), 123); + ASSERT_TRUE(edge.GetProperty(property2, storage::View::NEW)->IsNull()); { auto properties = edge.Properties(storage::View::NEW).GetValue(); ASSERT_EQ(properties.size(), 1); - ASSERT_EQ(properties[1].ValueInt(), 123); + ASSERT_EQ(properties[property1].ValueInt(), 123); } acc.Abort(); diff --git a/tests/unit/storage_v2_gc.cpp b/tests/unit/storage_v2_gc.cpp index e6837c749..b2de1ec04 100644 --- a/tests/unit/storage_v2_gc.cpp +++ b/tests/unit/storage_v2_gc.cpp @@ -57,9 +57,12 @@ TEST(StorageV2Gc, Sanity) { EXPECT_EQ(vertex.has_value(), i % 5 != 0); if (vertex.has_value()) { - EXPECT_FALSE(vertex->AddLabel(3 * i).HasError()); - EXPECT_FALSE(vertex->AddLabel(3 * i + 1).HasError()); - EXPECT_FALSE(vertex->AddLabel(3 * i + 2).HasError()); + EXPECT_FALSE( + vertex->AddLabel(storage::LabelId::FromUint(3 * i)).HasError()); + EXPECT_FALSE( + vertex->AddLabel(storage::LabelId::FromUint(3 * i + 1)).HasError()); + EXPECT_FALSE( + vertex->AddLabel(storage::LabelId::FromUint(3 * i + 2)).HasError()); } } @@ -78,8 +81,11 @@ TEST(StorageV2Gc, Sanity) { auto labels_new = vertex->Labels(storage::View::NEW); EXPECT_TRUE(labels_new.HasValue()); - EXPECT_THAT(labels_new.GetValue(), - UnorderedElementsAre(3 * i, 3 * i + 1, 3 * i + 2)); + EXPECT_THAT( + labels_new.GetValue(), + UnorderedElementsAre(storage::LabelId::FromUint(3 * i), + storage::LabelId::FromUint(3 * i + 1), + storage::LabelId::FromUint(3 * i + 2))); } } @@ -97,7 +103,8 @@ TEST(StorageV2Gc, Sanity) { EXPECT_EQ(to_vertex.has_value(), (i + 1) % 5 != 0); if (from_vertex.has_value() && to_vertex.has_value()) { - EXPECT_FALSE(acc.CreateEdge(&from_vertex.value(), &to_vertex.value(), i) + EXPECT_FALSE(acc.CreateEdge(&from_vertex.value(), &to_vertex.value(), + storage::EdgeTypeId::FromUint(i)) .HasError()); } } @@ -121,20 +128,19 @@ TEST(StorageV2Gc, Sanity) { auto vertex = acc.FindVertex(vertices[i], storage::View::NEW); EXPECT_EQ(vertex.has_value(), i % 5 != 0 && i % 3 != 0); if (vertex.has_value()) { - auto out_edges = - vertex->OutEdges(std::vector{}, storage::View::NEW); + auto out_edges = vertex->OutEdges({}, storage::View::NEW); if (i % 5 != 4 && i % 3 != 2) { EXPECT_EQ(out_edges.GetValue().size(), 1); - EXPECT_EQ(out_edges.GetValue().at(0).EdgeType(), i); + EXPECT_EQ(out_edges.GetValue().at(0).EdgeType().AsUint(), i); } else { EXPECT_TRUE(out_edges->empty()); } - auto in_edges = - vertex->InEdges(std::vector{}, storage::View::NEW); + auto in_edges = vertex->InEdges({}, storage::View::NEW); if (i % 5 != 1 && i % 3 != 1) { EXPECT_EQ(in_edges.GetValue().size(), 1); - EXPECT_EQ(in_edges.GetValue().at(0).EdgeType(), (i + 999) % 1000); + EXPECT_EQ(in_edges.GetValue().at(0).EdgeType().AsUint(), + (i + 999) % 1000); } else { EXPECT_TRUE(in_edges->empty()); }