-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Use inheritance instead of composition to simplify search phase transitions #119272
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
Use inheritance instead of composition to simplify search phase transitions #119272
Conversation
…itions We only need the extensibility for testing and it's a lot easier to reason about the code if we have explicit methods instead of overly complicated composition with lots of redundant references being retained all over the place. -> lets simplify to inheritance and get shorter code that performs more predictably (especially when it comes to memory) as a first step. This also opens up the possibility of further simplifications and removing more retained state/memory as we go through the search phases.
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
@@ -180,4 +179,95 @@ ShardSearchRequest rewriteShardSearchRequest(ShardSearchRequest request) { | |||
|
|||
return request; | |||
} | |||
|
|||
private static List<DfsKnnResults> mergeKnnResults(SearchRequest request, List<DfsSearchResult> dfsSearchResults) { |
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 two static methods move without changes, they are now only used from this class.
This change makes the code more readable. The classes' sequence is discrete and easy to follow.
It reminds me of the Similar logic can also be applied in the RankFeaturePhase, not updated in this pr. |
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.
LGTM! This is a refactoring task, which makes the code easier to follow. Thank you @original-brownbear
Thanks Dimitris! |
💔 Backport failed
You can use sqren/backport to manually backport by running |
…itions (elastic#119272) We only need the extensibility for testing and it's a lot easier to reason about the code if we have explicit methods instead of overly complicated composition with lots of redundant references being retained all over the place. -> lets simplify to inheritance and get shorter code that performs more predictably (especially when it comes to memory) as a first step. This also opens up the possibility of further simplifications and removing more retained state/memory as we go through the search phases.
…120079) (#126511) * Remove unnecessary interfaces/abstractions from search phases (#120079) A couple obvious cleanups where declared general interfaces aren't actually used + we shouldn't escape potentially heavy-weight search phases just to get their name in a call so adjusted the failure API. * Use inheritance instead of composition to simplify search phase transitions (#119272) We only need the extensibility for testing and it's a lot easier to reason about the code if we have explicit methods instead of overly complicated composition with lots of redundant references being retained all over the place. -> lets simplify to inheritance and get shorter code that performs more predictably (especially when it comes to memory) as a first step. This also opens up the possibility of further simplifications and removing more retained state/memory as we go through the search phases.
We only need the extensibility for testing and it's a lot easier to reason about the code if we have explicit methods instead of overly complicated composition with lots of redundant references being retained all over the place.
-> lets simplify to inheritance and get shorter code that performs more predictably (especially when it comes to memory) as a first step. This also opens up the possibility of further simplifications and removing more retained state/memory as we go through the search phases.