Skip to main content

MapReducer

Trait MapReducer 

Source
pub trait MapReducer {
    type Label: ToOwned + ?Sized;
    type Error;

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

    // Provided methods
    fn map_reduce(
        &mut self,
        node: NodeId,
        successors_label: <Self::Label as ToOwned>::Owned,
    ) -> Result<Option<<Self::Label as ToOwned>::Owned>, 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 as ToOwned>::Owned>, 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 as ToOwned>::Owned, other_labels: I, ) -> Result<Option<<Self::Label as ToOwned>::Owned>, 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 as ToOwned>::Owned, ) -> Result<Option<<Self::Label as ToOwned>::Owned>, Self::Error>

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

Defaults to calling Self::map then Self::reduce. Specialized implementations must have an equivalent implementation (which may be optimized), as there is no guarantee which is called by MapReduce.

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§