[ 
https://issues.apache.org/jira/browse/TINKERPOP-3223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18050697#comment-18050697
 ] 

Stephen Mallette commented on TINKERPOP-3223:
---------------------------------------------

I think the idiomatic way to write this is:

{code}
g.withStrategies(SubgraphStrategy.build().edges(has(id, 
lt(8L))).vertices(has(id, lt(4L))).create()).E()
[code}

i think transforming with {{id()}} is going to cause a problem. I think this 
might be a documentation task to better clarify what steps you should ideally 
use in {{SubgraphStrategy}} definitions because it simply has the potential to 
either fail like this or be abused (like, imagine doing wild stuff like doing 
mutations in the filter definitions).  maybe we also need {{SubgraphStrategy}} 
to restrict it to certain steps. There could also be a task to make this 
particular case work better, but it involves more wrapping of inside of 
`filter` to have it work.  not sure which of these paths is right to take, but 
we should sew this up a bit better than it currently is.

> Argument to SubgraphStrategy.Builder.edges changes semantics when used along 
> vertices
> -------------------------------------------------------------------------------------
>
>                 Key: TINKERPOP-3223
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3223
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: process
>    Affects Versions: 3.8.0, 3.7.5
>         Environment: Gremlin Console, Windows 11
> GremlinServer on Docker.
>            Reporter: Daniel Weber
>            Priority: Minor
>
> Setup: Any TinkerGraph with vertices and edges with long-Ids.
> The arguments to SubgraphStrategy.Builder.vertices and edges are supposed to 
> be predicate-traversals, i.e. edges and vertices are only to be considered 
> part of the subgraph if the predicate traversal yields a result. This works 
> for  
> {{g.withStrategies(SubgraphStrategy.build().vertices(id().is(lt(42L))).create()).V()
>  / .E()}}
> {{and}}
> {{g.withStrategies(SubgraphStrategy.build().edges(id().is(lt(4L))).create()).V()
>  / .E()}}
> however, if used together, the edges-traversal suddenly becomes somewhat of a 
> failed cast on edges:
> {{g.withStrategies(SubgraphStrategy.build().edges(id().is(lt(8L))).vertices(id().is(lt(4L))).create()).E()}}
>  yields
> class java.lang.Long cannot be cast to class 
> org.apache.tinkerpop.gremlin.structure.Edge (java.lang.Long is in module 
> java.base of loader 'bootstrap'; org.apache.tinkerpop.gremlin.structure.Edge 
> is in unnamed module of loader 'app')
> It does work, however, if the filter is made explicit: 
> {{g.withStrategies(SubgraphStrategy.build().edges(filter(id().is(lt(8L)))).vertices(id().is(lt(4L))).create()).E()}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to