pub trait MapReduce: ViewSchema {
    // Required method
    fn map<'doc>(
        &self,
        document: &'doc BorrowedDocument<'_>
    ) -> ViewMapResult<'doc, Self>;

    // Provided method
    fn reduce(
        &self,
        mappings: &[MappedValue<Self::MappedKey<'_>, <Self::View as View>::Value>],
        rereduce: bool
    ) -> Result<<Self::View as View>::Value, Error> { ... }
}
Expand description

The Map/Reduce functionality for a ViewSchema.

This trait implementation provides the behavior for mapping data from documents into their key/value pairs for this view, as well as reducing multiple values into a single value.

Required Methods§

source

fn map<'doc>( &self, document: &'doc BorrowedDocument<'_> ) -> ViewMapResult<'doc, Self>

The map function for this view. This function is responsible for emitting entries for any documents that should be contained in this View. If None is returned, the View will not include the document. See the user guide’s chapter on views for more information on how map works.

Provided Methods§

source

fn reduce( &self, mappings: &[MappedValue<Self::MappedKey<'_>, <Self::View as View>::Value>], rereduce: bool ) -> Result<<Self::View as View>::Value, Error>

Returns a value that is produced by reducing a list of mappings into a single value. If rereduce is true, the values contained in the mappings have already been reduced at least one time. If an error of ReduceUnimplemented is returned, queries that ask for a reduce operation will return an error. See the user guide’s chapter on views for more information on how reduce works.

Object Safety§

This trait is not object safe.

Implementors§