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
Lyndon10mo 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
redtree111210mo 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
Lyndon10mo 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
redtree111210mo ago
Ah I see. Does specifying a type in generics above work ?
Lyndon
Lyndon10mo 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
More Posts
valueMap and MultivaluesI was going to use the recipe from @KelvinL 's book to return lists only when the property has multiAWS Neptune bulk load notificationsI wonder if anyone has knowledge of a way to receive a notification event(s) for bulk loading. RightVertexProgram filter graph before terminationI have a VertexProgram that operates on vertices of type A and B. B vertices are "below" A verticesStraightforward way to render a force directed graph svg/pngI was wondering if there is a "simple" way in java for me to take a GraphTraversal and render a forcCan't do explain() traversal step using Gremlin-Python ..Hi I just started messing around in gremlin-python this week, so likely to be doing something wrong Gremlin Query for amount of time and return all results?Is there a way to make gremlin keep running until time elapses then return the results? I have a queHow do I make a ssl connection using only ARN from neptune (AWS)I have a simple connection in my project using remotecon = DriverRemoteConnection(neptune_url) But Can gremlin-server be started via its Java packageI'm considering exposing the G.V() Playground graphs, which runs on TinkerGraph, to the network via Getting Property Out of a Variable in Python Gremlin QueryI've been working on attempting to find a performance way to route from point A to point B. Right nThe Cascading Coalescing - Create a V then Create an E in One ShotI have been struggling with this and perhaps I can ask some expert on how to approach this type of i