-
Notifications
You must be signed in to change notification settings - Fork 147
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
changing MLSearchActionRequest to an instance subclass of SearchActionRequest #3459
Conversation
import static org.junit.Assert.assertNotSame; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertSame; | ||
import static org.junit.Assert.*; |
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.
Change wildcard import
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.
addressed. That's in test file and we have a lot like this in ml-commons for test classes.
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.
Add details to github issues to provide description about why this PR is required, changes implemented as part of this PR and testing details.
@@ -36,7 +35,7 @@ public class MLSearchActionRequest extends SearchRequest { | |||
*/ | |||
@Builder | |||
public MLSearchActionRequest(SearchRequest searchRequest, String tenantId) { | |||
this.searchRequest = searchRequest; | |||
super(searchRequest); |
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 constructs a new search request instead of reusing existing search request: https://github.com/opensearch-project/OpenSearch/blob/6f644e1c12de709b2136b999c8cb112a27c62100/server/src/main/java/org/opensearch/action/search/SearchRequest.java#L133
Would that be a memory concern?
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.
Not sure how much memory concern will it be there. May be we can do something like:
// Use existing SearchRequest constructor to ensure minimal duplication
super(searchRequest.indices(), searchRequest.source());
this.routing(searchRequest.routing());
this.preference(searchRequest.preference());
this.scroll(searchRequest.scroll());
this.allowPartialSearchResults(searchRequest.allowPartialSearchResults());
@msfroh do you have any input on this?
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.
Given that the searchRequest.source()
(and pretty much everything else) is copied by reference, the added memory is pretty negligible.
Doing the math, I count 14 object references (each at most 8 bytes, depending on CompressedOOPS, if I recall correctly), 2 booleans (which I think are 1 byte each -- I don't think they get packed smaller than that), and 2 ints (4 bytes each). So, I think a rough estimate would be 122 bytes?
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 approach seems fine to me, since you've already made MLSearchActionRequest
extend SearchRequest
.
It's also valid to make MLSearchActionRequest
extend ActionRequest
directly and hold a reference to SearchRequest
. Functionally, there's not much difference either way.
@@ -36,7 +35,7 @@ public class MLSearchActionRequest extends SearchRequest { | |||
*/ | |||
@Builder | |||
public MLSearchActionRequest(SearchRequest searchRequest, String tenantId) { | |||
this.searchRequest = searchRequest; | |||
super(searchRequest); |
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.
Given that the searchRequest.source()
(and pretty much everything else) is copied by reference, the added memory is pretty negligible.
Doing the math, I count 14 object references (each at most 8 bytes, depending on CompressedOOPS, if I recall correctly), 2 booleans (which I think are 1 byte each -- I don't think they get packed smaller than that), and 2 ints (4 bytes each). So, I think a rough estimate would be 122 bytes?
No need add backport label, as this change has added to this PR in 2.x branch: https://github.com/opensearch-project/ml-commons/pull/3443/files |
…nRequest Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3459 +/- ##
============================================
- Coverage 80.26% 80.25% -0.02%
- Complexity 6887 6902 +15
============================================
Files 608 610 +2
Lines 30008 30067 +59
Branches 3357 3367 +10
============================================
+ Hits 24085 24129 +44
- Misses 4480 4488 +8
- Partials 1443 1450 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
In this PR, I'm making MLSearchActionRequest as a subclass of SearchActionRequest to follow the standard. Previously I wasn't quite extending the SearchActionRequest, as I had another SearchActionRequest object in the class and it was being read and written twice.
Description
[Describe what this change achieves]
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
--signoff
.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.