orientechnologies / OrientDB-NET.binary

C#/.NET binary driver for OrientDB
MIT License
93 stars 59 forks source link

hanging when creating edge with useLightweightEdges enabled #166

Open DarrenLamb opened 5 years ago

DarrenLamb commented 5 years ago

I'm new to OrientDb (and noSQL databases in general) and have put together a small application to model "friend" relationships.

The "FriendOf" edge is ideally just a link between two Person vertices, I had read in the documentation that the use of lightweight edges may increase performance. The below code works fine when lightweight edges are disabled. However, when enabling them the line to create the edge hangs.

Am I missing something?

public static void EnableLightweightEdges(ODatabase orient)
{
  orient.Command("ALTER DATABASE custom useLightweightEdges=true");
}

public static void DisableLightweightEdges(ODatabase orient)
{
   orient.Command("ALTER DATABASE custom useLightweightEdges=false");
}

public ODatabase Connect()
{
   return new ODatabase(_connectionOptions);
}

public void EnsureCreated()
{
   using (var orient = Connect())
   {
       DisableLightweightEdges(orient);
       if (!orient.Schema.IsClassExist<Person>())
       {
           orient.Create.Class<Person>().Extends<OVertex>().CreateProperties().Run();
       }

       if (!orient.Schema.IsClassExist("FriendOf"))
       {
           orient.Create.Class("FriendOf").Extends<OEdge>().Run();
       }
       CreatePeople(orient);
   }
}

private static void CreatePeople(ODatabase orient)
{         
   // Clear existing data
   orient.Delete.Edge("FriendOf").Run();
   orient.Delete.Vertex<Person>().Run();

   var person1 = new Person {Id = Guid.Parse("199a5b7a-b4fe-4927-901b-d5b5d2226045"), Name = "Person1"};
   var person1Vertex = orient.Create.Vertex(person1).Run();

   var person2 = new Person {Id = Guid.Parse("5dee19d8-86f0-41a8-b2d8-62a77f80b6d1"), Name = "Person2"};
   var person2Vertex = orient.Create.Vertex(person2).Run();

   orient.Create.Edge("FriendOf").From(person1.ORID).To(person2.ORID).Run();
}