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").
by(__.unfold().values("...").dedup().count()).
by(__.unfold().
repeat( __.in()).
emit(__.<etc>))

g.V(..).in(..).<some contraints that do not change it from a vertex).
fold().project("visits", "form").
by(__.unfold().values("...").dedup().count()).
by(__.unfold().
repeat( __.in()).
emit(__.<etc>))

The problem is because of the fold it loses the type and then the type going into the repeat will not allow me to execute an in() step. I tried casting the unfold() and the in() to GraphTraversal<Vertex, Vertex> and variations of that with 1 vertex switched for Object. I cannot get this to compile. Anyone have any ideas on how to cast this properly?
5 Replies
Lyndon
LyndonOP17mo ago
If I switch the by(__unfold() for by( V() it works but obviously that isn't what I want and i cant cast it to the type of V()...
redtree1112
redtree111217mo ago
I may be missing something but if you unfold() immediately after fold(), can you just omit it ? or does this work ?
.by(__.<Vertex>unfold().repeat(__.in()))
.by(__.<Vertex>unfold().repeat(__.in()))
Lyndon
LyndonOP17mo ago
problem is when you go into the project without the fold it just gives 1 item in and so you have to fold before hand
redtree1112
redtree111217mo ago
Ah I see. Does specifying a type in generics above work ?
Lyndon
LyndonOP17mo ago
it did not, sorry I was moving and was away for a while I havent found a way to do it so I just rewrote the query to not require it
Want results from more Discord servers?
Add your server