Skip to main content

Mapper

Trait Mapper 

Source
pub trait Mapper {
    // Provided methods
    fn setup(&mut self, _ctx: &mut Context) { ... }
    fn map(&mut self, key: usize, value: &[u8], ctx: &mut Context) { ... }
    fn cleanup(&mut self, _ctx: &mut Context) { ... }
}
Expand description

Trait to represent the mapping stage of MapReduce.

All trait methods have sane defaults to match the Hadoop MapReduce implementation, allowing the developer to pick and choose what they customize without having to write a large amount of boilerplate.

Provided Methods§

Source

fn setup(&mut self, _ctx: &mut Context)

Setup handler for the current Mapper.

Source

fn map(&mut self, key: usize, value: &[u8], ctx: &mut Context)

Mapping handler for the current Mapper.

The default implementation is to simply emit each key/value pair as they are received, without any changes. As such, this is where most developers will immediately begin to change things.

Source

fn cleanup(&mut self, _ctx: &mut Context)

Cleanup handler for the current Mapper.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<M> Mapper for M
where M: FnMut(usize, &[u8], &mut Context),

Enables raw functions to act as Mapper types.