1

I am a recent adopter of Gremlin and am trying to piece together an understanding of the TinkerPop architecture. Does the diagram below correctly identify the relationships between the components that are shown?

This diagram has been revised per the comments by Stephen Mallete enter image description here

Joel Stevick
  • 1,638
  • 2
  • 16
  • 22

1 Answers1

3

There are a lot of different ways that a graph database can be considered TinkerPop-enabled and that definition has shifted and changed over the decade or so that TinkerPop has been around at this point. As a result, I can confirm your depiction of the interaction between Gremlin Console and a TinkerPop-enabled graph database is mostly correct but really just identifies one method by which that works. I say "mostly correct" because the Gremlin Console typically doesn't send bytecode, but the actual text of what is typed by the user before they hit enter - i.e. a script processed by the server. It further assumes that the Gremlin Console is configured for a :remote connection and is not working in with a locally established graph.

Some graphs will work with a :remote connection but not actually have a "Gremlin Server" in play...they will just implement Gremlin Server protocols and thus have their own method for handling those scripts.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Thank you, this is very helpful. I have revised the diagram to reflect my understanding of what you are saying. This leaves me with a follow-up question: does the GTM also accept plain-text queries and then parse them into bytecode for execution, or is there some external code that handles this (please refer to the red circle)? Any further insight that you can provide is greatly appreciated! – Joel Stevick Oct 22 '18 at 01:27
  • 1
    The Gremlin Console only sends bytecode if you locally instantiate a `GraphTraversalSource` that does so using http://tinkerpop.apache.org/docs/current/reference/#connecting-via-remotegraph so the console itself really doesn't send anything to Gremlin Server in that case...it's more a function of the code you are evaluating locally in that case. as for your question about the red circle, i guess that could be the GremlinScriptEngine which takes a script and compiles to JVM bytecode for execution. – stephen mallette Oct 22 '18 at 10:39
  • Yes. Perfect. thanks for filling in the holes for me! – Joel Stevick Oct 22 '18 at 10:49
  • I have two more follow-up questions: 1. Is it the case that the GremlinScriptEngine listens on port 8182 (or whatever), and then hands bytecode streams received over the websocket connection directly to the GTM? 2. Did you mean GTM in your comment above? Or does the script engine actually compile script to JVM bytecode that is executed externally to the GTM? – Joel Stevick Oct 22 '18 at 10:59
  • 1
    Gremlin Server listens on a port and handles websocket/network protocol level events. it hosts a `GremlinScriptEngine`. I think of the GTM as "the `Traversal` object", so i don't think of there being a "hand-off to the GTM" - it's more of a logical concept than a concrete one. when there is a `GremlinScriptEngine.eval()` of bytecode you end up with a `Traversal` object that is ready to be iterated for results. when the `GremlinScriptEngine` completes its `eval()` of a script you get compiled JVM bytecode and if that compiled JVM bytecode has a `Traversal` in it then that gets executed. – stephen mallette Oct 22 '18 at 11:29
  • Thanks. Also, I could not find the Gremlin script engine source code on GitHub, all I have located are the gremlin server and the language provider implementations (https://github.com/apache/tinkerpop). Is the script engine available on GitHub? Also, any other pointers to relevant source would be appreciated so that I can stop bugging you with these questions! – Joel Stevick Oct 22 '18 at 11:53
  • 1
    It's an interface in gremlin-core, https://github.com/apache/tinkerpop/blob/84b419e717233ecb27647fb0599a1c55e042f80b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngine.java it has implementations in gremlin-groovy and gremlin-python. the groovy one is much more advanced and you should probably only concern yourself with that. if you have further questions, please consider just sending them gremlin-users mailing list: https://groups.google.com/forum/#!forum/gremlin-users might be easier to resolve detailed questions there than here in SO comments – stephen mallette Oct 22 '18 at 12:21