Can someone explain the split/merge behaviour of sack in more detail? Given a simple graph:
graph = TinkerGraph.open()
v0 = graph.addVertex("0")
v1 = graph.addVertex("1")
v0.addEdge("aaa", v1)
g = graph.traversal().withSack(0d, {a -> println("splitting sack"); a}, {a, b -> println("merging sack") a+b})
// coalesce splits the traverser and sack. However it never calls the sack's mergeOperator, so the sack changes inside the coalesce options don't propagate through to the main traverser.
g.V(
v0.id).sack{s, v -> 1d}.coalesce(outE("aaa").sack{s, e -> println("aaa"); 2d}).sack()
// output:
// splitting sack
// splitting sack
// aaa
// splitting sack
// splitting sack
// ==>1.0
// In contrast: `choose` also splits the traverser and sack, and the mergeOperator is also never called, but somehow the sack modifications propagate through to the main traverser. This seems to be true for all branch steps (coalesce is a FlatMapStep).
g.V(
v0.id).sack{s, v -> 1d}.choose(outE().label()).option("aaa", __.outE("aaa").sack{s, e -> println("aaa"); 2d}).sack()
// output:
// splitting sack
// splitting sack
// splitting sack
// splitting sack
// splitting sack
// aaa
// splitting sack
// ==>2.0
Is there a way to propagate the sack from within coalesce back to the main traverser? I tried a few combinations of `withBulk` and `local` steps, but the results don't change. Do I misunderstand the concept of the mergeOperator?