db.addEdge(...) and CREATE EDGE not equivalent?

60 views
Skip to first unread message

Harish

unread,
Oct 8, 2015, 5:33:13 PM10/8/15
to orient-...@googlegroups.com
Using orientdb-community-2.2-alpha.

We're using the following config for the graph database:

setUseClassForEdgeLabel(false);
setUseVertexFieldsForEdgeLabels(true);

We use this particular configuration because our edge labels are generally not statically defined, and the number of edge labels are dynamic and could be specified by the user resulting in a largish number of edge labels. As a result, it's not feasible for us to create an Edge class for each edge label. The configuration above allows us to use only a single Edge class (the default E) along with a large number of dynamically specified edge labels. 

We don't need to create any subclasses of E as we don't care about Edge class inheritance as such, and so the setUseClassForEdgeLabel(false); solution works well.

So as per the above, the following call creates the appropriate Edge

OrientEdge e = g.addEdge(null, outVertex, inVertex,  'someDynamicLabel');
e.setProperty('someProperty', 'val');

This works as expected and I can create a large number edges of the same edge class E but with different labels. This is important for us since we often have a large number of edges going out of a vertex, and the appropriate edge label significantly speeds up traversal since the edges are apparently partitioned by edge label and traversal does not seem to traverse any labels that are not specified in the traversal query.

Now for the question: In other contexts we would like to use the CREATE EDGE Sql command. I would expect that CREATE EDGE  is equivalent to g.addEdge(...), but there seems to be no way to use a label with edge class E in CREATE EDGE

So, for example, 

CREATE EDGE E set label = 'someDynamicLabel' doesn't work and throws an error. The error makes sense in that I should obviously not be able to set the label property manually since it is reserved by Orient.

However, it seems to me that there should be a way in CREATE EDGE to do what g.addEdge(...) above does. So perhaps, something like:

CREATE EDGE E LABEL = 'someDynamicLabel' SET someProperty = 'val' would probably do the trick.

P.S. If db.addEdge(...) and CREATE EDGE are not meant to be equivalent, it's not clear to me why that would be the case.

Thanks,
--Harish.



Luigi Dell'Aquila

unread,
Oct 9, 2015, 6:31:37 AM10/9/15
to orient-...@googlegroups.com
Hi Harish,

IMHO also CREATE EDGE should take into consideration that setting, so we can consider it a bug.
The syntax should remain the same:

CREATE EDGE someDynamicLabel FROM... TO...

just the engine should avoid to check edge class existence in case these flags are set.
Could you please open an issue about this?

Thanks

Luigi


2015-10-08 23:33 GMT+02:00 Harish <hre...@gmail.com>:
We're using the following config for the graph database:

setUseClassForEdgeLabel(false);
setUseVertexFieldsForEdgeLabels(true);

We use this particular configuration because our edge labels are generally not statically defined, and the number of edge labels are dynamic and could be specified by the user resulting in a largish number of edge labels. As a result, it's not feasible for us to create an Edge class for each edge label. The configuration above allows us to use only a single Edge class (the default E) along with a large number of dynamically specified edge labels. 

We don't need to create any subclasses of E as we don't care about Edge class inheritance as such, and so the setUseClassForEdgeLabel(false); solution works well.

So as per the above, the following call creates the appropriate Edge

OrientEdge e = g.addEdge(null, outVertex, inVertex,  'someDynamicLabel');
e.setProperty('someProperty', 'val');

This works as expected and I can create a large number edges of the same edge class E but with different labels. This is important for us since we often have a large number of edges going out of a vertex, and the appropriate edge label significantly speeds up traversal since the edges are apparently partitioned by edge label and traversal does not seem to traverse any labels that are not specified in the traversal query.

Now for the question: In other contexts we would like to the CREATE EDGE Sql command. I would expect that CREATE EDGE  is equivalent to g.addEdge(...), but there seems to be no way to use a label with edge class E in CREATE EDGE

So, for example, 

CREATE EDGE E set label = 'someDynamicLabel' doesn't work and throws an error. The error makes sense in that I should obviously not be able to set the label property manually since it is reserved by Orient.

However, it seems to me that there should be a way in CREATE EDGE to do what g.addEdge(...) above does. So perhaps, something like:

CREATE EDGE LABEL = 'someDynamicLabel' SET someProperty = 'val' would probably do the trick.

P.S. If db.addEdge(...) and CREATE EDGE are not meant to be equivalent, it's not clear to me why that would be the case.

Thanks,
--Harish.



--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luigi Dell'Aquila

unread,
Oct 9, 2015, 8:13:40 AM10/9/15
to orient-...@googlegroups.com
No problem, I did it for you:


Fixing it, I hope I'll be able to push the fix in a few hours

Thanks

Luigi

Luigi Dell'Aquila

unread,
Oct 9, 2015, 10:19:36 AM10/9/15
to orient-...@googlegroups.com
Done, you can find the fix on develop branch

Harish

unread,
Oct 9, 2015, 1:36:04 PM10/9/15
to OrientDB
Great! Thanks Luigi

--Harish.
Reply all
Reply to author
Forward
0 new messages