gremlin-python and int64 property value

246 views
Skip to first unread message

dwoz...@gmail.com

unread,
Mar 17, 2019, 9:51:27 PM3/17/19
to Gremlin-users
Hello folks - 

I'm running gremlin-python from an iPython console and connected to a a TinkerGraph in Gremlin-Server (all 3.4.0)  I am having problems submitting

orderverts = g.V().has('OrderID',783643977611).order().by(id).toList()

I can get this to run (which doesn't help but to narrow down the issue):

orderverts = g.V().has('OrderID',gt(700000000)).order().by(id).toList()

so it pretty much has to be one of those dastardly Python->Java int64 issues.

I learned the trick for the quoted int64 vertex id, but it doesn't seem to work here. I have no problem running it in the gremlin console. Any tricks of the trade to save the day?

abrag...@gmail.com

unread,
Mar 18, 2019, 7:47:27 AM3/18/19
to Gremlin-users
I had the same issue and thought about opening a bug:
  • the Gremlin driver serialize the Python Int as Int32 (but Python int can hold int64 values also)
  • the Gremlin-Console do not have this issue as the "string"/characters representing the integer are parsed correctly 

for now as a workaround I am doing the following:
from gremlin_python.statics import long

g = traversal().withRemote(
DriverRemoteConnection('ws://{}:{}/gremlin'.format("127.0.0.1", "8182"), 'g'))
g.addV("label").property(T.id, "id").property("super_big_int", long(12313123123133))

using the long() before the int will force it to be serialized as Int64

I do not know if its the right way to go, but for a temp workaround its working,
in the future the python driver should handle the conversion to Int64 or Int32 based on the size or something 
or maybe it was done intentionally to save space (if so why this is not an issue in the gremlin-console) 

drew.w...@sacient.com

unread,
Mar 18, 2019, 10:08:48 AM3/18/19
to Gremlin-users
Thanks for your post.  I can't apply your work around because I have hundreds of Kryo graphs with multiple int64 properties that have been built through
a CSV->graphml->tinkegraph->kryo ETL process.  The graphml schema that is loaded with the xml data into tinkergraph
specifies this property 'OrderID', as well as 5 other int64 properties, as attr.type='long'.  Why this is proving insufficient - I don't know.

Is there any other way to coerce gremlin-python int64 property values into a format that can be consumed by gremlin-server??

drew.w...@sacient.com

unread,
Mar 19, 2019, 10:53:48 AM3/19/19
to Gremlin-users
Ok - I got it now - whew - thank goodness, and thanks for the help!
Reply all
Reply to author
Forward
0 new messages