pub struct MapReduce<G: SwhForwardGraph + SwhBackwardGraph, MR: MapReducer, L> {
pub map_reducer: MR,
/* private fields */
}Expand description
Associates labels to nodes in the graph using successor nodes’ labels and “bubbling up”
Use swh_graph::views::Subgraph to select the set of nodes to run this on.
For example, to avoid content and directory nodes (which are typically much slower to process),
use Subgraph::with_node_constraint("rev,rel,snp,ori".parse().unwrap()).
Built from MapReduceBuilder
§Example
For example, with this graph:
- 3
/
<-
1 <--- 4 <--+
+--- 6
2 <--- 5 <--+We call 1 a successor of 3, consistent with swh-graph’s terminology, even though MapReducer propagates labels in the other direction.
we would:
- compute label of 1
- compute label of 2
- compute label of 2 and merge it with 1’s
- compute label of 4 and merge it with 1’s
- compute label of 5 and merge it with 2’s
- compute label of 6 and merge it with 4’s and 5’s
Fields§
§map_reducer: MRImplementations§
Source§impl<G: SwhForwardGraph + SwhBackwardGraph, MR: MapReducer, L: Labels<Label = MR::Label>> MapReduce<G, MR, L>
impl<G: SwhForwardGraph + SwhBackwardGraph, MR: MapReducer, L: Labels<Label = MR::Label>> MapReduce<G, MR, L>
Sourcepub fn run_in_topological_order(
&mut self,
nodes: impl Iterator<Item = NodeId>,
) -> Result<(), MR::Error>
pub fn run_in_topological_order( &mut self, nodes: impl Iterator<Item = NodeId>, ) -> Result<(), MR::Error>
Runs the configured MapReducer sequentially on all nodes in the graph.
nodes must be an iterator of all nodes in topological order,
eg. returned by GenerationsReader::iter_nodes
with .map(|(_depth, node)| node).
Sourcepub fn push_node(&mut self, node: NodeId) -> Result<(), MR::Error>
pub fn push_node(&mut self, node: NodeId) -> Result<(), MR::Error>
A single step of Self::run_in_topological_order, in case the caller does not have an
iterator of nodes
Sourcepub fn labels(&self) -> Result<&L>
pub fn labels(&self) -> Result<&L>
Returns every node’s labels, if MapReduceBuilder::keep_labels was set to true.
Sourcepub fn take_labels(self) -> Result<L>
pub fn take_labels(self) -> Result<L>
Returns every node’s labels, if MapReduceBuilder::keep_labels was set to true.
Auto Trait Implementations§
impl<G, MR, L> Freeze for MapReduce<G, MR, L>
impl<G, MR, L> RefUnwindSafe for MapReduce<G, MR, L>
impl<G, MR, L> Send for MapReduce<G, MR, L>
impl<G, MR, L> Sync for MapReduce<G, MR, L>
impl<G, MR, L> Unpin for MapReduce<G, MR, L>
impl<G, MR, L> UnsafeUnpin for MapReduce<G, MR, L>
impl<G, MR, L> UnwindSafe for MapReduce<G, MR, L>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more