Skip to content

Commit 73d23a4

Browse files
committed
iter
1 parent 7963cf1 commit 73d23a4

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
@@ -55,6 +55,7 @@
5555
requires org.apache.lucene.queryparser;
5656
requires org.apache.lucene.sandbox;
5757
requires org.apache.lucene.suggest;
58+
requires org.elasticsearch.server;
5859

5960
exports org.elasticsearch;
6061
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;
@@ -1243,7 +1244,9 @@ static List<SearchShardIterator> getRemoteShardsIterator(
12431244
null,
12441245
searchShardsGroup.preFiltered(),
12451246
searchShardsGroup.skipped(),
1246-
0 // TODO
1247+
// This parameter is specific to the resharding feature.
1248+
// Resharding is currently not supported with CCS.
1249+
IndexReshardingMetadata.NOOP_RESHARD_SPLIT_SHARD_COUNT_SUMMARY
12471250
);
12481251
remoteShardIterators.add(shardIterator);
12491252
}
@@ -1297,7 +1300,9 @@ static List<SearchShardIterator> getRemoteShardsIteratorFromPointInTime(
12971300
searchContextKeepAlive,
12981301
false,
12991302
false,
1300-
0 // TODO
1303+
// This parameter is specific to the resharding feature.
1304+
// Resharding is currently not supported with CCS.
1305+
IndexReshardingMetadata.NOOP_RESHARD_SPLIT_SHARD_COUNT_SUMMARY
13011306
);
13021307
remoteShardIterators.add(shardIterator);
13031308
}
@@ -1980,7 +1985,15 @@ static List<SearchShardIterator> getLocalShardsIteratorFromPointInTime(
19801985
keepAlive,
19811986
false,
19821987
false,
1983-
0 // TODO
1988+
// This parameter is specific to the resharding feature.
1989+
// It is used when creating a searcher to apply filtering needed to have correct search results
1990+
// while resharding is in progress.
1991+
// In context of PIT the searcher is reused or can be recreated only in read-only scenarios.
1992+
// If a searcher is reused, this value won't be used
1993+
// (it was calculated and used when PIT was created).
1994+
// In read-only scenarios (e.g. searchable snapshots) we don't expect resharding to happen
1995+
// so the value doesn't matter.
1996+
IndexReshardingMetadata.NOOP_RESHARD_SPLIT_SHARD_COUNT_SUMMARY
19841997
)
19851998
);
19861999
}
@@ -2005,7 +2018,7 @@ List<SearchShardIterator> getLocalShardsIterator(
20052018
searchRequest.routing(),
20062019
searchRequest.indices()
20072020
);
2008-
List<SearchShardRouting> shardRoutings = clusterService.operationRouting()
2021+
List<SearchShardRouting> searchShards = clusterService.operationRouting()
20092022
.searchShards(
20102023
projectState,
20112024
concreteIndices,
@@ -2020,18 +2033,19 @@ List<SearchShardIterator> getLocalShardsIterator(
20202033
concreteIndices,
20212034
searchRequest.indicesOptions()
20222035
);
2023-
SearchShardIterator[] list = new SearchShardIterator[shardRoutings.size()];
2036+
SearchShardIterator[] list = new SearchShardIterator[searchShards.size()];
20242037
int i = 0;
2025-
for (SearchShardRouting shardRouting : shardRoutings) {
2026-
final ShardId shardId = shardRouting.iterator().shardId();
2038+
for (SearchShardRouting shardInfo : searchShards) {
2039+
ShardIterator iterator = shardInfo.iterator();
2040+
final ShardId shardId = iterator.shardId();
20272041
OriginalIndices finalIndices = originalIndices.get(shardId.getIndex().getName());
20282042
assert finalIndices != null;
20292043
list[i++] = new SearchShardIterator(
20302044
clusterAlias,
20312045
shardId,
2032-
shardRouting.iterator().getShardRoutings(),
2046+
iterator.getShardRoutings(),
20332047
finalIndices,
2034-
shardRouting.reshardSplitShardCountSummary()
2048+
shardInfo.reshardSplitShardCountSummary()
20352049
);
20362050
}
20372051
// 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)