Skip to content

Commit

Permalink
Remove some dead code from SearchPhase and friends (elastic#116645)
Browse files Browse the repository at this point in the history
The separate `onFailure` is unnecessary, just fail the phase like we do
elsewhere. Also make utility method static.
  • Loading branch information
original-brownbear authored Dec 4, 2024
1 parent 9df4a49 commit 4e8e973
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ void sendReleaseSearchContext(ShardSearchContextId contextId, Transport.Connecti
* @see #onShardFailure(int, SearchShardTarget, Exception)
* @see #onShardResult(SearchPhaseResult, SearchShardIterator)
*/
final void onPhaseDone() { // as a tribute to @kimchy aka. finishHim()
private void onPhaseDone() { // as a tribute to @kimchy aka. finishHim()
executeNextPhase(this, this::getNextPhase);
}

Expand All @@ -762,13 +762,6 @@ public final void execute(Runnable command) {
executor.execute(command);
}

/**
* Notifies the top-level listener of the provided exception
*/
public void onFailure(Exception e) {
listener.onFailure(e);
}

/**
* Builds an request for the initial search phase.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void doRun() {
for (InnerHitBuilder innerHitBuilder : innerHitBuilders) {
MultiSearchResponse.Item item = it.next();
if (item.isFailure()) {
context.onPhaseFailure(this, "failed to expand hits", item.getFailure());
phaseFailure(item.getFailure());
return;
}
SearchHits innerHits = item.getResponse().getHits();
Expand All @@ -119,7 +119,11 @@ private void doRun() {
}
}
onPhaseDone();
}, context::onFailure));
}, this::phaseFailure));
}

private void phaseFailure(Exception ex) {
context.onPhaseFailure(this, "failed to expand hits", ex);
}

private static SearchSourceBuilder buildExpandSearchSourceBuilder(InnerHitBuilder options, CollapseBuilder innerCollapseBuilder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,6 @@ protected void executePhaseOnShard(
}, shardIt);
}

@Override
public void onFailure(Exception e) {
Assert.fail("should not be called");
}

@Override
public void sendReleaseSearchContext(ShardSearchContextId contextId, Transport.Connection connection, OriginalIndices originalIndices) {
releasedSearchContexts.add(contextId);
Expand Down

0 comments on commit 4e8e973

Please sign in to comment.