Best approach to setting up for driver data serialization from WebSocketChannelizer

35 views
Skip to first unread message

Ray Scott

unread,
Aug 4, 2017, 3:07:58 PM8/4/17
to Aurelius
I want to develop a driver in Go that connects to Gremlin Server using a websocket, runs a parameterized Groovy script and parses the response. At this stage all I need to do is perform basic queries and modify the graph. I've read through the documentation on driver development, and looked through some source code for existing drivers. 

Connecting and sending the data is the easy part. What I can not find anywhere, is an explanation of what I can expect to receive back in terms of the serialised format. I'm actually using JanusGraph straight out the box. I've looked at the yaml config and read some posts on the serializers listed therein. I've read a little about GraphSON and GraphML and Kryo and all I'm really looking for is a way to setup the server so that it returns a response thats some sort of official spec'd format that I can work with in Go. The only other thing I need to do, is be able to use the console as normal. 

As an example, if I send this query...

graph = JanusGraphFactory.open(cassandra)
g
= graph.traversal()
g
.V().has('name', 'hercules').next()


I receive this...

[[map[id:8376 label:demigod type:vertex properties:map[name:[map[id:2s7-6go-sl value:hercules]] age:[map[id:36f-6go-35x value:30]]]]]]


What format is that? How do other driver developers handle this? Do I need to change the settings of the serializers in the yaml config? Do I use a writer in the Groovy script to serialize the result into a format of my choice? I don't want to perform any unnecessary serialization. 

Thanks.

Stephen Mallette

unread,
Aug 5, 2017, 7:38:34 AM8/5/17
to Aurelius
This question is best asked on the gremlin-users mailing list, but before I go into any real detail I'll mention that this would be the third Go driver that I'm aware of to undergo development - have you looked at the groundwork already put in place at this point? This one is the most current one I believe:




--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraphs+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aureliusgraphs/48a3cc88-3424-4e6b-a7a5-3b09e94e8c46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ray Scott

unread,
Aug 6, 2017, 2:41:35 PM8/6/17
to Aurelius
Yes, and I'm not the only potential user of that driver with questions about how to actually use it practically with regard to serialising a response format.

https://github.com/qasaur/gremgo/issues/18

If you, or someone else could tell us how to get meanifuly responses using that or any other Go driver, I'd use it. But even the developer of the driver seems to just throw his arms up in the air and say "It's up to you" when some asks how to get a meaningful, serialisable response.

Can you tell me what format is being returned in my previous post? All I want to do is get consistent results back that I can unmarshall into a collection object.

Stephen Mallette

unread,
Aug 7, 2017, 7:33:50 AM8/7/17
to Aurelius
I don't know Go syntax so I'm not sure I fully understand the problem with usage. as I understood it, gremgo was just a Gremlin Server driver. You can send a Gremlin string to the server and it will return a result as JSON. The content of that JSON is dependent upon what your Gremlin string returns. For your specific example on this thread, that result just looks like a serialized Vertex in GraphSON 1.0 format:

--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraphs+unsubscribe@googlegroups.com.

Ray Scott

unread,
Aug 7, 2017, 10:53:18 AM8/7/17
to Aurelius
Yes thanks. I have found that the Gremlin console tutorial has quite a useful section called "ad-hoc" that shows you how to manipulate results into something useable. 

Is there a "best practice" for formatting vertex and edge data sent back from the Gremlin Server? Say for simple CRUD style operations. This is all within the data centre: microservice to microservice. I don't want to end up with serialization errors due to special/reservced characters used in user data. Does GraphSON automatically put quotes around values that have reserved characters in them? There aren't any in the output I posted. 

Is it performant to start using the GraphSON writer (or other) in a Gremlin parameterized script to format data to be sent back? Sorry if you've heard these questions many times before. 




On Monday, 7 August 2017 12:33:50 UTC+1, stephen mallette wrote:
I don't know Go syntax so I'm not sure I fully understand the problem with usage. as I understood it, gremgo was just a Gremlin Server driver. You can send a Gremlin string to the server and it will return a result as JSON. The content of that JSON is dependent upon what your Gremlin string returns. For your specific example on this thread, that result just looks like a serialized Vertex in GraphSON 1.0 format:
On Sun, Aug 6, 2017 at 2:41 PM, 'Ray Scott' via Aurelius <aureliu...@googlegroups.com> wrote:
Yes, and I'm not the only potential user of that driver with questions about how to actually use it practically with regard to serialising a response format.

https://github.com/qasaur/gremgo/issues/18

If you, or someone else could tell us how to get meanifuly responses using that or any other Go driver, I'd use it. But even the developer of the driver seems to just throw his arms up in the air and say "It's up to you" when some asks how to get a meaningful, serialisable response.

Can you tell me what format is being returned in my previous post? All I want to do is get consistent results back that I can unmarshall into a collection object.

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

Stephen Mallette

unread,
Aug 7, 2017, 1:22:37 PM8/7/17
to Aurelius
I wouldn't return entire vertex/edge instances in my Gremlin for an application. I would use Gremlin to form the results into something useful to my application. Gremlin is fairly powerful in this regard as you just need to introduce the right transformative steps to get the result back that is meaningful to what the application requires. Usually this means just returning map or list or some combination of those. 

Does GraphSON automatically put quotes around values that have reserved characters in them? 

GraphSON uses Jackson data-bind for serialization which i believe would handle any encoding issues related to special characters and such.

Is it performant to start using the GraphSON writer (or other) in a Gremlin parameterized script to format data to be sent back?

Not sure i understand what you're asking, but you shouldn't need to use the writer directly. just send a parameterized script and it will automatically pass the result through the GraphSON serializer. Just use Gremlin to get it into a Map/List first as I mentioned at the start of this post - GraphSON should handle the rest.


To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraphs+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aureliusgraphs/7beee4d1-502b-4639-b55b-b94edb4b58ea%40googlegroups.com.

Ray Scott

unread,
Aug 8, 2017, 3:25:49 AM8/8/17
to Aurelius
Great, thanks very much for your help. 
Reply all
Reply to author
Forward
0 new messages