-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Remove hppc from FetchSearchPhase #85188
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
Remove hppc from FetchSearchPhase #85188
Conversation
This commit clean up hppc in FetchSearchPhase class and all impacted classes. Relates elastic#84735
Pinging @elastic/es-search (Team:Search) |
Pinging @elastic/es-core-infra (Team:Core/Infra) |
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.
Thanks for the PR @OlivierCavadenti. I left a few requests.
@@ -128,7 +127,7 @@ private void innerRun() throws Exception { | |||
finishPhase.run(); | |||
} else { | |||
ScoreDoc[] scoreDocs = reducedQueryPhase.sortedTopDocs().scoreDocs(); | |||
final IntArrayList[] docIdsToLoad = searchPhaseController.fillDocIdsToLoad(numShards, scoreDocs); | |||
final ArrayList<Integer>[] docIdsToLoad = searchPhaseController.fillDocIdsToLoad(numShards, scoreDocs); |
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.
We should use List, not ArrayList, whenever passing these arround (ie in return types and local variables).
this.contextId = contextId; | ||
this.docIds = list.buffer; | ||
this.size = list.size(); | ||
this.docIds = docIds.stream().mapToInt(i -> i).toArray(); |
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 can use Integer::intValue
in mapToInt
this.docIds = list.buffer; | ||
this.size = list.size(); | ||
this.docIds = docIds.stream().mapToInt(i -> i).toArray(); | ||
this.size = docIds.size(); |
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 size is no longer needed as a member, since now the array is sized correctly. Before the buffer from the hppc type could have been larger.
…archPhase # Conflicts: # server/src/main/java/org/elasticsearch/action/search/FetchSearchPhase.java # server/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java # server/src/main/java/org/elasticsearch/action/search/SearchScrollQueryThenFetchAsyncAction.java
@elasticmachine ok to test |
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 looks good @OlivierCavadenti. Can you please address the compile failure I noted? Also, you'll want to sync with the latest upstream.
public static IntArrayList[] fillDocIdsToLoad(int numShards, ScoreDoc[] shardDocs) { | ||
IntArrayList[] docIdsToLoad = new IntArrayList[numShards]; | ||
public static List<Integer>[] fillDocIdsToLoad(int numShards, ScoreDoc[] shardDocs) { | ||
List<Integer>[] docIdsToLoad = (ArrayList<Integer>[]) new ArrayList[numShards]; |
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.
You'll need to annotate this to suppress the unchecked cast warning (and also just need List in the cast, not ArrayList).
@SuppressWarnings("unchecked")
List<Integer>[] docIdsToLoad = (List<Integer>[]) new ArrayList[numShards];
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, thanks @OlivierCavadenti
This commit clean up hppc in FetchSearchPhase class and all impacted classes.
Relates #84735