Hi!
I try to extract the weight information from path then sum to get the total weight but got object type cast error.
Experiment environment: graph db titan-1.0.0 + single node cassandra, and also post question in titan user group.
Below is my steps:
gremlin> v1 = graph.addVertex(T.label, 'v1')
gremlin> v2 = graph.addVertex(T.label, 'v2')
gremlin> v1.addEdge("foo", v2, "weight", 0.25f)
gremlin> g.V().hasLabel('v1').repeat(outE().inV().simplePath()).times(1).path().as('p').map(unfold().coalesce(values('weight'), constant(0.0)).sum()).as('w').select('p', 'w')
org.apache.tinkerpop.gremlin.process.traversal.step.util.ImmutablePath cannot be cast to org.apache.tinkerpop.gremlin.structure.Element
Display stack trace? [yN]
The above step show object type is ImmutablePath which can not be cast to Element.
By adding By step, then type change from ImmutablePath to MutablePath,
gremlin> g.V().hasLabel('v1').repeat(outE().inV().simplePath()).times(1).path().as('p').by(constant(0.0)).by('weight').map(unfold().coalesce(values('weight'),constant(0.0)).sum()).as('w').select('p', 'w')
org.apache.tinkerpop.gremlin.process.traversal.step.util.MutablePath cannot be cast to org.apache.tinkerpop.gremlin.structure.Element
Display stack trace? [yN]
I think the problem might be caused by unfold step didn't decompose path object into list for Sum step.
Do I miss anything mentioned in the document or is it a bug? plz kindly help, thanks!