gremlin.net and Cosmos (but NOT using cosmos API)

894 views
Skip to first unread message

shapeshifter

unread,
Apr 11, 2018, 12:38:39 PM4/11/18
to Gremlin-users
Hi guys (first post here so go easy please :) )

Ok, I'm very new to graph DBs, gremlin.net and Azure/Cosmos and pretty new to .NET too (it's not surprising I'm confused)

What I can do so far: 
I spent a fair bit of time initially just on gremlin console. I have no trouble using that to work on the in-memory DB, and no trouble connecting to both the basic gremlin-server and even a Cosmos graph DB (just by editing remote.yaml).

In .Net, I can connect to said cosmos DB using the Azure API (DocumentClient, DocumentCollection etc.).  However, I can only find out how to submit traversals as a string rather than using chaining. e.g.

                var queryStr = "g.V().hasLabel('person').values('firstName')";
               
var query = client.CreateGremlinQuery<Microsoft.Azure.Graphs.Elements.Vertex>(graph, queryStr);

Even if I could build queries using chaining, the bigger picture here is that my boss wants code that is more portable and not so embedded with cosmos, so I'm looking at connecting gremlin.net directly to cosmos, just as I can from the gremlin console.

This bit of code gives an error on the traversal:

            var gremlinServer = new GremlinServer(hostname, port, enableSsl: true,
                                                                 username
: "/dbs/" + database + "/colls/" + collection,
                                                                 password
: authKey);
           
var driver = new DriverRemoteConnection(new GremlinClient(gremlinServer));
           
//var driver = new DriverRemoteConnection(new GremlinClient(new GremlinServer("localhost", 8182)));


           
var graph = new Gremlin.Net.Structure.Graph();
           
var g = graph.Traversal().WithRemote(driver);


            g
.V().Drop().Next(); // nullreferenceexception

However, if I swap over the 2 'driver' lines and connect locally instead, everything is fine.  I know the connection to cosmos works as I can screw up the hostname to get a "no connection" error.

I have code that DOES work:

            var gremlinServer = new GremlinServer(hostname, port, enableSsl: true,
                                                    username
: "/dbs/" + database + "/colls/" + collection,
                                                    password
: authKey);  // same as above
           
// using new (At time of writing) gremlin.net 3.3.2, but also tried with 3.3.1 and 3.2.7 (the latter has slightly differernt params)
           
using (var gremlinClient = new GremlinClient(gremlinServer, new GraphSON2Reader(), new GraphSON2Writer(), GremlinClient.GraphSON2MimeType))

           
{
                   
var task = gremlinClient.SubmitAsync<dynamic>("g.V().Drop()");
                    task
.Wait();

Notice something different from the above code here? It doesn't wrap the client in a DriverRemoteConnection object.  However, without this I can't (or don't know how to) create a graph traversal object, and so I am again stuck using string literals for traversals.

Sorry for the long post, and sorry if I've missed something obvious and/or have my terminology mixed up (I'm learning a lot of new stuff concurrently).  I have lots of other questions, but this is enough for now!

In summary all I want is to use gremlin.net to connect to cosmos WITHOUT using azure API methods and WITH a graph traversal object so I can create chained traversals.

TIA

Stephen Mallette

unread,
Apr 12, 2018, 7:10:52 AM4/12/18
to Gremlin-users
Hello and welcome to The TinkerPop! I'm sorry to say that CosmosDB doesn't yet supports bytecode based traversals - only the string based traversals.


We were just about finishing up bytecode as a feature when CosmosDB first announced so it's not too surprising that it wasn't immediately supported. Hopefully they will have that covered soon.




--
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/c50498df-1fb4-4f13-abcf-1fee108ef555%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

shapeshifter

unread,
Apr 12, 2018, 9:37:48 AM4/12/18
to Gremlin-users
Hi Stephen,

Thanks for your quick response.  This is disappointing, but at least I know now.  Would it be possible to add this status to the gremlin.net section of the docs?  I've lost a lot of time on this and would like to save others the same fate.

Do you know of any such problems or short-comings with Gremlin.net and Janus? I'm looking to that as an alternative.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.

Stephen Mallette

unread,
Apr 12, 2018, 9:47:28 AM4/12/18
to Gremlin-users
Sorry you went down a rabbit hole on this but I don't think we would add this kind of notice to our documentation. TinkerPop doesn't really keep track of the specifics of how each graph implementations work or the extent to which they support what we expose as functionality. That takes a fair bit of work considering all the different graphs that implement the TinkerPop interfaces and I'm not sure we'd be good at keeping it current which would also be bad. 

As far as graphs that support bytecode I think that CosmosDB is the only one with trouble right now. Any graph that can be embedded in Gremlin Server (like JanusGraph) will support bytecode. As for the "server graphs" out there, I think that CosmosDB is the only one that doesn't support it. So DSE Graph, Neptune, Compose for JanusGraph should all be fine. 

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/181e254e-5217-4d30-863c-91cea1b4dfdf%40googlegroups.com.

shapeshifter

unread,
Apr 12, 2018, 9:56:52 AM4/12/18
to Gremlin-users
I understand re: docs

Thank you, Stephen, you've been very helpful.
Reply all
Reply to author
Forward
0 new messages