Skip to content

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

Merged

Conversation

OlivierCavadenti
Copy link
Contributor

This commit clean up hppc in FetchSearchPhase class and all impacted classes.

Relates #84735

This commit clean up hppc in FetchSearchPhase class and all impacted classes.

Relates elastic#84735
@elasticsearchmachine elasticsearchmachine added external-contributor Pull request authored by a developer outside the Elasticsearch team v8.2.0 labels Mar 21, 2022
@jtibshirani jtibshirani added the :Search/Search Search-related issues that do not fall into other categories label Mar 28, 2022
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Mar 28, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@arteam arteam added the :Core/Infra/Core Core issues without another label label Mar 29, 2022
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Mar 29, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@arteam arteam requested a review from rjernst March 29, 2022 09:16
Copy link
Member

@rjernst rjernst left a 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);
Copy link
Member

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();
Copy link
Member

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();
Copy link
Member

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.

@rjernst rjernst self-assigned this Mar 29, 2022
…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
@rjernst
Copy link
Member

rjernst commented Apr 1, 2022

@elasticmachine ok to test

Copy link
Member

@rjernst rjernst left a 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];
Copy link
Member

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];

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @OlivierCavadenti

@rjernst rjernst merged commit b20abe9 into elastic:master Apr 1, 2022
@rjernst rjernst mentioned this pull request Apr 1, 2022
43 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label external-contributor Pull request authored by a developer outside the Elasticsearch team >refactoring :Search/Search Search-related issues that do not fall into other categories Team:Core/Infra Meta label for core/infra team Team:Search Meta label for search team v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants