Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added subtract operation #120

Merged
merged 4 commits into from
Jul 6, 2020
Merged

added subtract operation #120

merged 4 commits into from
Jul 6, 2020

Conversation

ajprabhu09
Copy link
Contributor

No description provided.

src/rdd/rdd.rs Outdated
@@ -26,28 +26,49 @@ use serde_derive::{Deserialize, Serialize};
use serde_traitobject::{Deserialize, Serialize};

mod parallel_collection_rdd;

pub use parallel_collection_rdd::*;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove these extra new lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@@ -838,6 +859,65 @@ pub trait Rdd: RddBase + 'static {
self.intersection_with_num_partitions(other, self.number_of_splits())
}

fn subtract<T>(&self, other: Arc<T>) -> SerArc<dyn Rdd<Item = Self::Item>>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, please add documentation for this method. Similar to the one in Spark will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have added documentation for the function and an example in examples/subtract.rs

.map_partitions(Box::new(Fn!(|iter: Box<
dyn Iterator<Item = Option<Self::Item>>,
>|
-> Box<
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I maybe wrong, but it looks like rustfmt is not done. If so, please run cargo fmt.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@iduartgomez
Copy link
Collaborator

Closes #91

There is an optimized version for this op (could be implemented in the future) in case you want to check it out. It entails quite more changes though, I had somethings close to done (had to debug one error) but haven't been able to finish it up yet due to lack of time.

@ajprabhu09
Copy link
Contributor Author

Is there any reference to the more optimized method you mentioned, I could look into
?

let first = sc.parallelize(col1, 4);
let second = sc.parallelize(col2, 4);
let ans = first.subtract(Arc::new(second));
assert_eq!(ans.collect().unwrap(), vec![19, 12, 10, 1, 0, 2])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion can fail randomly depending on shuffle(as evidenced by CI check fail). You can iterate over one vector and check if an element exists in the other one or convert both of them as hashset and do assert_eq. HashSet is the better way.

@rajasekarv
Copy link
Owner

merging this for now as it is working version. @iduartgomez When you are done, please feel free to modify this operation.

@rajasekarv rajasekarv merged commit 07c2e74 into rajasekarv:master Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants