Skip to content

Commit 4ec55c1

Browse files
committed
update isPartial
1 parent 508d3eb commit 4ec55c1

File tree

2 files changed

+14
-28
lines changed

2 files changed

+14
-28
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlExecutionInfo.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,8 @@ public Map<String, Cluster> getClusters() {
248248
public Cluster swapCluster(String clusterAlias, BiFunction<String, Cluster, Cluster> remappingFunction) {
249249
return clusterInfo.compute(clusterAlias, (unused, oldCluster) -> {
250250
final Cluster newCluster = remappingFunction.apply(clusterAlias, oldCluster);
251-
if (isPartial == false) {
252-
isPartial = newCluster.getStatus() == Cluster.Status.PARTIAL
253-
|| newCluster.getStatus() == Cluster.Status.SKIPPED
254-
|| (newCluster.failedShards != null && newCluster.failedShards > 0);
251+
if (newCluster != null && isPartial == false) {
252+
isPartial = newCluster.isPartial();
255253
}
256254
return newCluster;
257255
});
@@ -313,13 +311,6 @@ public boolean isPartial() {
313311
return isPartial;
314312
}
315313

316-
/**
317-
* Mark the query as having partial results.
318-
*/
319-
public void markAsPartial() {
320-
isPartial = true;
321-
}
322-
323314
public void markAsStopped() {
324315
isStopped = true;
325316
}
@@ -328,13 +319,6 @@ public boolean isStopped() {
328319
return isStopped;
329320
}
330321

331-
/**
332-
* Mark this cluster as having partial results.
333-
*/
334-
public void markClusterAsPartial(String clusterAlias) {
335-
swapCluster(clusterAlias, (k, v) -> new Cluster.Builder(v).setStatus(Cluster.Status.PARTIAL).build());
336-
}
337-
338322
/**
339323
* Represents the search metadata about a particular cluster involved in a cross-cluster search.
340324
* The Cluster object can represent either the local cluster or a remote cluster.
@@ -626,6 +610,10 @@ public List<ShardSearchFailure> getFailures() {
626610
return failures;
627611
}
628612

613+
boolean isPartial() {
614+
return status == Status.PARTIAL || status == Status.SKIPPED || (failedShards != null && failedShards > 0);
615+
}
616+
629617
@Override
630618
public boolean equals(Object o) {
631619
if (this == o) return true;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -252,16 +252,14 @@ public void execute(
252252
cancelQueryOnFailure,
253253
localListener.acquireCompute().map(r -> {
254254
localClusterWasInterrupted.set(execInfo.isStopped());
255-
if (execInfo.isCrossClusterSearch() && execInfo.clusterAliases().contains(LOCAL_CLUSTER)) {
256-
execInfo.swapCluster(
257-
LOCAL_CLUSTER,
258-
(k, v) -> new EsqlExecutionInfo.Cluster.Builder(v).setTotalShards(r.getTotalShards())
259-
.setSuccessfulShards(r.getSuccessfulShards())
260-
.setSkippedShards(r.getSkippedShards())
261-
.setFailedShards(r.getFailedShards())
262-
.build()
263-
);
264-
}
255+
execInfo.swapCluster(
256+
LOCAL_CLUSTER,
257+
(k, v) -> new EsqlExecutionInfo.Cluster.Builder(v).setTotalShards(r.getTotalShards())
258+
.setSuccessfulShards(r.getSuccessfulShards())
259+
.setSkippedShards(r.getSkippedShards())
260+
.setFailedShards(r.getFailedShards())
261+
.build()
262+
);
265263
return r.getProfiles();
266264
})
267265
);

0 commit comments

Comments
 (0)