OGraphBatchInsert class question

67 views
Skip to first unread message

Emin Agassi

unread,
Dec 11, 2014, 10:09:22 AM12/11/14
to orient-...@googlegroups.com
Hi Luca,

The OGraphBatchInsert class contains a createEdge method which does not allow to create an Edge with a default label set.
Is there a method to provide a default label for the E edges?

I do not want to create any additional properties on the Edges that I am creating.
Default labels on the Edges allows very easy edge traversals.

Thanks

Emin Agassi

unread,
Dec 11, 2014, 9:52:07 PM12/11/14
to orient-...@googlegroups.com

 I found a setEdgeClass method in the OGraphBatchInsert class which allows to set the class name for all edges.However, I need to be able to set different classes for different edges.
 I am passing a @class property to the addEdge method but this does not work.
 Can anyone help?

Luca Garulli

unread,
Dec 12, 2014, 5:45:31 AM12/12/14
to orient-database
Hi Emin,
That API is quite raw. I know Luigi is working to extend it, but this is not a so high priority now (we're under release of 2.0rc1).

Please could you open a new issue on that?

Lvc@


--

---
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.

Emin Agassi

unread,
Dec 12, 2014, 9:05:55 AM12/12/14
to orient-...@googlegroups.com
 Luca

 Thanks. I wonder if I can quickly patch up that class to do what I need it to do. Not sure how long it will take for you guys to get to this.
 I actually was able to pass in the @class property and it does create Edges using the passed in classes But it does not create lightweight edges and so they do not have Labels associated with them.
 Interestingly, without labels it is not easy to traverse the Edges. I did not realize this before. The lightweight edges are much faster and easier to traverse. In fact, I am finding that the SQL syntax such as:

  out('xxxx')

only works when Edges have class labels which I think it only happens with lightweight edges.
Surely, I can use the following SQL to traverse:

select expand(in) from ( traverse * from #10:0) where @class='isA'

But the above is not as efficient as:

traverse out('isA') from #10:0

I am still a bit confused by how the BatchInser works. When I create an edge which extends the E using the SQL and with properties, it creates the new Edge and it has a label.
But when BatchInsert creates the edge with the class, it does not get a Label. Can you point me to what might be the problem?
here is the code that creates the Edge in the
OGraphBatchInsert class:


public void createEdge(final Long from, final Long to, Map<String, Object> properties) {
if (settingProperties) {
throw new IllegalStateException("Cannot create new edges when already set properties on vertices");
}
if (from < 0) {
throw new IllegalArgumentException(" Invalid vertex id: " + from);
}
if (to < 0) {
throw new IllegalArgumentException(" Invalid vertex id: " + to);
}
if (useLightWeigthEdges && (properties == null || properties.size() == 0)) {
last = last < from ? from : last;
last = last < to ? to : last;
putInList(from, out, to);
putInList(to, in, from);
} else {
ODocument edgeDoc = new ODocument(edgeClass);

edgeDoc.fromMap(properties);
edgeDoc.field("out", new ORecordId(getClusterId(from), getClusterPosition(from)));
edgeDoc.field("in", new ORecordId(getClusterId(to), getClusterPosition(to)));
db.save(edgeDoc);
ORecordId rid = (ORecordId) edgeDoc.getIdentity();
putInList(from, out, rid);
putInList(to, in, rid);
}
}

How do I open the issue? Where do I go for this?

Emin Agassi

unread,
Dec 12, 2014, 9:50:19 AM12/12/14
to orient-...@googlegroups.com
Luca

Just to clarify a bit. I like the new BatchInsert class because it is much faster than Blueprints version. My very big graph (1.5 million vertexes and 3+ million edges) load in minutes.
However, this class creates Edges that all end up being in one big OUT or IN collection. Filtering edges in these collections while traversing a graph is not very simple.
In a normal case when edges are created using SQL or Blueprints API, all edges end up being named fields in the OUT or IN collections. This makes it easy to write traversal SQL using the out('isA') or in('SAMEAS')
syntax. Do you know any other method to efficiently filter Edges in the OUT and IN collections in a given Vertex without having explicit names. Each of my edges have a property.

Thanks for help!

Emin Agassi

unread,
Dec 12, 2014, 10:41:58 AM12/12/14
to orient-...@googlegroups.com

 I think I know what is going on in this code. Basically, this class links all Edges to a given Vertex using either IN and OUT properties or only one specified Edge Class name. So, all edges end up being linked to only one property.
That property ends up having a large collection of edges. In my case this collection must be filtered when traversing happens but this is not possible.
The only method I found was to traverse all and then filter by @class but that does not work for all use cases.
Hmmm. Blueprints Graph Api is much more versatile in this respect.

Emin Agassi

unread,
Dec 12, 2014, 3:31:48 PM12/12/14
to orient-...@googlegroups.com
 Hi Luca
 I quickly modified OGraphBatchInsert class and added a support for multiple Edge class names. Now, I can see my Edges in the proper fields of a given Vortex.
 Would you tell me where is the latest version of this Java code? I am not sure if I got the latest.

 Also, I randomly get Timer exceptions and database seem to close. Why is this ?

Luca Garulli

unread,
Dec 13, 2014, 3:25:37 PM12/13/14
to orient-database
Hi Emin,
Awesome. Would you like to send a Pull Request against the "develop" branch (latest)?


Lvc@

Reply all
Reply to author
Forward
0 new messages