Skip to content

Commit

Permalink
rdd: eliminate the duplicate reduce method for Iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
Thysinner committed May 25, 2021
1 parent 0471eda commit 129b546
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/rdd/rdd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ pub trait Rdd: RddBase + 'static {
self.intersection_with_num_partitions(other, self.number_of_splits())
}

/// subtract function, same as the one found in apache spark
/// subtract function, same as the one found in apache spark
/// example of subtract can be found in subtract.rs
/// performs a full outer join followed by and intersection with self to get subtraction.
fn subtract<T>(&self, other: Arc<T>) -> SerArc<dyn Rdd<Item = Self::Item>>
Expand All @@ -848,7 +848,7 @@ pub trait Rdd: RddBase + 'static {
{
self.subtract_with_num_partition(other, self.number_of_splits())
}

fn subtract_with_num_partition<T>(
&self,
other: Arc<T>,
Expand Down Expand Up @@ -1159,17 +1159,3 @@ pub trait Reduce<T> {
Self: Sized,
F: FnMut(T, T) -> T;
}

impl<T, I> Reduce<T> for I
where
I: Iterator<Item = T>,
{
#[inline]
fn reduce<F>(mut self, f: F) -> Option<T>
where
Self: Sized,
F: FnMut(T, T) -> T,
{
self.next().map(|first| self.fold(first, f))
}
}

0 comments on commit 129b546

Please sign in to comment.