Skip to content

Commit 8f27a20

Browse files
committed
iter
1 parent 1bab9e4 commit 8f27a20

File tree

7 files changed

+22
-26
lines changed

7 files changed

+22
-26
lines changed

modules/lang-mustache/src/yamlRestTest/resources/rest-api-spec/test/lang_mustache/30_search_template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137

138138
- match: { hits.total: 1 }
139139
- length: { hits.hits: 1 }
140-
- length: { profile: 1 }
140+
- length: { profile: 2 }
141141

142142
---
143143
"Test with new response format":

server/src/main/java/org/elasticsearch/action/search/QueryPhaseResultConsumer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public QueryPhaseResultConsumer(
9797
this.queryPhaseRankCoordinatorContext = source == null || source.rankBuilder() == null
9898
? null
9999
: source.rankBuilder().buildQueryPhaseCoordinatorContext(size, from);
100-
this.hasTopDocs = (source == null || size != 0) && queryPhaseRankCoordinatorContext == null;
100+
this.hasTopDocs = (source == null || size != 0) && queryPhaseRankCoordinatorContext == null || source.rankBuilder() != null;
101101
this.hasAggs = source != null && source.aggregations() != null;
102102
this.aggReduceContextBuilder = hasAggs ? controller.getReduceContext(isCanceled, source.aggregations()) : null;
103103
int batchReduceSize = (hasAggs || hasTopDocs) ? Math.min(request.getBatchedReduceSize(), expectedResultSize) : expectedResultSize;

server/src/main/java/org/elasticsearch/search/profile/SearchProfileCoordinatorResult.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ public String getNodeId() {
5454
}
5555

5656
public RetrieverProfileResult getRetrieverProfileResult() {
57-
return retrieverProfileResult;
58-
}
59-
60-
public Map<String, Long> getBreakdownMap() {
61-
return breakdownMap;
57+
return this.retrieverProfileResult;
6258
}
6359

6460
@Override

server/src/main/java/org/elasticsearch/search/profile/coordinator/RetrieverProfileResult.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
import org.elasticsearch.xcontent.XContentBuilder;
1818

1919
import java.io.IOException;
20-
import java.util.List;
20+
import java.util.Map;
2121

2222
public class RetrieverProfileResult implements ToXContentObject, Writeable {
2323

2424
private final String name;
2525
private long tookInMillis;
26-
private final List<SearchProfileCoordinatorResult> children;
26+
private final Map<String, SearchProfileCoordinatorResult> children;
2727

28-
public RetrieverProfileResult(String name, long tookInMillis, List<SearchProfileCoordinatorResult> children) {
28+
public RetrieverProfileResult(String name, long tookInMillis, Map<String, SearchProfileCoordinatorResult> children) {
2929
this.name = name;
3030
this.tookInMillis = tookInMillis;
3131
this.children = children;
@@ -34,14 +34,14 @@ public RetrieverProfileResult(String name, long tookInMillis, List<SearchProfile
3434
public RetrieverProfileResult(StreamInput in) throws IOException {
3535
name = in.readString();
3636
tookInMillis = in.readLong();
37-
children = in.readCollectionAsList(SearchProfileCoordinatorResult::new);
37+
children = in.readMap(StreamInput::readString, SearchProfileCoordinatorResult::new);
3838
}
3939

4040
@Override
4141
public void writeTo(StreamOutput out) throws IOException {
4242
out.writeString(name);
4343
out.writeLong(tookInMillis);
44-
out.writeCollection(children);
44+
out.writeMap(children, StreamOutput::writeString, StreamOutput::writeWriteable);
4545
}
4646

4747
@Override
@@ -53,9 +53,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
5353
}
5454
if (false == children.isEmpty()) {
5555
builder.startArray("children");
56-
for (SearchProfileCoordinatorResult child : children) {
56+
for (Map.Entry<String, SearchProfileCoordinatorResult> child : children.entrySet()) {
5757
builder.startObject();
58-
child.toXContent(builder, params);
58+
builder.startObject(child.getKey());
59+
child.getValue().toXContent(builder, params);
60+
builder.endObject();
5961
builder.endObject();
6062
}
6163
builder.endArray();
@@ -65,13 +67,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
6567
return builder;
6668
}
6769

68-
public List<SearchProfileCoordinatorResult> getChildren() {
69-
return children;
70-
}
71-
72-
public void addChild(SearchProfileCoordinatorResult profileResult) {
70+
public void addChild(String name, SearchProfileCoordinatorResult profileResult) {
7371
assert profileResult != null;
74-
children.add(profileResult);
72+
children.put(name, profileResult);
7573
}
7674

7775
public void setTookInMillis(long tookInMillis) {

server/src/main/java/org/elasticsearch/search/profile/coordinator/SearchCoordinatorProfiler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public SearchCoordinatorProfiler(final String nodeId) {
2222
this.nodeId = nodeId;
2323
}
2424

25-
public void captureInnerRetrieverResult(SearchProfileCoordinatorResult profileResult) {
25+
public void captureInnerRetrieverResult(String name, SearchProfileCoordinatorResult profileResult) {
2626
if (retriever == null) {
2727
throw new IllegalArgumentException("parent [retriever] results have not been initialized");
2828
}
29-
retriever.addChild(profileResult);
29+
retriever.addChild(name, profileResult);
3030
}
3131

3232
public void captureRetrieverTookInMillis(long tookInMillis) {

server/src/main/java/org/elasticsearch/search/retriever/CompoundRetrieverBuilder.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.elasticsearch.action.search.SearchRequest;
1919
import org.elasticsearch.action.search.SearchResponse;
2020
import org.elasticsearch.action.search.TransportMultiSearchAction;
21+
import org.elasticsearch.common.util.Maps;
2122
import org.elasticsearch.index.query.BoolQueryBuilder;
2223
import org.elasticsearch.index.query.QueryBuilder;
2324
import org.elasticsearch.index.query.QueryRewriteContext;
@@ -89,7 +90,9 @@ public final RetrieverBuilder rewrite(QueryRewriteContext ctx) throws IOExceptio
8990
final SearchCoordinatorProfiler profiler = ctx.profiler();
9091
Timer rewriteTimer = null;
9192
if (profiler != null && profiler.getRetriever() == null) {
92-
profiler.retriever(new RetrieverProfileResult(this.getName(), -1, new ArrayList<>(innerRetrievers.size())));
93+
profiler.retriever(
94+
new RetrieverProfileResult(this.getName(), -1, Maps.newConcurrentHashMapWithExpectedSize(innerRetrievers.size()))
95+
);
9396
rewriteTimer = profiler.getNewTimer(SearchCoordinatorTimingType.RETRIEVER_REWRITE);
9497
rewriteTimer.start();
9598
}
@@ -150,7 +153,8 @@ public void onResponse(MultiSearchResponse items) {
150153
listener.onFailure(new IllegalStateException("Coordinator profile results are missing"));
151154
}
152155
SearchProfileCoordinatorResult nestedResult = item.getResponse().getCoordinatorProfileResults();
153-
profiler.captureInnerRetrieverResult(nestedResult);
156+
nestedResult.getRetrieverProfileResult().setTookInMillis(item.getResponse().getTookInMillis());
157+
profiler.captureInnerRetrieverResult(innerRetrievers.get(i).retriever().getName(), nestedResult);
154158
}
155159
}
156160
}

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankBuilder.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,11 @@ public Explanation explainHit(Explanation baseExplanation, RankDoc scoreDoc, Lis
157157
@Override
158158
public QueryPhaseRankShardContext buildQueryPhaseShardContext(List<Query> queries, int from) {
159159
return null;
160-
// return new RerankingQueryPhaseRankShardContext(queries, rankWindowSize());
161160
}
162161

163162
@Override
164163
public QueryPhaseRankCoordinatorContext buildQueryPhaseCoordinatorContext(int size, int from) {
165164
return null;
166-
// return new RerankingQueryPhaseRankCoordinatorContext(rankWindowSize());
167165
}
168166

169167
@Override

0 commit comments

Comments
 (0)