[
https://issues.apache.org/jira/browse/TINKERPOP-1974?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Nathaniel Meyer updated TINKERPOP-1974:
---------------------------------------
Priority: Minor (was: Major)
Description:
Attempts to add edges during a vertex program on tinkergraph result in a
ClassCastException because
org.apache.tinkerpop.gremlin.process.computer.util.ComputerGraph.ComputerVertexcan't
be cast to having class
org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex.
In a vertex program to add edges to vertices 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);
}
was:
Attempts to add edges during a vertex program on tinkergraph result in a
ClassCastException because
org.apache.tinkerpop.gremlin.process.computer.util.ComputerGraph.ComputerVertexcan't
be cast to having class
org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex.
In a vertex program to add edges to vertices 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.
> 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.ComputerVertexcan't
> be cast to having class
> org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex.
> In a vertex program to add edges to vertices 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)