kelvinl2816
kelvinl2816
ATApache TinkerPop
Created by red on 10/14/2024 in #questions
Naming multiple vertices
When you say "apply" do you want to add a given name to a given vertex based on a given pair of vertex/name, or are you looking to filter in some way? Happy to try to help, but not fully understanding the question.
3 replies
ATApache TinkerPop
Created by nhthavn on 10/3/2024 in #questions
Neo4j news
Just my view - I like seeing the news from the broader graph community. Many of the activities are relevant more broadly such as all of the work going on with respect to Generative AI
4 replies
ATApache TinkerPop
Created by Max on 10/2/2024 in #questions
Confusing behavior of `select()`.
"cnt" is going to be a Long. By making the map keys explicit Long values, it works (as Long#equals will be true as far as the HashMap is concerned).
11 replies
ATApache TinkerPop
Created by Max on 10/2/2024 in #questions
Confusing behavior of `select()`.
This is caused (if you are using TinkerGraph for example) by Java's HashMap implementation and the fact that a Long will not match an Integer type.
g.withSideEffect("map", [3L: "foo", 4L: "bar"]).
inject("a", "b", "c", "d").
aggregate(local, "x").
map(select("x").count(local)).
as("cnt").
select("map").select(select('cnt'))

==>foo
==>bar
g.withSideEffect("map", [3L: "foo", 4L: "bar"]).
inject("a", "b", "c", "d").
aggregate(local, "x").
map(select("x").count(local)).
as("cnt").
select("map").select(select('cnt'))

==>foo
==>bar
11 replies
ATApache TinkerPop
Created by Max on 9/3/2024 in #questions
Gremlin query to order vertices with some locked to specific positions
you can play tricks like this to move the 0 index to last place, but that still leaves the 7 one row off
gremlin> g.V().hasLabel("Category").
......1> inE("belongsTo").as('a').outV().
......2> path().
......3> from('a').
......4> by(coalesce(values('lockedPosition'),constant(0))).
......5> by('name').
......6> fold().
......7> index().
......8> unfold().
......9> order().
.....10> by(choose(limit(local,1).limit(local,1).is(neq(0)),limit(local,1).limit(local,1),tail(local))).
.....11> by(limit(local,1),desc).
.....12> fold().
.....13> union(range(local,1,-1).unfold(),limit(local,1)).fold().unfold()
==>[[0,Product6],1]
==>[[0,Product1],2]
==>[[3,Product10],9]
==>[[0,Product7],3]
==>[[0,Product2],4]
==>[[0,Product8],5]
==>[[0,Product3],6]
==>[[7,Product9],7]
==>[[0,Product4],8]
==>[[0,Product5],0]
gremlin> g.V().hasLabel("Category").
......1> inE("belongsTo").as('a').outV().
......2> path().
......3> from('a').
......4> by(coalesce(values('lockedPosition'),constant(0))).
......5> by('name').
......6> fold().
......7> index().
......8> unfold().
......9> order().
.....10> by(choose(limit(local,1).limit(local,1).is(neq(0)),limit(local,1).limit(local,1),tail(local))).
.....11> by(limit(local,1),desc).
.....12> fold().
.....13> union(range(local,1,-1).unfold(),limit(local,1)).fold().unfold()
==>[[0,Product6],1]
==>[[0,Product1],2]
==>[[3,Product10],9]
==>[[0,Product7],3]
==>[[0,Product2],4]
==>[[0,Product8],5]
==>[[0,Product3],6]
==>[[7,Product9],7]
==>[[0,Product4],8]
==>[[0,Product5],0]
18 replies
ATApache TinkerPop
Created by Max on 9/3/2024 in #questions
Gremlin query to order vertices with some locked to specific positions
This is almost there, other than being zero based on the index and the 7 still being one row off
gremlin> g.V().hasLabel("Category").
......1> inE("belongsTo").as('a').outV().
......2> path().
......3> from('a').
......4> by(coalesce(values('lockedPosition'),constant(0))).
......5> by('name').
......6> fold().
......7> index().
......8> unfold().
......9> order().
.....10> by(choose(limit(local,1).limit(local,1).is(neq(0)),limit(local,1).limit(local,1),tail(local))).
.....11> by(limit(local,1),desc)
==>[[0,Product5],0]
==>[[0,Product6],1]
==>[[0,Product1],2]
==>[[3,Product10],9]
==>[[0,Product7],3]
==>[[0,Product2],4]
==>[[0,Product8],5]
==>[[0,Product3],6]
==>[[7,Product9],7]
==>[[0,Product4],8]
gremlin> g.V().hasLabel("Category").
......1> inE("belongsTo").as('a').outV().
......2> path().
......3> from('a').
......4> by(coalesce(values('lockedPosition'),constant(0))).
......5> by('name').
......6> fold().
......7> index().
......8> unfold().
......9> order().
.....10> by(choose(limit(local,1).limit(local,1).is(neq(0)),limit(local,1).limit(local,1),tail(local))).
.....11> by(limit(local,1),desc)
==>[[0,Product5],0]
==>[[0,Product6],1]
==>[[0,Product1],2]
==>[[3,Product10],9]
==>[[0,Product7],3]
==>[[0,Product2],4]
==>[[0,Product8],5]
==>[[0,Product3],6]
==>[[7,Product9],7]
==>[[0,Product4],8]
18 replies
ATApache TinkerPop
Created by Max on 9/3/2024 in #questions
Gremlin query to order vertices with some locked to specific positions
I do think considering data model changes, or just doing this in code within the application (if possible) would be simpler.
18 replies
ATApache TinkerPop
Created by Max on 9/3/2024 in #questions
Gremlin query to order vertices with some locked to specific positions
This is not quite there - but it is close
gremlin> g.V().hasLabel("Category").
......1> inE("belongsTo").as('a').outV().
......2> path().
......3> from('a').
......4> by(coalesce(values('lockedPosition'),constant(0))).
......5> by('name').
......6> fold().
......7> index().
......8> unfold().order().by(choose(limit(local,1).limit(local,1).is(neq(0)),limit(local,1).limit(local,1),tail(local)))
==>[[0,Product5],0]
==>[[0,Product6],1]
==>[[0,Product1],2]
==>[[0,Product7],3]
==>[[3,Product10],9]
==>[[0,Product2],4]
==>[[0,Product8],5]
==>[[0,Product3],6]
==>[[7,Product9],7]
==>[[0,Product4],8]
gremlin> g.V().hasLabel("Category").
......1> inE("belongsTo").as('a').outV().
......2> path().
......3> from('a').
......4> by(coalesce(values('lockedPosition'),constant(0))).
......5> by('name').
......6> fold().
......7> index().
......8> unfold().order().by(choose(limit(local,1).limit(local,1).is(neq(0)),limit(local,1).limit(local,1),tail(local)))
==>[[0,Product5],0]
==>[[0,Product6],1]
==>[[0,Product1],2]
==>[[0,Product7],3]
==>[[3,Product10],9]
==>[[0,Product2],4]
==>[[0,Product8],5]
==>[[0,Product3],6]
==>[[7,Product9],7]
==>[[0,Product4],8]
18 replies
ATApache TinkerPop
Created by Max on 9/3/2024 in #questions
Gremlin query to order vertices with some locked to specific positions
I wonder if the solution to a similar situation I posted in the tinkerpop-tips area could be used here as well? https://discord.com/channels/838910279550238720/1156920912206110834/1254910222837874759
18 replies
ATApache TinkerPop
Created by Max on 9/3/2024 in #questions
Gremlin query to order vertices with some locked to specific positions
Are you able to share a small test graph (a few addV and addE steps) ? Having that makes writing tested answers a lot easier.
18 replies
ATApache TinkerPop
Created by danielcraig23 on 4/18/2024 in #questions
.mergeV() with Javascript not working
Is it possible the vertex already existed?
28 replies
ATApache TinkerPop
Created by rpuga on 3/23/2024 in #questions
mergeE(): increment counter on match
Currently no unfortunately. It will depend on what is in the stream until changes can be made to the way the step is working today. I called out this case mainly as an example of a behavior that needs to be supported in some way (as it is very useful).
16 replies
ATApache TinkerPop
Created by rpuga on 3/23/2024 in #questions
mergeE(): increment counter on match
FYI @spmallette and @Valentyn Kahamlyk this is I think one of the key cases where being able to do additional work inside onMatch is very useful.
16 replies
ATApache TinkerPop
Created by rpuga on 3/23/2024 in #questions
mergeE(): increment counter on match
So @rpuga that is one way you can (with the current latest version) make this work. Regarding EventStrategy @Flynnt , those only really make sense when the graph is embedded into the application (as a TinkerGraph can be). In order to catch database wide changes you need something more like the Amazon Neptune CDC stream, or JanusGraph triggers.
16 replies
ATApache TinkerPop
Created by rpuga on 3/23/2024 in #questions
mergeE(): increment counter on match
@spmallette has been working on some PRs to improve a few mergeE behaviors. I would like him to comment on whether my example will still be vallid after those updates land.
16 replies
ATApache TinkerPop
Created by rpuga on 3/23/2024 in #questions
mergeE(): increment counter on match
gremlin> g.mergeE([(Direction.from):44,(Direction.to):8]).valueMap(true)
==>[id:5062,label:route,dist:549]
gremlin> g.mergeE([(Direction.from):44,(Direction.to):8]).valueMap(true)
==>[id:5062,label:route,dist:549]
and then
gremlin> g.mergeE([(Direction.from):44,(Direction.to):8]).
......1> option(onMatch,property('dist',union(values('dist'), __.constant(1)).sum()).constant([:])).valueMap(true)
==>[id:5062,label:route,dist:550]
gremlin> g.mergeE([(Direction.from):44,(Direction.to):8]).
......1> option(onMatch,property('dist',union(values('dist'), __.constant(1)).sum()).constant([:])).valueMap(true)
==>[id:5062,label:route,dist:550]
16 replies
ATApache TinkerPop
Created by rpuga on 3/23/2024 in #questions
mergeE(): increment counter on match
So long as mergeE is used as a start step, I think you can make this work. But it maybe that this ability needs to get disabled temporarily in order to prevent some error conditions we have seen lately from happening as @Valentyn Kahamlyk mentions while we rework the mergeE semantics a little. I'll post an example in a bit. Need to type one up.
16 replies
ATApache TinkerPop
Created by mrckzgl on 3/11/2024 in #questions
Stackoverflow when adding a larger list of property values using traverser.property()
That's the same thing. You are just building it up stepwise. The stack overflow can (and does) still happen if you built them all inline.
19 replies
ATApache TinkerPop
Created by mrckzgl on 3/11/2024 in #questions
Stackoverflow when adding a larger list of property values using traverser.property()
So just to clarify, you are not doing something like .property().property().property().... 4000 times but doing something different?
19 replies
ATApache TinkerPop
Created by mrckzgl on 3/11/2024 in #questions
Stackoverflow when adding a larger list of property values using traverser.property()
You can check the stack size a JVM is currently using, running a command like this one:
$ java -XX:+PrintFlagsFinal -version | grep ThreadStackSize

intx CompilerThreadStackSize = 0
intx ThreadStackSize = 1024
intx VMThreadStackSize = 1024

$ java -XX:+PrintFlagsFinal -version | grep ThreadStackSize

intx CompilerThreadStackSize = 0
intx ThreadStackSize = 1024
intx VMThreadStackSize = 1024

19 replies