Mercurial > lbo > hg > localmr
changeset 72:98b6d1e37f6a
rustfmt
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Sat, 06 Feb 2016 18:37:34 +0000 |
parents | 2a58864abf08 |
children | 7a059fb6186a |
files | src/parameters.rs src/record_types.rs src/reduce.rs |
diffstat | 3 files changed, 33 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parameters.rs Sat Feb 06 18:37:22 2016 +0000 +++ b/src/parameters.rs Sat Feb 06 18:37:34 2016 +0000 @@ -75,7 +75,10 @@ /// BUG: This will not work correctly until the map phase delivers outputs in the correct order, i.e. /// dictionary order. The default Ord implementation for String treats lower and upper case /// very differently. Default: false. - pub fn set_reduce_group_opts(mut self, prealloc_size: usize, insensitive: bool) -> MRParameters { + pub fn set_reduce_group_opts(mut self, + prealloc_size: usize, + insensitive: bool) + -> MRParameters { self.reduce_group_prealloc_size = prealloc_size; self.reduce_group_insensitive = insensitive; self
--- a/src/record_types.rs Sat Feb 06 18:37:22 2016 +0000 +++ b/src/record_types.rs Sat Feb 06 18:37:34 2016 +0000 @@ -10,7 +10,10 @@ /// Shortcut for creating a record. pub fn mk_rcrd(k: &str, v: &str) -> Record { - Record { key: String::from(k), value: String::from(v) } + Record { + key: String::from(k), + value: String::from(v), + } } impl PartialOrd for Record {
--- a/src/reduce.rs Sat Feb 06 18:37:22 2016 +0000 +++ b/src/reduce.rs Sat Feb 06 18:37:34 2016 +0000 @@ -17,18 +17,18 @@ } impl<MR: MapReducer, InputIt: Iterator<Item=Record>, SinkGen: MRSinkGenerator> ReducePartition<MR, InputIt, SinkGen> { - /// Create a new Reduce partition for the given MR; source and destination I/O. - /// mr is the map/reduce functions. - /// params is generic MR parameters as well as some applying directly to this reduce partition. - /// srcfiles is a set of Iterator<Item=Record>s. Those are usually reading from the map phase's - /// outputs. - /// dstfiles is a SinkGen (as known from the mapping phase) that is used to create the output - /// file (there is one output file per reduce partition, currently). +/// Create a new Reduce partition for the given MR; source and destination I/O. +/// mr is the map/reduce functions. +/// params is generic MR parameters as well as some applying directly to this reduce partition. +/// srcfiles is a set of Iterator<Item=Record>s. Those are usually reading from the map phase's +/// outputs. +/// dstfiles is a SinkGen (as known from the mapping phase) that is used to create the output +/// file (there is one output file per reduce partition, currently). pub fn new(mr: MR, params: MRParameters, srcfiles: Vec<InputIt>, dstfiles: SinkGen) -> ReducePartition<MR, InputIt, SinkGen> { ReducePartition { mr: mr, params: params, srcfiles: srcfiles, dstfilegen: dstfiles } } - /// Run the Reduce partition. +/// Run the Reduce partition. pub fn _run(mut self) { let mut inputs = Vec::new(); inputs.append(&mut self.srcfiles); @@ -107,7 +107,8 @@ Some(r) => { if !self.settings.reduce_group_insensitive && r.key != key { break; - } else if self.settings.reduce_group_insensitive && r.key[..].to_ascii_lowercase() != key { + } else if self.settings.reduce_group_insensitive && + r.key[..].to_ascii_lowercase() != key { break; } } @@ -125,22 +126,23 @@ use record_types::*; use std::vec; - fn get_records() -> Vec<Record>{ - vec![ - mk_rcrd("aaa", "def"), - mk_rcrd("abb", "111"), - mk_rcrd("Abb", "112"), - mk_rcrd("abbb", "113"), - mk_rcrd("abc", "xyz"), - mk_rcrd("xyz", "___"), - mk_rcrd("xyz", "__foo"), - mk_rcrd("xyz", "---")] + fn get_records() -> Vec<Record> { + vec![mk_rcrd("aaa", "def"), + mk_rcrd("abb", "111"), + mk_rcrd("Abb", "112"), + mk_rcrd("abbb", "113"), + mk_rcrd("abc", "xyz"), + mk_rcrd("xyz", "___"), + mk_rcrd("xyz", "__foo"), + mk_rcrd("xyz", "---")] } #[test] fn test_grouping_iterator() { let records = get_records(); - let group_it: RecordsToMultiRecords<vec::IntoIter<Record>> = RecordsToMultiRecords::new(records.into_iter(), MRParameters::new().set_reduce_group_opts(2, true)); + let group_it: RecordsToMultiRecords<vec::IntoIter<Record>> = + RecordsToMultiRecords::new(records.into_iter(), + MRParameters::new().set_reduce_group_opts(2, true)); let lengths = vec![1, 2, 1, 1, 3]; let mut i = 0; @@ -154,7 +156,9 @@ #[test] fn test_grouping_iterator_sensitive() { let records = get_records(); - let group_it: RecordsToMultiRecords<vec::IntoIter<Record>> = RecordsToMultiRecords::new(records.into_iter(), MRParameters::new().set_reduce_group_opts(2, false)); + let group_it: RecordsToMultiRecords<vec::IntoIter<Record>> = + RecordsToMultiRecords::new(records.into_iter(), + MRParameters::new().set_reduce_group_opts(2, false)); let lengths = vec![1, 1, 1, 1, 1, 3]; let mut i = 0;