Apache TinkerPop

AT

Apache TinkerPop

Join the community to ask questions about Apache TinkerPop and get answers from other members.

Join

G.V Graph Playground: Gremlin client

@G.V() - Gremlin IDE (Arthur) Quick question: Does G.V graph playground allow adding vertices & edges programmatically? In other words, can I use a gremlin client to connect to the playground graph?
Solution:
Hey not at the moment but that's on the roadmap, I'm working through a big 2.0 rewrite atm which should be out by end of January and hoping to have G.V() playgrounds served by a gremlin server managed by g.v before end of q1, I don't think it should be too much work

Splitting a query with range()

I have a Gremlin Query that starts simple (one Label), and then branches out to many different paths to collect unrelated informations (aka, I need to follow those paths). I'm considering using range() to break down that query into smaller chunks of, say 1k rows' and avoid processing the whole set of Labels into one. Of course, I'll have to run the query several times, but I expect each run to be faster, better fit in memory. May be I'll escape some fast degradation by keeping the load small enough. Does that sound like a good idea? I'm usually concerned such partitioning means that the common part of the query (before the range()) is executed several times, and that limits the speed potential. In the current case, it is merely a hasLabel() + some property collection. ...
Solution:
I have often used range() steps to break up queries, it can be a useful technique but does come with several caveats. The most important piece is that this will only work if your database guarantees that the common part of your query will always produce results in a consistent order. The default implementation of range(x, x + 1000) will first iterate and discard the first x results, then pass the next 1000. If the result ordering changes on each execution, then you will essentially be taking a random sample of 1000 results each time, instead of progressively going batch by batch. You already mentioned the performance concerns with the common part of the query being executed each time, due to the way this is implemented, this performance penalty is proportional to x (minimal penalty when x is small as almost no results are skipped, larger penalty with large x as many results need to be processed and skipped). Results will depend greatly on your DB and your data but in general, if the left-hand side of the query is fast and efficient in your DB, and the right-hand side is slow and complex, then this technique works quite well....

Exception saving as Gryo

When trying to save as gryo getting the error, Unable to create serializer "org.apache.tinkerpop.shaded.kryo.serializers.FieldSerializers" for class java.util.concurrent.atomic.AtomicLong. What could be the possible reason.
Solution:
With some trail and error found the solution - openjdk is possibly the reason. I traied with standard jdk/jre, now it works.

AWS Neptune: Pong fails and close event not emitted

Hey guys, long time no see. We have an issue which occurred a few times in the last couple weeks and we've been investigating for a while; posting here in case the issue is maybe known. We are using the gremlin-aws-sigv4 in a NodeJS project. We occasionally do a ping to the server and wait for a Pong with a timeout of 3 seconds....
Solution:
Interesting approach. Our typical guidance is to not worry about whether or not the connection is live and assume it is always available. Then build in exception handling and reconnect logic for the condition when a query is sent to a closed connection. Neptune will close connections on the server side if they are idle for more than 20-25 minutes.

Gremlin upsert on a vertex but preventing updates on a particular property on a vertex during upsert

Hi, Following is an upsert query on a vertex with label 'stvertex' and I am required to initialize and default the 'flagProp' to 0 only during creation of this vertex but during update I am required to prevent any update only on 'flagProp' while rest of the property should update, below is one of the approach I took: g.V(id).fold().coalesce(unfold(), __.addV(‘stvertex’) .property(T.id, id).property(Cardinality.single, flagProp,0)) .property(Cardinality.single, name, nameValue) .property(Cardinality.single, station, stationValue) .property(Cardinality.single, base, baseValue).next() The above query only works for creation of new vertex I am looking for some help to write the correct query which works for update as well...
Solution:
Hi Salman, Better to use mergeV step. You may set flagProp in onCreate option, and create/update all other properties in both onCreate and onMatch, something like `gremlin> g.mergeV([(T.label):'stvertex'])....

Does graph notebook still work after changes to serializers?

I am trying to use the graph-notebook project, my project previously worked. I updated Aerospike graph to the latest version of tinkerpop and with it the serializers were updated. Trying to run any %%gremlin now results in an error of ```...
Solution:

Implementing Graph Filter for Sub-Graph Loading in Spark Cluster with JanusGraph

Hello, I'm currently utilizing JanusGraph 0.6.4 with Bigtable as the storage backend and encountering difficulties when attempting to run OLAP queries on my graph via SparkGraphComputer. The graph is quite large, containing billions of vertices, and I'm only able to execute queries on significantly smaller graphs. My queries are being run through the Gremlin console, and the problem appears to be related to loading the graph into Spark RDD. I'm interested in applying a filter to load only vertices and edges with specific labels before running the query....

Testing against AWS Neptune

Hi, the app that I'm maintaining has a Neptune integration for which I've written some integration tests. For those tests I'm using gremlin-server which so far is fine, but because of the cardinality difference between Neptune and other Gremlin implementation I get different behaviour in prod vs testing. Of course, this is a known difference, but I'm wondering if there's a solution that emulates the Neptune engine locally for such use cases. I could spin-up a new Neptune instance at testing time, but that seems a bit of an anti-pattern. What do people do to test the clients against multiple engines, if at all?...
Solution:
Hi, the main solution I've seen around for such use case (and I'm using myself) is to start the gremlin-server using a custom configuration. Basically what you need to do is create a custom 'gremlin-server.yaml' file with the server config. There is a field called graphs in this file, which you can use to specify the path to a custom property file. This property file is where you define your graph properties, and in your case the defaultCardinality....

Janusgraph vertex property with cardinality as SET type

Hi, need a working example of how a property can be added to a vertex with cardinality as SET type and how we can retrieve it and assign it to SET of strings in JAVA. Please note: I have tried the janusgraph doc code, google search, chat GPT but every time I put something in that property through java code it get stored in STRING format only. Ex: "["ABC"]" --> current , ["ABC"] --> this I need. ...
Solution:
for JanusGraph you'd want to set up the schema for your multiproperty: ``` mgmt = graph.openManagement() mgmt.makePropertyKey('p').dataType(String.class).cardinality(Cardinality.SET).make() mgmt.commit()...

Error: `Failed to authenticate`, when connection pool size is >1 for GremlinServer with ArcadeDB

Hi Friends, I am exploring and evaluating ArcadeDB. The DB is setup with GremlinServerPlugin to expose GremlinServer at port 8182. Using SpringBoot to create client app. `@Bean...

How can I use the .io("filename.json").write() pattern to append to an existing graphson file?

I have read about defining a custom GraphWriter using the builder, but wanted to ask first before spending more time Here is my example code: ``` private static Graph buildGraph() {...
Solution:
The subgraph is stored as a side-effect, so you could use withSideEffect() to give it your own graph instance and then reuse that across multiple traversals to subgraph: ```gremlin> g = TinkerFactory.createModern().traversal() ==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard] gremlin> sub = TinkerGraph.open() ==>tinkergraph[vertices:0 edges:0]...

using tinkerpop 3.6.x on a jdk 21 project

I'm using tinkerpop 3.6.5 to read/write over an AWS neptune graph database. Is there any issues using this library on a jdk 21 project ? While the doc says "You can now run TinkerPop with Java 17." : https://issues.apache.org/jira/browse/TINKERPOP-2703 I have the impression it's only regarding Gremlin console that I do not use....
Solution:
I've not personally tried JDK21 so I can't say for sure how TinkerPop and its dependencies will behave. Note that as of right now we do not use any features of Java beyond JDK8, continually test builds on JDK8, 11 and 17 and that we release on JDK8 bytecode. So presumably, any JDK that can run JDK8 should be able to use TinkerPop without trouble. In practice of course it's hard to say that there aren't subtle differences among JDK versions that you could encounter. As an example, I can think of...

Is the following use of next() allowed?

The update does not seem to work in this case, even when changes is a non-empty object. No error is raised, and when I printed the result, it has { value : null, done : true }. ```
const changes = { ... } let v0 = g.V(0); if (!(await v0.next()).value) {...
Solution:
It turns out, no, that's not allowed. It seems like done: true signifies that the traversal sequence was already committed and I'm doing basically nothing.

Gremlin-go cannot bring out props when querying Vertex with Neptune

```golang g := gremlingo.Traversal_().WithRemote(driverRemoteConnection) traversal := g.GetGraphTraversal() result, err := traversal.V("v-1").Next()...
Solution:
The short answer is that you can get properties on your returned elements after 3.7.0 - https://tinkerpop.apache.org/docs/current/upgrade/#_properties_on_elements (note that the graph database that you are using must also support 3.7.x). If you care about the long answer then you should read this: https://lists.apache.org/thread.html/e959e85d4f8b3d46d281f2742a6e574c7d27c54bfc52f802f7c04af3%40%3Cdev.tinkerpop.apache.org%3E
No description

search for vertices where multiple properties

I need to search for vertices where multiple properties are a certain value. Here is what I am able to come up with. ``` try (TinkerGraph graph = TinkerGraph.open()) {...

repeat and until methods in Javascript Gremlin:

I'm not particularly sure how to use them properly. From my current understanding, repeat() and until() are both instance methods of the GraphTraversal class, but how do I reference any methods within the class body but still refer to the same reference?
const org = await g.V().until((r) => r.hasLabel('')).repeat({...}).path().by('name').next()

const org = await g.V().until((r) => r.hasLabel('')).repeat({...}).path().by('name').next()

...
Solution:
I think this section of the documentation will help with imports: https://tinkerpop.apache.org/docs/current/reference/#gremlin-javascript-imports In particular: ``` const = gremlin.process.statics; const org = await g.V().until.hasLabel('b')). repeat(__.in())....

Gremlin driver setup for Amazon Neptune behind a Load balancer

Hi folks, I've been running into issues connecting to Amazon Neptune behind an HAProxy as detailed on https://aws-samples.github.io/aws-dbs-refarch-graph/src/connecting-using-a-load-balancer/ (2nd option) The issue is to do with sending subsequent queries via a graph traversal source where it appears to cause NoHostAvailableExceptions frequently. The interesting part here is that this only happens when a Graph traversal source is reused. I'm using Gremlin driver 3.7.0 in Java....

Gremlin (with Python + Neptune) Out of Memory Error with .toList()[0], .next() Fixes It. But Why?

This is not really a question, but more of a discussions on how internally this would cause an out of memory error. I have the following construct and last night, it resulted in out of memory error. * path_v is a single well defined V. I am expecting it is returning a single V....

AWS Neptune and gremlin-javascript versions

Hi, I'm using the js gremlin client 3.6.2 with AWS Neptune version 1.2.1.0 and I get the following error when trying to upsert nodes with mergeV() ``` ResponseError: Server error: {"code":"InternalFailureException","requestId":"aa89ee40-74d5-46c1-9ad5-0bc3f2fde5c1","detailedMessage":"null: .option(LinkedHashMap, LinkedHashMap)","message":"null: .option(LinkedHashMap, LinkedHashMap)"} (599)...
Solution:
That's a strange error because the error seems to indicate that option() is being called with two Map arguments, but your example does not seem to indicate that you are doing that. It's interesting that 3.7.0 "fixes" it because I can't think of any reason why that would matter. Perhaps you could try 3.6.5 to see if there were somehow changes after 3.6.2 that solved this problem? Regarding your more general question of:
My question is: does the version of the javascript client match the version of the server (or should it)? Or should I always strive to use the latest client?
Generally speaking you should follow the version table here https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-client.html - While it is possible that versions outside of those ranges in that table will work with one another, those are the versions that Neptune tests against and that are supported....

Docker Janusgraph Custom ID Values

I'm trying to setup a janusgraph database with custom verex ID values. I have the following docker-compose configuration: ```yaml version: '3.8' services:...
Solution:
You could do both ``` graph.set-vertex-id=true graph.allow-custom-vid-types=true...