Hi,
I'm learning Gremlin recently and got confused on the last example of Sack Step in the official guide.
====Examples===
gremlin> g.withSack(1.0d).V(1).local(outE('knows').barrier(normSack).inV()).in('knows').barrier() //[4]
==>v[1]
==>v[1]
gremlin> g.withSack(1.0d).V(1).local(outE('knows').barrier(normSack).inV()).in('knows').barrier().sack() //[5]
==>0.5
==>0.5
gremlin> g.withSack(1.0d,sum).V(1).local(outE('knows').barrier(normSack).inV()).in('knows').barrier().sack() //[6]
==>1.0
==>1.0
gremlin> g.withBulk(false).withSack(1.0f,sum).V(1).local(outE('knows').barrier(normSack).inV()).in('knows').barrier().sack() //[7]
==>1.0
gremlin> g.withBulk(false).withSack(1.0f).V(1).local(outE('knows').barrier(normSack).inV()).in('knows').barrier().sack() //[8]
==>0.5
==>0.5
Notes:
- [5] The local(…barrier(normSack)…) ensures that all
traversers leaving vertex 1 have an evenly distributed amount of the
initial 1.0 "energy" (50-50), i.e. the sack is 0.5 on each result.
- [6] Using sum as merge operator leads to the expected 1.0.
[7] There is now a single traverser with bulk of 2 and sack of 1.0 and thus, setting withBulk(false)` yields the expected 1.0
-
[8] Like 7, but without the sum operator
=======End======
My Questions:
- What's indeed the normSack for? Is it a function to distribute the sack number among traversers?
- Is local(…barrier(normSack)…) the only form/context of the usage of normSack? I can't find more information on it in the class API docs.
- Comaring
to example 6, example 7,8 begin with withBulk(false) step. What will
this influence the behavior of traversers? Will the traverser clone
itself when the path splits?
Looking forward to your help. Thanks ahead.
Max