Apache TinkerPop

AT

Apache TinkerPop

Apache TinkerPop is an open source graph computing framework and the home of the Gremlin graph query language.

Join

Version Update differences

Hi guys, We are upgrading from gremlin_python 3.4.11 to 3.6.2. We had some functions break and it turns out that gremlin migrated from tornado to aiohttp in 3.5. Before, we used tornado.httpclient.HTTPRequest in RemoteDriverConnection( tornado.obj ) to form a connection to Neptune. We got the credentials using AWSRequest, botocore, and Sig4Auth. My question would be how do I create a connection using AIOHttpTransport instead of Tornado....
Solution:
Hi guys, We are upgrading from gremlin_python 3.4.11 to 3.6.2. We had some functions break and it turns out that gremlin migrated from tornado to aiohttp in 3.5. Before, we used tornado.httpclient.HTTPRequest in RemoteDriverConnection( tornado.obj ) to form a connection to Neptune. We got the credentials using AWSRequest, botocore, and Sig4Auth. My question would be how do I create a connection using AIOHttpTransport instead of Tornado....

What is the ordering of group?

For instance (on Tinkerpop modern) g.V().group().by('age').by('name') gives [{32=[josh], 35=[peter], 27=[vadas], 29=[marko]}] ...
Solution:
Gremlin doesn't offer too many order guarantees. I think group() by default uses a regular old HashMap for it's data structure. If you want an order you would want to specifically specify an order() - for example:
gremlin> g.V().group().by('age').by('name').order(local).by(keys)
==>[27:[vadas],29:[marko],32:[josh],35:[peter]]
gremlin> g.V().group().by('age').by('name').order(local).by(keys)
==>[27:[vadas],29:[marko],32:[josh],35:[peter]]
I suppose you could also force use of a LinkedHashMap: ```gremlin> g.withSideEffect('m', [:]).V().hasLabel('person').group('m').by('age').by('name').cap('m')...

Export to graphml/graphson with Python

Hello everyone, I hope this question has not been asked yet, if so I'm sorry for redundant content... I would like to export my graph to graphml or graphson using Python. The documenation provides this code "g.io("graph.xml").write().iterate()" , which does not produce any output or this "g.io(someOutputFile).with(IO.writer,IO.graphml).write().iterate()", which does not follow the syntax. Do you have any suggestion how to solve this? I also read about making sure that the file is accessible by the GremlinServer, do I need to do anything else except creating a connection to the server (which I have done to create the graph in the first place)?...

Out edge of vertex is slow

When i run this below query: "g.V().has("guid", "6203620951906330066").limit(10).out("matching").profile().toSet()" And I see step "JanusGraphVertexStep(OUT,[matching],vertex)" take a lot of time. Is there any way to solve this?...

Translating bytecode into JupyterLabs compatible script.

I've found that the gremlin syntax in jupyter is different from every other language, including python. For now i've resorted to copying the java PythonTranslator into a new class and modifying the code to suit the differences. Does a better way exist?

Query if else in gremlin

I have a query and that return a list vertex. I want to do a query from those vertexes like this (if - else): - vertex doesn't has out edge -> return itself - vertex has out edge -> then keep querying until there are no edges out ( repeat(out()).until(outE().count().is(0)) ) I'm trying to limit the use of loops here to improve performance. Who can help me. Thank you very much...

Does Gremlin do DFS or BFS?

Does Gremlin perform a Depth First Search (DFS) or Breadth First Search (BFS) when traversing?

Isolated vertices vs connected vertices with no join benefit

Is there any downside to storing an isolated vertex with references to other nodes? Creating relationships makes the query more complicated than it needs to be, but storing references to other vertices seems like an anti-pattern/smell. The relationship between nodes is defined as follows: ```g.addV('batch').property(id,'batch-a').as('a'). addV('batch').property(id,'batch-b')as('b'). addV('reusable').property(id, 123).as('r1')....
Solution:
We're basically talking about denormalization here. denormalization is common for graphs as it is for relational data structures and it comes with the same drawbacks. Is this a case for denormalization? Based on this simple example, I'd say "no" because you really just have a single hop or so to collect what you need and you're done. But, I also don't know any other statistics about your data structure and other expected query patterns so it's hard to say with certainty that you shouldn't denormalize. That said, if denormalization is the answer, do you denormalize to a wholly disconnected vertex? i still don't think i'd recommend that based on what i know. You're most painful traversal is a two hop of __.in('relates_to_batch').out("related_to_reusable") to get an id or perhaps multiple ids. Considering adding a property of "reusableIds" to "batch-a" and store a List of the ids there (or use multi-properties, https://tinkerpop.apache.org/docs/current/reference/#vertex-properties). That seems like the most natural model to me since "isolated" is really just a "batch" with properties containing various things its connected to. Seems better to me to not introduce an "isolated" concept for that and denormalize to a thing that is actually part of your graph and connected. ...

Subgraph Strategy with vertexProperties + project().by("field name") = crash

Running the following query: g.withStrategies(new SubgraphStrategy(vertexProperties: constant(true))).V().project("example").by("example") Results in a crash with obscure error: ```java org.apache.tinkerpop.gremlin.driver.exception.ResponseException: The provided traverser does not map to a value: v[122908680][CacheVertex]->[PropertiesStep([example],property), TraversalFilterStep([ConstantStep(true)]), OrStep([[ClassFilterStep(VertexProperty)], [TraversalFilterStep([ConstantStep(true)])]]), PropertyValueStep][DefaultTraversal] parent[[CoalesceStep([value([PropertiesStep([example],property), TraversalFilterStep([ConstantStep(true)]), OrStep([[ClassFilterStep(VertexProperty)], [TraversalFilterStep([ConstantStep(true)])]]), PropertyValueStep]), (null)])]]...

Custom MutationListener on Transaction

Hello everyone, I'm a beginner regarding tinkerpop and i'm trying to fire my custom listener after a transaction is done. I have registered an EventStrategy on my JanusGraph
graph.traversal().withStrategies(EventStrategy.build().eventQueue(new CustomTransactionnalEventQueue(graph)).addListener(new CustomListener(graph.traversal())).create())
graph.traversal().withStrategies(EventStrategy.build().eventQueue(new CustomTransactionnalEventQueue(graph)).addListener(new CustomListener(graph.traversal())).create())
The Custom transactionnal Event Queue is just a copy of the one in the EventStrategy class with logs at every step to help me find where the problem is . Now the problem : I have noticed that my transaction are never mark as committed....

Gremlin Query to give all related items in versioned graph

I am working on a requirement where I need to store all version of a record in a Graph Database say JanusGraph, one naïve approach for this requirement could be to create separate vertex for each record version. Say: Record R1 has version v1, v2, v3 Then create separate vertex for R1: v1, R2:v2 and R2:v3...

Order group count result alphabetically

Hi! Given the following query and results in the enclosed image: how would I sort the labels alphabetically? Air routes dataset for illustration....

Transactions - tx.commit vs tx.close

I have a question related to transactions. I'm having issues with tx.commit() hanging locally when running through Tinkerpop (this is fine when connected to Amazon Neptune), although tx.close() does seem to work instead. So I'm wondering whats the difference between tx.commit() and tx.close() ? Are they ok to be substituted for one another?...

Extracting the ProjectStep of a GraphTraversal instance during unit testing

Tl;dr Given an instance of GraphTraversal<?, Map<String, Object>>, is it possible to extract the ProjectStep<?> which is producing the Map<String, Object> inferred by the type system, and which would be returned once a terminal step is applied? We only want to access the .projectKeys() of the ProjectStep, so we don't need to actually execute the traversal. It can be assumed that we are always dealing with an instance of GraphTraversal<?, Map<String, Object>>, and we do not have access to the actual graph in this environment. ...

When can we get a non-RC release for Python 3.11 support in Production Envs?

There was a bug where the version of aiohttp was too strict and blocked Python 3.11 support. ( https://lists.apache.org/thread/ln8wmg35cj4xn0rsyrhz7gj8otd161zs ) It's great that there was an RC deployment (3.6.3rc1 + 3.5.6rc1), but I'm uncomfortable running an RC in a production setting.

Subgraph query returns String instead of TinkerGraph Object in Fluent Java API

Hi guys. I am running the following query in the console and it works fine: g.V().has('user', 'id', 'Andrei').repeat(bothE().subgraph("subgraph").otherV().simplePath()).dedup().cap("subgraph").next(); I can then do a .traversal() on the Thinkergraph result. When I am using the Tinkerpop Java API, the next() step returns the following as a String: tinkergraph[vertices:11 edges:11]...

Multiple Graphs in Gremlin Server?

How do I manage multiple graphs? Is there an option where I can select which graph to use for query or will the query check each graph present in the server?...

Has anyone else encountered "NoSuchElementException" when calling getLeafTrees() on a tree object

Did a little bit of debugging and it seems that the issue has to do with a cast to Tree before calling the isLeaf() method inside getLeafTrees(). As far as my testing goes it seems to happen when a child of the root is a leaf. Here's an example dataset and the tree query: Data: ```g.addV('node::Dev').as('1'). property(single, 'data', 22).addV('node::Dev'). as('2'). property(single, 'data', 16).addV('root::Dev')....

The query gets slower as the number of vertices that already exist in JanusGraph gets bigger and big

When i start JanusGraph and perform any query like : - g.V().has(properties).limit(10).toList() - g.V(vertex).repeat(outE()).until(outE().count().is(0)) ( it will traverse about 3-4 vertices) - g.V().has(properties).next - g.addV()....... ( 1 vertex)...

Is there a limitation on Neptune HTTP API endpoint compatibility when using a proxy and IAM Auth?

Hi, Got a weird one today. I'm working on bringing full compatibility for the use of proxies fronting Amazon Neptune services. In my setup I have an Amazon Neptune cluster and an nginx proxy. The proxy runs on an EC2 container and provides connectivity to Neptune over a public domain. Additionally, my Neptune DB has IAM authentication enabled....