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

Implement outer join and friends #8

Merged
merged 12 commits into from
Jun 25, 2022

Conversation

marcelogomez
Copy link
Contributor

@marcelogomez marcelogomez commented Jun 25, 2022

This PR implements all of the methods described this comment on #6 :

  • outer_join: Takes in a reference to a second HashBag and returns an iterator that yields the union of the key sets for both HashBags (ie. keyset(self) ∪ keyset(other)). Each key is yielded along with its corresponding counts on each HashBag.
  • not_in: Takes in a reference to a second HashBag and returns an iterator that yields the set difference between the key set of the first HashBag and the second one (i.e. keyset(self) \ keyset(other)). Each key is yielded along with its corresponding count on the first HashBag.
  • signed_difference: Takes in a reference to a second HashBag and returns an iterator that yields the union of the keys sets for both HashBags (ie. keyset(self) ∪ keyset(other). Each key is yielded along with the difference between its count on the first and second HashBags.

@marcelogomez marcelogomez marked this pull request as ready for review June 25, 2022 17:23
@codecov
Copy link

codecov bot commented Jun 25, 2022

Codecov Report

Merging #8 (c551d0c) into main (d1140b8) will increase coverage by 6.6%.
The diff coverage is 100.0%.

Impacted Files Coverage Δ
src/lib.rs 94.7% <100.0%> (+2.1%) ⬆️
src/serde.rs 95.3% <0.0%> (+95.3%) ⬆️

Copy link
Owner

@jonhoo jonhoo left a comment

Choose a reason for hiding this comment

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

This looks great, thanks for taking it on! The only thing I'm missing is a test that checks that outer_join indeed returns all the elements of self before any elements that are exclusively in other. We promise that in the docs, so we should have a test that the implementation meets that promise.

@marcelogomez
Copy link
Contributor Author

This looks great, thanks for taking it on! The only thing I'm missing is a test that checks that outer_join indeed returns all the elements of self before any elements that are exclusively in other. We promise that in the docs, so we should have a test that the implementation meets that promise.

Thanks for taking a look! :D

Yeah, will add that test! However, that's not what I meant when I wrote:

The iterator also yields the respective counts in self and other in that order.

The order I was referring was the the order of the values in the tuple that the iterator yields (i.e. it's (key, self_count, other_count). Will change the documentation to make that clearer

@jonhoo
Copy link
Owner

jonhoo commented Jun 25, 2022

The order I was referring was the the order of the values in the tuple that the iterator yields (i.e. it's (key, self_count, other_count). Will change the documentation to make that clearer

Ah, I see! Yeah, I think we want to make both promises in the docs (and check in tests) — that the first count in the tuple is from self, and that all elements not in other are yielded first.

@marcelogomez
Copy link
Contributor Author

Ah, I see! Yeah, I think we want to make both promises in the docs (and check in tests) — that the first count in the tuple is from self, and that all elements not in other are yielded first.

The tests for outer_join assert on the exact values yielded by the iterator so I think the ordering within the tuple is already covered by tests :) I just added new tests for the ordering between yielded elements

Copy link
Owner

@jonhoo jonhoo left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@jonhoo jonhoo merged commit 0bf4847 into jonhoo:main Jun 25, 2022
@jonhoo
Copy link
Owner

jonhoo commented Jun 25, 2022

Published as 0.1.7 🎉

src/lib.rs Show resolved Hide resolved
jonhoo added a commit that referenced this pull request Feb 17, 2024
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