Skip to main content

MapReducer

Trait MapReducer 

Source
pub trait MapReducer {
    type Label: Clone;
    type Error;

    // Required methods
    fn map(&mut self, node: NodeId) -> Result<Option<Self::Label>, Self::Error>;
    fn reduce<'a, I: Iterator<Item = &'a Self::Label>>(
        &mut self,
        first_label: Self::Label,
        other_labels: I,
    ) -> Result<Option<Self::Label>, Self::Error>
       where Self::Label: 'a;

    // Provided methods
    fn map_reduce(
        &mut self,
        node: NodeId,
        successors_label: Self::Label,
    ) -> Result<Option<Self::Label>, Self::Error> { ... }
    fn on_node_traversed(
        &mut self,
        _node: NodeId,
        _label: Option<&Self::Label>,
    ) -> Result<(), Self::Error> { ... }
}
Expand description

Callbacks for MapReduce

Required Associated Types§

Required Methods§

Source

fn map(&mut self, node: NodeId) -> Result<Option<Self::Label>, Self::Error>

Returns the label to assign to the given node, independently of its successors, if any

Source

fn reduce<'a, I: Iterator<Item = &'a Self::Label>>( &mut self, first_label: Self::Label, other_labels: I, ) -> Result<Option<Self::Label>, Self::Error>
where Self::Label: 'a,

Given the labels of the children of a node, merge them into a single label.

Not guaranteed to be called for every node.

Provided Methods§

Source

fn map_reduce( &mut self, node: NodeId, successors_label: Self::Label, ) -> Result<Option<Self::Label>, Self::Error>

Special-case of Self::reduce for merging a node’s label with its successors’ label

Defaults to calling Self::reduce.

Not guaranteed to be called for every node.

Source

fn on_node_traversed( &mut self, _node: NodeId, _label: Option<&Self::Label>, ) -> Result<(), Self::Error>

Called once a node’s initial label was computed and merged with its successors’

Defaults to no-op.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§