tinkerpop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "stephen mallette (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (TINKERPOP-1974) Adding edges during VertexProgram execute with Tinkergraph backend results in ClassCastException
Date Fri, 01 Jun 2018 11:59:00 GMT

     [ https://issues.apache.org/jira/browse/TINKERPOP-1974?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

stephen mallette closed TINKERPOP-1974.
---------------------------------------
    Resolution: Not A Problem

As this behavior is expected and there hasn't been additional update, i'm going to close this.
If you have other questions, please feel free to ask. Usage questions are best posted on the
gremlin-users mailing list: 

https://groups.google.com/forum/#!forum/gremlin-users


> Adding edges during VertexProgram execute with Tinkergraph backend results in ClassCastException
> ------------------------------------------------------------------------------------------------
>
>                 Key: TINKERPOP-1974
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1974
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: tinkergraph
>    Affects Versions: 3.3.3
>            Reporter: Nathaniel Meyer
>            Priority: Minor
>
> Attempts to add edges during a vertex program on tinkergraph result in a ClassCastException
because org.apache.tinkerpop.gremlin.process.computer.util.ComputerGraph.ComputerVertex can't
be cast to class org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex.
> In a vertex program designed to add edges to the graph based on rules, attempts to call
vertex.addEdge(label,otherVertex,edgeProperties) can only result in a ClassCastException
on Tinkergraph.  At runtime, the Vertex argument to VertexProgram.execute(vertex,messenger,memory)
has class org.apache.tinkerpop.gremlin.process.computer.util.ComputerGraph.ComputerVertex. 
Both the vertex and the otherVertex are instances of class ComputerGraph.ComputerVertex,
but when addEdge is called on the ComputerGraph.ComputerVertex instance, internally it calls
the addEdge(...) of the wrapped TinkerVertex.  TinkerVertex.addEdge(...) casts the otherEdge
to a TinkerVertex, which it is not.  There is no way to get an instance of a TinkerVertex
in a VertexProgram without specifically handling this case, casting to ComputerGraph.ComputerVertex
or WrappedVertex, and getting the wrapped vertex of the other vertex before calling addEdge. 
This is not portable across backends!
> A fix might be to add handling for instances of ComputerGraph.ComputerVertex or <C
extends WrappedVertex> and get the base vertex before casting to TinkerVertex.
> EDIT: Workaround exists, downgrade to minor.  Added test for WrappedVertex.class in my
vertex program and performed a getBaseVertex() call on the target vertex before calling addEdge.
 
> if(WrappedVertex.class.isAssignableFrom(mate.getClass())) {			 
> 	vertex.addEdge("similarTo", ((WrappedVertex<Vertex>)mate).getBaseVertex(), edgeProperties);
> } else {
> 	vertex.addEdge("similarTo", mate, edgeProperties);
> }



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message