Mercurial > lbo > hg > localmr
changeset 19:0d1007320d02
formats/util: Add MRSinkGenerator type.
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Sun, 31 Jan 2016 13:52:49 +0000 |
parents | 3b56d88a7ab8 |
children | 12e16da09d18 |
files | src/formats/util.rs |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/formats/util.rs Sun Jan 31 13:52:28 2016 +0000 +++ b/src/formats/util.rs Sun Jan 31 13:52:49 2016 +0000 @@ -1,7 +1,9 @@ //! Various iterators/adapters used for input/output formats. + use mapreducer::Record; use std::fmt; +use std::io; /// Transforms an iterator<string> into an iterator<Record>. It yields /// records with the key being the position of the current record, starting with @@ -36,3 +38,13 @@ } } } + +/// A type implementing MRSinkGenerator is used at the end of the reducer +/// phase to write the output. Given a name, new() should return a new object +/// that can be used to write the output of a reduce partition. +/// Values are always written as a whole to the writer. +pub trait MRSinkGenerator { + type Sink: io::Write + Sized; + /// Return a new output. + fn new_output(&mut self, name: &String) -> Self::Sink; +}