TinkerGraph as a domain object?

56 views
Skip to first unread message

Nick Halase

unread,
Mar 13, 2017, 12:32:15 PM3/13/17
to Gremlin-users
Hey all, I was wondering if this would work at all.

Let's say we have a web application which lets users define groups of friends, including information such as who knows whom, and which people like what stuff.

My application is using spring-hateoas and the incoming resources are JSON. I was thinking about sending these resources over to a service layer which validates them and converts them into a local TinkerGraph Graph. The in-memory Graph would then be passed to a DAO layer which translates and persists the TinkerGraph to my graph database (DSE Graph). The TinkerGraph would then be closed.

My Reasoning: I would prefer not to create and maintain a complicated domain model full of Java POJOs; I expect the model to change often as time goes on.

As far as I can tell, since I won't have concurrent reads or writes to the TinkerGraph, this should work out okay. The only issue I foresee is memory usage.

Am I going about this all wrong? Is this a terri-bad idea? I'd appreciate some feedback.

Thanks!

-Nick

Daniel Kuppitz

unread,
Mar 13, 2017, 3:43:29 PM3/13/17
to gremli...@googlegroups.com
Funny that you ask, as I was suggesting exactly that in a project earlier today. My idea was to build a TinkerGraph subgraph in the application code, then serialize it, send it to Gremlin server, deserialize it and merge it with the DSE graph. That requires a bit of manual work as you can't just dseGraph.io(gryo()).readGraph(), but in the end it's pretty simple and straight forward. I've written a small test to see how much overhead the (de)serialization adds and it's really not a lot (provided that my VM to test this is not pretty fast).

Check this: https://gist.github.com/dkuppitz/67f1d446a72366cca234b062810cadfb

Sample output:

tinkergraph[vertices:100 edges:34]
Time to serialize the graph: 4.91 ms, size of serialized graph: 6536 bytes
Time to deserialize and merge the graph: 8.00 ms.

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-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/b1bc20f6-eb71-41e7-b6e4-18c63e474b07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages