Apache TinkerPop

AT

Apache TinkerPop

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

Join

project("p").by(__.values("a", "b") Only Outputs Single Property, Bug or Expected?

I am curious why this does not behave in the way I expected. Not a problem - solution question. I created the following Gremlin: ` g.E()....
Solution:
i think the more specific way to answer this question is to say that by() modulators only grab the first item in the traversal provided to it so if you want all of them you need to provide your own reducing operator to convert all the items into a single one. typically this is done with fold(): by(__.values("localId", "uuid").fold())e...

Use of by()

Can somebody explain the usecase of by() function in gremlin in very simple language.
Solution:
by() is a step modulator, meaning it modifies the step it is being applied to in some way by giving it some additional instruction. an easy example to see this with is groupCount():
gremlin> g.V().groupCount()
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1,v[6]:1]
gremlin> g.V().groupCount()
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1,v[6]:1]
Calling groupCount() without modulation implies the default behavior of grouping on the incoming traverser (i.e. the current Vertex). Each Vertex is simply counted once as a result as they are each unique entities. If we want to change that grouping behavior, we modulate that step with by(), like: ```gremlin> g.V().groupCount().by(label)...

@GremlinDSL support in the GremlinLangScriptEngine

Hi, I recently sent a pull-request into the github ArcadeDB repository to add support binding custom TraversalSources to the embedded graph bound in the script engine. ArcadeDb has modes to support both the GremlinLangScriptEngine and the GremlinGroovyScriptEngine. https://github.com/ArcadeData/arcadedb/pull/1239...
Solution:
The two ScriptEngine implementations are not meant to have complete feature parity. GremlinLangScriptEngine does not process arbitrary code. It only processes Gremlin, which I tend to think is a good thing compared to GremlinGroovyScriptEngine which will run any arbitrary code and is therefore a bit of a security risk. That said there is some untangling to do in Gremlin Server, ScriptEngines and the grammar and that's the main reason TinkerPop has not yet promoted GremlinLangScriptEngine over its groovy counterpart despite it being more secure and generally more performant than both groovy and bytecode. This is the reason why we don't have much documentation on it. I believe that you should be able to process Gremlin that originated from a DSL in the GremlinLangScriptEngine but you couldn't do it in the fashion you can with groovy. To understand how it's worth noting that any DSL step is really just a compositions of standard Gremlin steps. in other words, a DSL step like: g.persons() might really just compose as: g.V().hasLabel('person')...

RepeatStep does not appear to respect barriers

I was digging into some traversal performance and had something similar to the following:
g.V(<ids>).repeat(out()).until(out().count().is(0)).toList()
g.V(<ids>).repeat(out()).until(out().count().is(0)).toList()
...

Trying to find a Vertex using a variable injected earlier in the traversal

I am trying to add a series of vertices and edges to an existing graph. The newly created Vertex will be the to Vertex. From business logic, I will know the ID of the from Vertex for the new Edge . I am able to create the new Vertex without any issue, but when I am having trouble grabbing the from Vertex to create the edge. Is there a way to do this/what am I doing wrong? ```g.inject(["myID": "2", "parentID": "1", "properties": ["key1":"value1"]]). addV("MyVertex").as("newVertex"). property(id, select("myID"))....

Does Gremlin support API for CRUD operations?

Currently using g.V() for read and g.addV() for write.

Individual Vertex per property or Vertex with grouped properties

I'm building an identity graph that also stores User profile data - things like email address, phone number, address, company information, etc. Is there a generally accepted best practice for whether to store those attributes in their own vertex or group them in a vertex? The graph is part of a transactional system that will need to retrieve a complete user profile,

Filter out empty results

gremlin> g.V().hasLabel('metadata').valueMap() ==>{} ==>{} ==>{oncall_roster=[oncall_schedule]} ...

Question on running queries in windows env.

I get an error RuntimeError: Event loop is closed, but after troubleshooting I notice that my script ran just fine. It crashed after the script eded. I suppose I was just ignoring it at first, but should I? I'm using asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) . Should I just ignore the error or should I deal with it? if the latter, how?

PropertiesStep.hashcode() not always unique

As background... We're working with Gremlin (groovy) to write queries against an in memory graph model implemented in java. I've implemented a custom traversal strategy that will find all PropertiesStep instances in the traversal and prepend a custom step to each one (I could go into more detail but it's not actually relevant to my question). While implementing the apply method of the strategy I was getting the index of the PropertiesStep instances using the indexOf method:...
Solution:
On the other hand, @dbns97_61020 's issue is that we have the exact same PropertiesStep under the same traversal. I am not sure if we need to improve that part, a user might need to specify the Step they want by its index, or use == and compare by reference (you need the reference of the exact object in advance though). You may also rely on Step ID to identify some Step in such case as well....

Trying to run a local version for a test, what is the correct serializer?

Windows machine, local host. I can't find the Running this, https://github.com/bricaud/gremlin-server but updated the version to apache-tinkerpop-gremlin-server-3.7.0 I had issue with the serializers: section of the gremlin-conf.yaml so I commented out to see if the defaults would work. The docker image loads fine, but then I can't seem to connect to it. ...

adding edges to multiple vertices at once

Hey all. Working with tinkerpop on Cosmos Gremlin DB which is horrific. Wondering is there anyway around adding an edge from multiple vertices at the same time? For example...

Does .math() always return a Double?

I have the following query, how can I get the result as a Long instead of a Double? In context, I want this query to be unioned with a set of other numbers which are Longs and then I want to take the .max() of them. But I can't do that if I have a mix of Long and Double
Long tenHours = Long.valueOf(Duration.ofHours(10).toMillis());

g.withSideEffect("tenHours", tenHours).inject(1689570000000L).math("_ + tenHours").next().getClass()
Long tenHours = Long.valueOf(Duration.ofHours(10).toMillis());

g.withSideEffect("tenHours", tenHours).inject(1689570000000L).math("_ + tenHours").next().getClass()
...

Trying to update a property value based on another property

I have a query that looks something like the following g.V('9999').hasLabel('someLabel').properties('PropertyName').hasId('1234').property('currentDate',12/12/2023).property('previousDate',10/10/2023) Using this query when an Id matches the passed value on hasId the data needs to be updated. I'm able to update currentDate & previousDate, which is a meta property, on the following data, however I'd also like to update the 'value' field which is on the same level as the 'id' field. My question is how do I tweak the query to also update the value along with the Dates....

Casting issue with Gremlin Java

I wrote the following query and I can't get it to compile, tried a ton of casting but it just isn't happy... ``` g.V(..).in(..).<some contraints that do not change it from a vertex). fold().project("visits", "form")....

valueMap and Multivalues

I was going to use the recipe from @KelvinL 's book to return lists only when the property has multiple values: ``` l, err := g.G.V(id).HasLabel("geoname"). ValueMap().With(gremlingo.WithOptions.Tokens)....

AWS Neptune bulk load notifications

I wonder if anyone has knowledge of a way to receive a notification event(s) for bulk loading. Right now, one can poll via the https endpoint, but that would require having a container running somewhere that did this.
I was rather hoping to configure an SNS notification for say status change "LOAD_STARTED"... etc. The JSON given by the https: calls would be fine as having received the notification, I can use the standard calls to retrieve errors and more detailed information etc. Fairly standard pattern: SNS->lambda function-><do something>...

VertexProgram filter graph before termination

I have a VertexProgram that operates on vertices of type A and B. B vertices are "below" A vertices. The VertexProgram aggregates stuff about the underlying B vertices into their common parent A vertex....

Straightforward way to render a force directed graph svg/png

I was wondering if there is a "simple" way in java for me to take a GraphTraversal and render a force directed picture of the graph or subgraph it returns?