Bolt encoder

This commit is contained in:
Andi Skrgat
2023-05-15 15:50:21 +02:00
parent c88fba3322
commit 4b063fc457

View File

@@ -184,44 +184,44 @@ TEST_F(BoltEncoder, VertexAndEdge) {
auto va2 = dba->CreateVertex();
auto l1 = dba->NameToLabel("label1");
auto l2 = dba->NameToLabel("label2");
ASSERT_TRUE(va1->AddLabel(l1).HasValue());
ASSERT_TRUE(va1->AddLabel(l2).HasValue());
ASSERT_TRUE(va1.AddLabel(l1).HasValue());
ASSERT_TRUE(va1.AddLabel(l2).HasValue());
auto p1 = dba->NameToProperty("prop1");
auto p2 = dba->NameToProperty("prop2");
memgraph::storage::PropertyValue pv1(12), pv2(200);
ASSERT_TRUE(va1->SetProperty(p1, pv1).HasValue());
ASSERT_TRUE(va1->SetProperty(p2, pv2).HasValue());
ASSERT_TRUE(va1.SetProperty(p1, pv1).HasValue());
ASSERT_TRUE(va1.SetProperty(p2, pv2).HasValue());
// create edge
auto et = dba->NameToEdgeType("edgetype");
auto ea = dba->CreateEdge(va1.get(), va2.get(), et).GetValue();
auto ea = dba->CreateEdge(&va1, &va2, et).GetValue();
auto p3 = dba->NameToProperty("prop3");
auto p4 = dba->NameToProperty("prop4");
memgraph::storage::PropertyValue pv3(42), pv4(1234);
ASSERT_TRUE(ea->SetProperty(p3, pv3).HasValue());
ASSERT_TRUE(ea->SetProperty(p4, pv4).HasValue());
ASSERT_TRUE(ea.SetProperty(p3, pv3).HasValue());
ASSERT_TRUE(ea.SetProperty(p4, pv4).HasValue());
// check everything
std::vector<Value> vals;
vals.push_back(*memgraph::glue::ToBoltValue(memgraph::query::TypedValue(memgraph::query::VertexAccessor(va1->Copy())),
*db, memgraph::storage::View::NEW));
vals.push_back(*memgraph::glue::ToBoltValue(memgraph::query::TypedValue(memgraph::query::VertexAccessor(va2->Copy())),
*db, memgraph::storage::View::NEW));
vals.push_back(*memgraph::glue::ToBoltValue(memgraph::query::TypedValue(memgraph::query::EdgeAccessor(ea->Copy())),
*db, memgraph::storage::View::NEW));
vals.push_back(*memgraph::glue::ToBoltValue(memgraph::query::TypedValue(memgraph::query::VertexAccessor(va1)), *db,
memgraph::storage::View::NEW));
vals.push_back(*memgraph::glue::ToBoltValue(memgraph::query::TypedValue(memgraph::query::VertexAccessor(va2)), *db,
memgraph::storage::View::NEW));
vals.push_back(*memgraph::glue::ToBoltValue(memgraph::query::TypedValue(memgraph::query::EdgeAccessor(ea)), *db,
memgraph::storage::View::NEW));
bolt_encoder.MessageRecord(vals);
// The vertexedge_encoded testdata has hardcoded zeros for IDs,
// and Memgraph now encodes IDs so we need to check the output
// part by part.
CheckOutput(output, vertexedge_encoded, 5, false);
CheckInt(output, va1->Gid().AsInt());
CheckInt(output, va1.Gid().AsInt());
CheckOutput(output, vertexedge_encoded + 6, 34, false);
CheckInt(output, va2->Gid().AsInt());
CheckInt(output, va2.Gid().AsInt());
CheckOutput(output, vertexedge_encoded + 41, 4, false);
CheckInt(output, ea->Gid().AsInt());
CheckInt(output, va1->Gid().AsInt());
CheckInt(output, va2->Gid().AsInt());
CheckInt(output, ea.Gid().AsInt());
CheckInt(output, va1.Gid().AsInt());
CheckInt(output, va2.Gid().AsInt());
CheckOutput(output, vertexedge_encoded + 48, 26);
}