Apache TinkerPop

AT

Apache TinkerPop

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

Join

Does anybody know

I am C# developer using the Tinker pop nuget package v3.6.2 .I am struggling with a poblem with regex search. actually everytime I run my code it just goes for ever and nothing returns back until I shutdown the the app. Can anybody help me here: my code is looks like this var test1 = g.V().Has("names", TextP.Regex("^Majid*"));...
Solution:
Just to summarize here, I think the failure is expected since you are using operators from 3.6.x that Neptune doesn't know how to deal with yet (soon though!). I do find it strange that these traversals dont get an immediate error when it encounters those though. I still would like to know how long you are waiting for the query to return and what exception it is returning with or if it hangs indefinitely (at least past the 2 minute default). I think if it is hanging indefinitely then there might...

what are the pros and cons of using tinkerpop based graph vs enterprise vendors neo4j or tigergraph

Hi team, I am currently in process of choosing a graph database for some realtime usecases and was really wanted to know opinion of this community around pros and cons of using tinkerpop based graph vs enterprise vendors like neo4j or tigergraph....
Solution:
i think you can get all kinds of answers for this question. i'll just offer that i dont think comparing "TinkerPop" to a specific graph is a good way to do an evaluation. TinkerPop isn't a graph database so to compare it one isn't really comparing the right things. It's better to compare the features and capabilities of one graph database to another. You might compare TigerGraph to a TinkerPop-enabled graph like JanusGraph or Neptune. You could then say TigerGraph uses GSQL as a query language a...

upsert not working properly in specific cases

Hello, We have a upsert utility function in Gremlin that gets a name and a label, then either fetches it if it exists or creates it, then sets it with specific values. The query looks like this: ```...
Solution:
There were a number of improvements to the upsert pattern between versions 1.0.3.0 and 1.0.5.0. FWIW, 1.0.3.0 is now deprecated as of Jan 30th of this year.

running in k8s

Are there any nuances to running in k8s, are there helm charts or manifests available?
Solution:
TinkerPop hasn't done much officially with k8s to my knowledge, so the project itself doesn't have anything like that I'm afraid. Not sure if @triggan has anything that he could offer on this front?

Serialize custom sack

When trying to return the value of a custom sack object with .sack(), following error is thrown: ``` 2023-02-03 12:40:20 java.lang.IllegalArgumentException: Class is not registered: org.apache.tinkerpop.gremlin.server.jsr223.ScriptData 2023-02-03 12:40:20 Note: To register this class use: kryo.register(org.apache.tinkerpop.gremlin.server.jsr223.ScriptData.class); 2023-02-03 12:40:20 at org.apache.tinkerpop.shaded.kryo.Kryo.getRegistration(Kryo.java:488)...
Solution:
TinkerPop completely retired Gryo (kryo) for use as a network serialization format in 3.6.x. You should probably switch to GraphBinary serialization. With GraphBinary you will get a similar problem though. You would need to write a custom serializer for your object and install it in the client and server GraphBinaryMessageSerializer. The format for GraphBinary custom objects is shown here: https://tinkerpop.apache.org/docs/current/dev/io/#_custom There are tests that show how to create a custo...

GremlinGroovyScriptEngine to submit bytecode from string vs Client to submit query as string

Hey, Bit of a weird question here but I'm trying to decommission the (potentially never actually useful) use of the GremlinGroovyScriptEngine. "Historically" the GremlinGroovyScriptEngine was used to convert queries written in the query editor as String to bytecode for submission via a GraphTraversalSource generated in the backend. My question essentially is: can I completely rely on the Client instead to submit queries as string? The main limitation of the GremlinGroovyScriptEngine (groovy dependency aside) is that when submitting queries for non Gremlin technologies (e.g. JanusGraph) it leads to script execution errors when submitting JanusGraph specific predicates, for instance....
Solution:
i don't think there is much value to bytecode itself. that may sound weird because we promote use of bytecode so much, but we promote it more for the idea that you develop your applications without embedding scripts in your code and getting the development gains that come with using Gremlin as code itself. in your case, and similar tools, i think your Gremlin currency is the script and converting it to bytecode first for submission probably doesn't give you too much benefit and as you've found likely just gets in the way (you already outlined the problems with trying to transform those scripts for various graph providers).
As far as "fundamental differences" i don't think there are many and I assume you were doing a Client.submit() with your bytecode which means you were already dealing with a ResultSet object for your result so going to scripts should present no difference there....

Set TTL for vertex

Can i set TTL for vertex after running janusgraph about 4 months?
Solution:
From https://docs.janusgraph.org/schema/advschema/#vertex-ttl :
mgmt = graph.openManagement()
tweet = mgmt.makeVertexLabel('tweet').setStatic().make()
mgmt.setTTL(tweet, Duration.ofHours(36))
mgmt.commit()
mgmt = graph.openManagement()
tweet = mgmt.makeVertexLabel('tweet').setStatic().make()
mgmt.setTTL(tweet, Duration.ofHours(36))
mgmt.commit()
...

addV with existing ID doesn't throw error

I noticed when I call addV(newLabel) with an existing ID but a different label, it will add the newLabel and the new properties defined to the existing vertex. This is verrrry undesirable behavior, I would need to it throw a constrain violation. Any thoughts?...
Solution:
This works on Neptune b/c of the support for multiple labels. :/

Concatenating details with specified property key

Hey all, I'm trying to get an array of objects back from Gremlin that looks like the following: ```js [{...
Solution:
A minor point on your attempt to statically produce the output you wanted, but it is considered better form to use tokens when you can in the by() modulators: ```groovy g.V().hasLabel('ServiceGroup'). project('id', 'label', 'name', 'services')....

using mergeV/E

Hello I’m trying to upgrade my gremlin package to latest and running into an issue with mergeE and mergeV. I’m using this to replace some coalace steps that I was using before. How do you set the label in mergeV() for the particular vertex. I see I can pass the T.label in the map but, I don’t understand what the equivalent of this would be for JavaScript
Solution:
Another approach would be to inject a list of maps and do something like this: ``` var newNodes = [] newNodes.push(new Map([[(t.id),1],...

How to connect to a specific graph on Gremlin Server?

Provided a Gremlin server configured with multiple graphs in the graph property of the gremlin server configuration as below: ``` host: localhost port: 8182...
Solution:
we have a Gremlin Server startup script which uses the ConfiguredGraphFactory to look up the application's graph and which creates it if not yet present.
I think that shouldn't be necessary as ConfiguredGraphFactory should already create a graph traversal source automatically for every created graph with then name <graph.graphname>_traversal. But you can of course still do it like that if you want to...

Limiting .path() results to a number of valid starting vertices

Hey folks, for context, we're using AWS Neptune, and Neptune Notebook for visualisation. We would like to visualise neighbourhoods of data with a given criteria: 1. We would like an exact number of neighbourhoods, e.g. 5 distinct neighbourhoods 2. We only want to consider neighbourhoods that have a particular node in its tree Example:...
Solution:
Just realized that the approach I suggested with project() doesn't need deduplication - just need to unfold() the collection to get back to the original form: ```gremlin> g.V().project('s','e'). ......1> by(). ......2> by(out().hasLabel('software').path().fold()). ......3> filter(select('e').unfold())....

Gremlin server plugin for running additional function on each vertex edge

Dear TinkerPop team, I'm currently trying to wrap my head around a specific problem I've been trying to solve for a few days. Basic overview:...
Solution:
you understand them properly, but you perhaps didn't connect their use to your case. you would define a TraversalStrategy that replaces steps that traverse vertex/edge data like out() or inE() with your own implementation for those steps. in that way you will have access to the vertex/edge Traverser as it passes through the step. i suppose you could also consider adding a special step that wraps those steps or follows them depending on your needs. i'm not sure which is best offhand.

Option to be a range of values

Is there a way to provide an option after a choose step that includes a range of values in it? For example, option(1..100, ...)...
Solution:
option(__.is(P.between(1, 100)) should do the trick

Ciel function in Math step doesn't seem to work

Ciel function in Math step doesn't seem to work. ``` __.values(VERTEX_PROPERTY_RATE) .as('rate') .select('product')...
Solution:
ciel is mistyped. i believe you want ceil. the error is stating that math() does not recognize ciel as a function essentially and is treating it as a variable. since there is no definition for that it is null and math() doesn't like that.

Grouping and projections help

Hey everyone, I'm trying to execute this query: ```js g.V('0x77696bb39917c91a0c3908d577d5e322095425ca')...
Solution:
You can just add a group().by('from') to the end of what you have. as an example with the modern graph: ```gremlin> g.V().project('name','degree').by('name').by(bothE().count()) ==>[name:marko,degree:3] ==>[name:vadas,degree:1] ==>[name:lop,degree:3]...

Weird Error using inE()

Hey everyone, ```js g.V() .hasLabel("TokenTransfer")...
Solution:
glad you figured out the problem. usually those sorts of errors have to do with having no data when you expect to have some. also, note the difference between inlining your inE() and placing it inside a by() is that when you inline Gremlin just follows the edges he finds. so in cases where there is a vertex with no in edges he just stops there and that traverser is filtered away. on the other hand when Gremlin is traversing the same vertex within by(), the by() forces Gremlin to traverse...

Neptune - multiple labels

Hey, For some reason we had a few objects that had multiple labels. This was done via a huge script and we couldn't find anything that caused it. Now that the vertices have multiple labels, one of which is correct, is there a way to remove the other labels, or do we have to remove them and recreate the vertices?...
Solution:
Gremlin will not allow for you to remove labels. However, since Neptune supports both Gremlin and openCypher on the same data, you could use the openCypher support to remove the unwanted label(s): For a vertex created with Gremlin using: ``` g.addV('test1::test2').property(id,'testV001')...

Use statement from choose and option that check only if a value has been yielded

Hey everyone, .choose( __.out(EDGE_TOUCHPOINT_ACTION_ITEM) .hasLabel(VERTEX_LABEL_ACTION_ITEM)...
Solution:
i'm not sure i fully understand, but perhaps that's not relevant and i should just try to answer the question.

identity() on Neptune on a vertex

Hey all, hope you're doing well. I'm seeing an interesting behavior in Neptune (and also local gremlin server) where doing identity() on a vertex returns its id, label and the "properties" object. However the object is undefined even though it has some properties such as userId. Is this a known behavior?...
Solution:
I believe this is expected. As this post pertains to javascript, I seem to recall that properties was placed there with the idea that there was future potential to include actual properties on elements. There is a long history for why we do not yet do that and you can read about it here: https://lists.apache.org/thread.html/e959e85d4f8b3d46d281f2742a6e574c7d27c54bfc52f802f7c04af3%40%3Cdev.tinkerpop.apache.org%3E That said, we are working on finally implementing this functionality which will a...