Skip to content

Commit 727c8b5

Browse files
committed
iter
1 parent 00c7aec commit 727c8b5

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

server/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
requires org.apache.lucene.queryparser;
5555
requires org.apache.lucene.sandbox;
5656
requires org.apache.lucene.suggest;
57+
requires org.elasticsearch.server;
5758

5859
exports org.elasticsearch;
5960
exports org.elasticsearch.action;

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

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.elasticsearch.cluster.metadata.IndexMetadata;
4242
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
4343
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.ResolvedExpression;
44+
import org.elasticsearch.cluster.metadata.IndexReshardingMetadata;
4445
import org.elasticsearch.cluster.metadata.ProjectMetadata;
4546
import org.elasticsearch.cluster.node.DiscoveryNode;
4647
import org.elasticsearch.cluster.node.DiscoveryNodes;
@@ -1249,7 +1250,9 @@ static List<SearchShardIterator> getRemoteShardsIterator(
12491250
null,
12501251
searchShardsGroup.preFiltered(),
12511252
searchShardsGroup.skipped(),
1252-
0 // TODO
1253+
// This parameter is specific to the resharding feature.
1254+
// Resharding is currently not supported with CCS.
1255+
IndexReshardingMetadata.NOOP_RESHARD_SPLIT_SHARD_COUNT_SUMMARY
12531256
);
12541257
remoteShardIterators.add(shardIterator);
12551258
}
@@ -1303,7 +1306,9 @@ static List<SearchShardIterator> getRemoteShardsIteratorFromPointInTime(
13031306
searchContextKeepAlive,
13041307
false,
13051308
false,
1306-
0 // TODO
1309+
// This parameter is specific to the resharding feature.
1310+
// Resharding is currently not supported with CCS.
1311+
IndexReshardingMetadata.NOOP_RESHARD_SPLIT_SHARD_COUNT_SUMMARY
13071312
);
13081313
remoteShardIterators.add(shardIterator);
13091314
}
@@ -1986,7 +1991,15 @@ static List<SearchShardIterator> getLocalShardsIteratorFromPointInTime(
19861991
keepAlive,
19871992
false,
19881993
false,
1989-
0 // TODO
1994+
// This parameter is specific to the resharding feature.
1995+
// It is used when creating a searcher to apply filtering needed to have correct search results
1996+
// while resharding is in progress.
1997+
// In context of PIT the searcher is reused or can be recreated only in read-only scenarios.
1998+
// If a searcher is reused, this value won't be used
1999+
// (it was calculated and used when PIT was created).
2000+
// In read-only scenarios (e.g. searchable snapshots) we don't expect resharding to happen
2001+
// so the value doesn't matter.
2002+
IndexReshardingMetadata.NOOP_RESHARD_SPLIT_SHARD_COUNT_SUMMARY
19902003
)
19912004
);
19922005
}
@@ -2011,7 +2024,7 @@ List<SearchShardIterator> getLocalShardsIterator(
20112024
searchRequest.routing(),
20122025
searchRequest.indices()
20132026
);
2014-
List<SearchShardRouting> shardRoutings = clusterService.operationRouting()
2027+
List<SearchShardRouting> searchShards = clusterService.operationRouting()
20152028
.searchShards(
20162029
projectState,
20172030
concreteIndices,
@@ -2026,18 +2039,19 @@ List<SearchShardIterator> getLocalShardsIterator(
20262039
concreteIndices,
20272040
searchRequest.indicesOptions()
20282041
);
2029-
SearchShardIterator[] list = new SearchShardIterator[shardRoutings.size()];
2042+
SearchShardIterator[] list = new SearchShardIterator[searchShards.size()];
20302043
int i = 0;
2031-
for (SearchShardRouting shardRouting : shardRoutings) {
2032-
final ShardId shardId = shardRouting.iterator().shardId();
2044+
for (SearchShardRouting shardInfo : searchShards) {
2045+
ShardIterator iterator = shardInfo.iterator();
2046+
final ShardId shardId = iterator.shardId();
20332047
OriginalIndices finalIndices = originalIndices.get(shardId.getIndex().getName());
20342048
assert finalIndices != null;
20352049
list[i++] = new SearchShardIterator(
20362050
clusterAlias,
20372051
shardId,
2038-
shardRouting.iterator().getShardRoutings(),
2052+
iterator.getShardRoutings(),
20392053
finalIndices,
2040-
shardRouting.reshardSplitShardCountSummary()
2054+
shardInfo.reshardSplitShardCountSummary()
20412055
);
20422056
}
20432057
// the returned list must support in-place sorting, so this is the most memory efficient we can do here

server/src/main/java/org/elasticsearch/cluster/metadata/IndexReshardingMetadata.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@
8989
* to beginning another resharding operation.
9090
*/
9191
public class IndexReshardingMetadata implements ToXContentFragment, Writeable {
92+
/**
93+
* A value of `reshardSplitShardCountSummary` ({@link IndexMetadata#getReshardSplitShardCountSummaryForSearch(int)})
94+
* that is used when it is known that this value won't affect the correctness of the operation.
95+
*/
96+
public static int NOOP_RESHARD_SPLIT_SHARD_COUNT_SUMMARY = 0;
97+
9298
private static final String SPLIT_FIELD_NAME = "split";
9399
private static final ParseField SPLIT_FIELD = new ParseField(SPLIT_FIELD_NAME);
94100
// This exists only so that tests can verify that IndexReshardingMetadata supports more than one kind of operation.

server/src/main/java/org/elasticsearch/search/internal/ShardSearchRequest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.elasticsearch.action.support.IndicesOptions;
2020
import org.elasticsearch.cluster.metadata.AliasMetadata;
2121
import org.elasticsearch.cluster.metadata.IndexMetadata;
22+
import org.elasticsearch.cluster.metadata.IndexReshardingMetadata;
2223
import org.elasticsearch.common.CheckedBiConsumer;
2324
import org.elasticsearch.common.Strings;
2425
import org.elasticsearch.common.bytes.BytesArray;
@@ -233,8 +234,10 @@ public ShardSearchRequest(ShardId shardId, long nowInMillis, AliasFilter aliasFi
233234
SequenceNumbers.UNASSIGNED_SEQ_NO,
234235
SearchService.NO_TIMEOUT,
235236
false,
236-
// TODO (resharding) take as a parameter
237-
0
237+
// This parameter is specific to the resharding feature.
238+
// TODO
239+
// It is currently only supported in _search API and is stubbed here as a result.
240+
IndexReshardingMetadata.NOOP_RESHARD_SPLIT_SHARD_COUNT_SUMMARY
238241
);
239242
}
240243

0 commit comments

Comments
 (0)