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

Minor refactoring and refactored some unit test #2167

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

VijayanB
Copy link
Member

@VijayanB VijayanB commented Sep 28, 2024

Description

Related Issues

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@VijayanB VijayanB changed the title Update unit test to include empty field in multi field scenario Update unit test to include field with no live docs and minor refactor Sep 29, 2024
CHANGELOG.md Outdated
@@ -31,3 +31,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Maintenance
* Remove benchmarks folder from k-NN repo [#2127](https://github.com/opensearch-project/k-NN/pull/2127)
### Refactoring
* Update unit test to include field with no live docs and minor refactor [#2167](https://github.com/opensearch-project/k-NN/pull/2167)
Copy link
Member

Choose a reason for hiding this comment

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

I would reverse this to describe the minor refact and then say "and refactor some tests"

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

Copy link
Collaborator

@shatejas shatejas left a comment

Choose a reason for hiding this comment

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

Looks good overall

verify(knn990QuantWriterMockedConstruction.constructed().get(0)).writeState(i, quantizationState);
verify(nativeIndexWriter).flushIndex(expectedVectorValues.get(i), vectorsPerField.get(i).size());
if (vectorsPerField.get(i).isEmpty()) {
verify(knn990QuantWriterMockedConstruction.constructed().get(0), never()).writeState(i, quantizationState);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't want any interactions with quantwriter in this case right?

Suggested change
verify(knn990QuantWriterMockedConstruction.constructed().get(0), never()).writeState(i, quantizationState);
verifyNoInteractions(knn990QuantWriterMockedConstruction);

verify(nativeIndexWriter).flushIndex(expectedVectorValues.get(i), vectorsPerField.get(i).size());
if (vectorsPerField.get(i).isEmpty()) {
verify(knn990QuantWriterMockedConstruction.constructed().get(0), never()).writeState(i, quantizationState);
verify(nativeIndexWriter, never()).flushIndex(expectedVectorValues.get(i), vectorsPerField.get(i).size());
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here, verifying no interactions is a much stronger check

Suggested change
verify(nativeIndexWriter, never()).flushIndex(expectedVectorValues.get(i), vectorsPerField.get(i).size());
verifyNoInteractions(nativeIndexWriter);

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure will that work. We have interactions from other fields. I only want to verify that it doesn't interact when there are empty fields.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense, I missed that it has other values apart from empty vector

@VijayanB VijayanB changed the title Update unit test to include field with no live docs and minor refactor Minor refactoring and refactored some unit test Sep 30, 2024
@VijayanB VijayanB requested a review from jmazanec15 September 30, 2024 19:57
Refactored if/else to reduce nesting.
Added unit test when one of the field doesn't have live docs.

Signed-off-by: Vijayan Balasubramanian <[email protected]>
@VijayanB
Copy link
Member Author

VijayanB commented Sep 30, 2024

CI failure is not related to this PR. Created GH issue for flaky test #2169

Copy link
Member

@jmazanec15 jmazanec15 left a comment

Choose a reason for hiding this comment

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

LGTM

@VijayanB VijayanB merged commit f16f225 into opensearch-project:main Sep 30, 2024
29 of 30 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 30, 2024
Refactored if/else to reduce nesting.
Added unit test when one of the field doesn't have live docs.

Signed-off-by: Vijayan Balasubramanian <[email protected]>
(cherry picked from commit f16f225)
VijayanB added a commit that referenced this pull request Oct 1, 2024
…) (#2170)

Refactored if/else to reduce nesting.
Added unit test when one of the field doesn't have live docs.

Signed-off-by: Vijayan Balasubramanian <[email protected]>
(cherry picked from commit f16f225)

Co-authored-by: Vijayan Balasubramanian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants