-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add unit tests for terms aggregation objects. #23149
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
Conversation
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| return super.equals(obj) && Objects.equals(term, ((Bucket) obj).term); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs the traditional class comparison to make sure the cast doesn't blow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The super.equals call already guarantees it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, fine then!
|
|
||
| @Override | ||
| protected boolean doEquals(Object obj) { | ||
| InternalMappedTerms<?,?> that = (InternalMappedTerms<?,?>) obj; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is called from equals, which already does this check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I see now. Sorry, I wasn't being careful.
|
|
||
| @Override | ||
| protected boolean doEquals(Object obj) { | ||
| InternalTerms<?,?> that = (InternalTerms<?,?>) obj; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one is also fine.
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| return super.equals(obj) && Objects.equals(term, ((Bucket) obj).term); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As is this one.
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| return super.equals(obj) && Objects.equals(termBytes, ((Bucket) obj).termBytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is fine too.
| final int numBuckets = randomInt(shardSize); | ||
| Set<Double> terms = new HashSet<>(); | ||
| for (int i = 0; i < numBuckets; ++i) { | ||
| double term; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
randomValueOtherThanMany might make this easier to read.
Relates #22278