TP3 Gremlin server/console can't get vertex created by addVertex().

94 views
Skip to first unread message

Dmill

unread,
Mar 30, 2015, 11:09:31 AM3/30/15
to gremli...@googlegroups.com
Hey guys,

This is probably going to be a really stupid question but it's left me scratching my head. I'm using gremlin-server & console M7 and here's what's happening:

I'm using the  gremlin-server-classic.yaml configuration file for the server.

bin/gremlin.sh 

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Connected - localhost/127.0.0.1:8182
gremlin> :> g.V()
==>v[1]
==>v[2]
==>v[3]
==>v[4]
==>v[5]
==>v[6]
gremlin> :> g.addVertex('name', 'beepbeep');
==>v[12]
gremlin> :> g.V()
==>v[1]
==>v[2]
==>v[3]
==>v[4]
==>v[5]
==>v[6]
==>v[12]
gremlin> :> g.V(6)
==>v[6]
gremlin> :> g.V(12)
gremlin> 

g.V(6) works as expected.. but not the newly created vertex #12. It must be something really simple but what am I missing? 

I'm experiencing something similar in Titan 0.9.0-M1 where g.v(12) (small v) throws the following error: Exception: java.lang.RuntimeException: javax.script.ScriptException: javax.script.ScriptException: java.util.NoSuchElementException: The vertex with id 12 of type Integer does not exist in the graph

Thanks in advance.

Daniel Kuppitz

unread,
Mar 30, 2015, 12:00:52 PM3/30/15
to gremli...@googlegroups.com
Hi Dylan,

I haven't tried to reproduce it yet, but I guess it's because the IDs 1-6 were explicitly set as Integers; auto-generated IDs on the other hand are Longs. Try this:

:> g.V(12L)

Cheers,
Daniel


--
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/a6626def-212e-44a5-b1c3-574385dc5757%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dylan Millikin

unread,
Mar 30, 2015, 12:07:14 PM3/30/15
to gremli...@googlegroups.com
Thanks Daniel that works! 

If I understand correctly, the type of auto-generated IDs depends on the graph being used? So depending on whether I'm using tinkergraph, neo4j, Titan, or OrientDb the ID will be set with a different type? Or is it always going to be Long?

--
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/Nb7v1-ihFgY/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/CA%2Bf9seVZ3%3D3JcpFs1_JuVXbXLK2XK_qpwb0A-oaE6xbtza1gng%40mail.gmail.com.

Daniel Kuppitz

unread,
Mar 30, 2015, 1:04:13 PM3/30/15
to gremli...@googlegroups.com
It's Long for Titan and TinkerGraph. Neo4j should be Long too, but I'm not 100% sure. I believe OrientDB uses a String, but again I'm not 100% sure. However:

g.addVertex().id().getClass()

...should return the correct answer on any GraphDB.

Cheers,
Daniel


Dmill

unread,
Mar 30, 2015, 1:29:54 PM3/30/15
to gremli...@googlegroups.com
Thanks again for the info Daniel,

This is proving to be quite an issue however for non-java developers, especially in our case. Let me explain why.
When we query the db via gremlin server we will obtain a vertex ID (say 12 to stay consistent with the previous emails). When PHP parses the response there is no (more?) indication of whether this is an int, or a long. This is because there is no type setting of variables to long in PHP (ints are 64-bit on 64-bit systems). Thus 12 will always be int. Both when getting a response from the server or when setting binds for a gremlin script destined to be processed by the server.

So in essence:
- PHP built gremlin + binds are sent to the server
- Response gives an ID of 12
- PHP interprets 12 as int
- PHP tries to do g.V(12) or g.V(SOMEBIND) with SOMEBIND=12 (int)
- DB doesn't find the vertex since it should be 12L.
- PHP can't send g.V(SOMEBIND) with SOMEBIND=12L because 1) it doesn't know when a long should be sent in place of an int and 2) because 12L is automatically set as string in PHP, thus making it the equivalent of sending g.V("12L") which will return empty.
 
This is quite a problem and I'm not sure how to make it work. I'm assuming TP2 addVertex() would set the ID as Int or String because this wasn't a problem before. Of course, configuring the system so it would behave like this again is detrimental to the total available ID pool.

Any Ideas? How has the Javascript community handled this? If I recall, javascript numbers are all 64-bit floating points.

Thanks,
Dylan.

Stephen Mallette

unread,
Mar 30, 2015, 4:52:36 PM3/30/15
to gremli...@googlegroups.com
This exchange sorta ended with more of a "dev" tone to it, so I posted this:


on the dev mailing list.  Note that this problem has always been around and not really just a TP3 thing.  Please feel free to chime in on the issue in the dev list so that we can form up a solution.

Dylan Millikin

unread,
Mar 30, 2015, 5:01:06 PM3/30/15
to gremli...@googlegroups.com
Thanks! I'll have a look and participate.

Best,
Dylan

--
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/Nb7v1-ihFgY/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-H4382cpPb1na5devRbCftdPoXj%3D2c_Z_kPKz2e652HD7xUg%40mail.gmail.com.

Dylan Millikin

unread,
Mar 31, 2015, 5:34:38 AM3/31/15
to gremli...@googlegroups.com
Hey Stephen,

I just subscribed to the dev mailing list, I however need the message ID for the Message you posted there so that I can retrieve it and participate (the web interface doesn't display it. I think it strips some of the headers.). If you could send me the ID I'd be grateful. 

Thanks,
Dylan.

Stephen Mallette

unread,
Mar 31, 2015, 7:52:38 AM3/31/15
to gremli...@googlegroups.com
yeah - i guess we all have to get used to the apache mailing list.  i guess you should interact with the mail system this way:


just send a message to dev-...@tinkerpop.incubator.apache.org - that should give you latest posts which will provide you with the message id to get the specific one (e.g. 12345) with: dev-ge...@tinkerpop.incubator.apache.org

Dylan Millikin

unread,
Mar 31, 2015, 7:55:20 AM3/31/15
to gremli...@googlegroups.com
Awesome thanks, I wasn't aware of the dev-index.

Cheers!

Dylan Millikin

unread,
Mar 31, 2015, 10:52:22 AM3/31/15
to gremli...@googlegroups.com
Ok,

So I'm unsure of how to reply to a message gotten through dev-get. To avoid making a mistake and creating another thread I'm simply going to post my information here for the time being. If you've got any idea on how to, feel free to let me know. In any event I'm now subscribed and should be able to participate in future threads and in this one in particular as soon as another message is made.
Feel free to add this to the dev mailing list thread.

Just to clarify a bit because my previous messages danced around the main issue (though from your response you're well aware already) : 
This is in fact a blocking point for anyone using the JSON serializer and binds with gremlin-server.
JSON data types are limited and involve lossiness. Consider the following "args" of a gremlin driver message using the JSON serializer:

{
   "BIND1": 12,         // Interpreted as Integer
   "BIND2": 12.05,      // Interpreted as BigDecimal?
   "BIND3": 2147483647, // Interpreted as Integer
   "BIND3": 2147483648, // Interpreted as Long
   "BIND4": "12L",      // Interpreted as string
   "BIND5": 12L,        // Error illegal
}

So in essence it's impossible for anyone using gremlin-server with the JSON serializer to addVertex() and then find that vertex via g.V(BIND*). Unless the vertex ID > 2^31-1 . Whoops :|

I personally like option 1) best in your response. I can't really think of any downsides other than situations with conflicting IDs (v[12] & v[12L] residing in the same graph). I'm not too sure which scenario would have such a case. Maybe importing graphs with int IDs and relying on addVertex() for any further insertions would be a problem. I can see this happening when users migrate over to TP3.
In any event, numerical strings should stay strings though.

2) This has the advantage of keeping communication logic and issues on the serializer level but I feel like there is no clean way of ensuring correct interpretation in all events.

3) The use of embedTypes(true) as is can actually help if the drivers support it. But for languages that don't have equivalent datatypes there's still a lossiness issue. We would have to create objects that would emulate these datatypes. This is language dependent and for instance not easily doable in PHP.

How did Rexster handle this? Did addVertex() also set IDs as longs in TP2?

Stephen Mallette

unread,
Mar 31, 2015, 11:09:24 AM3/31/15
to gremli...@googlegroups.com
i have no idea how to reply to an archived thread on the dev list - i tried to research it out, but no luck........

anyway, thanks for your thoughts - i too think we should handle it at the Graph level and enforce it consistently.  Seems unlikely that an implementation would want to have mixed long/int IDs and want to differentiate between them.

How did Rexster handle this? Did addVertex() also set IDs as longs in TP2?

As best I can remember, this wasn't solved with Rexster.  It was always a bit of an issue.  You didn't see it with TinkerGraph in TP2 because it internally treated all IDs as String.  We changed that in TP3 which is why it is more apparent of a problem now.  

Reply all
Reply to author
Forward
0 new messages