Cannot access a stored value after fold

I think i cannot find the docs related to this behavior. I stored a value in a variable then tried to access it after an aggregation, but it seems not found anymore, what could be the reason? And what possible approach I can solve?
Solution:
once you use a reducing-barrier step, like fold() or groupBy() you lose path history.
ReducingBarrierStep: All of the traversers prior to the step are processed by a reduce function and once all the previous traversers are processed, a single "reduced value" traverser is emitted to the next step. Note that the path history leading up to a reducing barrier step is destroyed given its many-to-one nature.
Once you are reduced to a single traverser from many traversers, that path sort of loses meaning. Often folks work around this by rewriting their traversal to use aggregate() or some other global side-effect to hold the data somewhere other than path history. https://tinkerpop.apache.org/docs/current/reference/#a-note-on-barrier-steps...
Jump to solution
1 Reply
Solution
spmallette
spmallette2y ago
once you use a reducing-barrier step, like fold() or groupBy() you lose path history.
ReducingBarrierStep: All of the traversers prior to the step are processed by a reduce function and once all the previous traversers are processed, a single "reduced value" traverser is emitted to the next step. Note that the path history leading up to a reducing barrier step is destroyed given its many-to-one nature.
Once you are reduced to a single traverser from many traversers, that path sort of loses meaning. Often folks work around this by rewriting their traversal to use aggregate() or some other global side-effect to hold the data somewhere other than path history. https://tinkerpop.apache.org/docs/current/reference/#a-note-on-barrier-steps
Want results from more Discord servers?
Add your server