1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use fmt;
/// The Apache TinkerPop `Barrier` token: the built-in consumers of `barrier(Consumer)`.
///
/// TinkerPop's `SackFunctions.Barrier` has exactly one member, `normSack`: it merges the stream
/// like `barrier()` and then scales every numeric sack so that the sacks of all traversers
/// (weighted by bulk) add up to 1. In the Rhai DSL it is `Barrier.normSack` (or
/// `Barrier::normSack`); in Rust, [`GraphTraversalSource::barrier_with`](crate::GraphTraversalSource::barrier_with).
///
/// ```rust
/// use graphersal::prelude::*;
///
/// let graph = GraphSource::tinkerpop_modern();
/// let lock = graph.read();
/// let sacks = lock
/// .traversal()
/// .with_sack(1.0)
/// .v(None)
/// .out(None)
/// .barrier_with(Barrier::NormSack)
/// .sack()
/// .to_list()
/// .unwrap();
/// let total: f64 = sacks.iter().filter_map(|s| s.as_f64()).sum();
/// assert!((total - 1.0).abs() < 1e-9);
/// ```
///
/// `#[non_exhaustive]`: TinkerPop's set is closed today, but a consumer may be added later, so
/// downstream matches need a `_` arm.