Edge's Label can not be null

155 views
Skip to first unread message

Serge Vilvovsky

unread,
Jun 6, 2016, 3:26:02 PM6/6/16
to Gremlin-users
Hi All,

I ran the next tinkerpop3 code:

     final Graph newGraph = TinkerGraph.open();

     newGraph.io(IoCore.graphml()).readGraph("example.xml");

And got the next exception on Edge: 

Exception in thread "main" java.lang.IllegalArgumentException: Label can not be null

at org.apache.tinkerpop.gremlin.structure.Element$Exceptions.labelCanNotBeNull(Element.java:137)

at org.apache.tinkerpop.gremlin.structure.util.ElementHelper.validateLabel(ElementHelper.java:62)

at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerHelper.addEdge(TinkerHelper.java:51)

at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex.addEdge(TinkerVertex.java:125)

at org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader.readGraph(GraphMLReader.java:190)

at org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo.readGraph(GraphMLIo.java:86)

at mycompany.main(App2.java:35)

If I add the label to the edge, everything works. 

My question is if there is any graphml or gremlin standard that requires to have a label. What is the motivation of this constrain? 

Thank you!

Message has been deleted

Serge Vilvovsky

unread,
Jun 6, 2016, 3:48:33 PM6/6/16
to Gremlin-users
If the standard does not require, is it any way to provide the default edge label for tinkerpop3 to avoid the exception? 

Marko Rodriguez

unread,
Jun 6, 2016, 3:57:41 PM6/6/16
to gremli...@googlegroups.com
Hello,

Edge.DEFAULT_LABEL

HTH,
Marko.

On Jun 6, 2016, at 1:48 PM, Serge Vilvovsky <serg...@gmail.com> wrote:

If the standard does not require, is it any way to provide the default edge label for tinkerpop3 to avoid the exception? 

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/20256666-377a-4eee-b3b8-c0482d2d6580%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Serge Vilvovsky

unread,
Jun 6, 2016, 4:04:05 PM6/6/16
to gremli...@googlegroups.com
Thank you. How should I use it with bellow API calls to not get an exception? 


final Graph newGraph = TinkerGraph.open();

     newGraph.io(IoCore.graphml()).readGraph("example.xml");

--
You received this message because you are subscribed to a topic in the Google Groups "Gremlin-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gremlin-users/56CI2PTWueg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/DAB90BED-B7EF-4F4C-A0E0-24A65737E338%40gmail.com.

Daniel Kuppitz

unread,
Jun 7, 2016, 4:49:50 AM6/7/16
to gremli...@googlegroups.com
The GraphML reader requires the edge label to be present, there's nothing you can do in your code. I think you have two options: either add the default labels in your GraphML file or parse the input manually.

Cheers,
Daniel


Stephen Mallette

unread,
Jun 7, 2016, 6:20:42 AM6/7/16
to Gremlin-users
GraphML does not require an edge label, but TinkerPop's data structure is not bound to GraphML so the fact that we support GraphML is really only a convenience to users who want to use external tools.  I want to say that most graph databases supporting property graph model require an edge label. I'm not so sure I'm aware of any that allow the edge label to be optional, so even if we allowed a null/empty label to come in as part of the API I doubt there would be much support.

Serge Vilvovsky

unread,
Jun 7, 2016, 6:47:04 AM6/7/16
to gremli...@googlegroups.com

Is it any way that I can add the default label in parser? Any examples of such parser configuration?

Stephen Mallette

unread,
Jun 7, 2016, 6:56:41 AM6/7/16
to Gremlin-users
No, GraphMLReader doesn't provide a way to specify a default label. Kuppitz provided the best answer:

either add the default labels in your GraphML file or parse the input manually.

I would only offer a third option that you modify GraphMLReader to set the label with Edge.DEFAULT_LABEL if the label value is null :


If you did that, I think we could probably accept that as a pull request. If you decide to implement that, please issue your PR against the tp31 branch.

Thanks,

Stephen


Serge Vilvovsky

unread,
Jun 7, 2016, 9:38:04 AM6/7/16
to Gremlin-users
 What does it mean to parse the input manually? Is it any example of it? Can I parse it manually to the org.apache.tinkerpop.gremlin.structure.Graph?
 I need to run the next two lines after that:

        final GraphTraversalSource g = newGraph.traversal();


        GraphTraversal<Vertex, Path> result1g.V().as("v1").has("type","type1").out().as("v2").has("type", "type2").path();

Marko Rodriguez

unread,
Jun 7, 2016, 9:41:45 AM6/7/16
to gremli...@googlegroups.com
Hi,

I would do as Stephen recommended and provide us a PR (or ticket) that says: “if there is no edge label in the GraphML file, then use Edge.DEFAULT.”

Marko.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.

Stephen Mallette

unread,
Jun 7, 2016, 9:56:55 AM6/7/16
to Gremlin-users
Serge, he just means use your favorite XML parser and read the GraphML into your Graph instance. Again, the PR is probably the best solution. We're working toward a release soon so you could have the fix in 3.1.3/3.2.1.

Serge Vilvovsky

unread,
Jun 7, 2016, 10:18:57 AM6/7/16
to gremli...@googlegroups.com
Please, provide me the link, where I can do such request.

Thank you,
Serge

--
You received this message because you are subscribed to a topic in the Google Groups "Gremlin-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gremlin-users/56CI2PTWueg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CAA-H43-ON0WOFXQ_XsaRVZbO3X5Ry8-LwOuq%2BRGFyu59GXoFJQ%40mail.gmail.com.

Stephen Mallette

unread,
Jun 7, 2016, 10:35:56 AM6/7/16
to Gremlin-users

Serge Vilvovsky

unread,
Jun 7, 2016, 10:45:16 AM6/7/16
to gremli...@googlegroups.com
OK, I have created one: https://github.com/apache/incubator-tinkerpop/pull/331

Now what are my next steps? Who is going to make a change? I am not familiar with the code and not sure how to test everything. 

Serge Vilvovsky

unread,
Jun 7, 2016, 11:19:18 AM6/7/16
to gremli...@googlegroups.com
Please, see my update on the PR. I have never worked with Apache community (thanks for an experience), so need some guidelines how to contribute my change.

Stephen Mallette

unread,
Jun 7, 2016, 11:44:25 AM6/7/16
to Gremlin-users
sorry...i don't think you understand what's involved here. if you're creating a pull request then you make the changes and then submit them to us for review, at which point we will review/include them in the code base. If you don't feel comfortable doing that then you should just create an issue in JIRA and when someone has time they will make the change. Anyway, I'd encourage you to attempt to make the change yourself and submit a pull request. Again, the instructions to do so are here:


however, the summary/specifics of all that, is:

1. fork/clone (https://help.github.com/articles/fork-a-repo/) the Apache TinkerPop github repo
2. in this case, we want the changes on the tp31 branch so create a branch from that:
   a. git checkout tp31
   b. git checkout -b tp31-graphml
3. Make your changes: 
    a. Make the change to GraphMLReader as I suggested
4. Build with "mvn clean install" and validate that your changes work
5. push the branch to your fork
6. Issue the pull request through the GitHub UI
   b. please be sure to select the tp31 branch when you submit your pull request
7. work with us through the review process until your pull request is merged

Please delete your existing pull request.




Serge Vilvovsky

unread,
Jun 7, 2016, 1:21:34 PM6/7/16
to gremli...@googlegroups.com
Stephen, thank you for explanations. I hope I have done it correct now. Please, see at https://github.com/apache/incubator-tinkerpop/pull/332


Stephen Mallette

unread,
Jun 7, 2016, 1:25:35 PM6/7/16
to Gremlin-users
Thanks - at a glance, that looks better. :)

Reply all
Reply to author
Forward
0 new messages