Skip to content

Commit 6a2de32

Browse files
committed
Rename shardId to shardOrdinal for clarity
Signed-off-by: Michael Froh <[email protected]>
1 parent 222c1ea commit 6a2de32

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

server/src/main/java/org/opensearch/search/slice/SliceBuilder.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,13 @@ public int hashCode() {
214214
return Objects.hash(this.field, this.id, this.max);
215215
}
216216

217-
public boolean shardMatches(int shardId, int numShards) {
217+
public boolean shardMatches(int shardOrdinal, int numShards) {
218218
if (max >= numShards) {
219219
// Slices are distributed over shards
220-
return id % numShards == shardId;
220+
return id % numShards == shardOrdinal;
221221
}
222222
// Shards are distributed over slices
223-
return shardId % max == id;
223+
return shardOrdinal % max == id;
224224
}
225225

226226
/**
@@ -234,7 +234,7 @@ public Query toFilter(ClusterService clusterService, ShardSearchRequest request,
234234
throw new IllegalArgumentException("field " + field + " not found");
235235
}
236236

237-
int shardId = request.shardId().id();
237+
int shardOrdinal = request.shardId().id();
238238
int numShards = context.getIndexSettings().getNumberOfShards();
239239
if ((request.preference() != null || request.indexRoutings().length > 0)) {
240240
GroupShardsIterator<ShardIterator> group = buildShardIterator(clusterService, request);
@@ -250,21 +250,21 @@ public Query toFilter(ClusterService clusterService, ShardSearchRequest request,
250250
*/
251251
numShards = group.size();
252252
int ord = 0;
253-
shardId = -1;
253+
shardOrdinal = -1;
254254
// remap the original shard id with its index (position) in the sorted shard iterator.
255255
for (ShardIterator it : group) {
256256
assert it.shardId().getIndex().equals(request.shardId().getIndex());
257257
if (request.shardId().equals(it.shardId())) {
258-
shardId = ord;
258+
shardOrdinal = ord;
259259
break;
260260
}
261261
++ord;
262262
}
263-
assert shardId != -1 : "shard id: " + request.shardId().getId() + " not found in index shard routing";
263+
assert shardOrdinal != -1 : "shard id: " + request.shardId().getId() + " not found in index shard routing";
264264
}
265265
}
266266

267-
if (shardMatches(shardId, numShards) == false) {
267+
if (shardMatches(shardOrdinal, numShards) == false) {
268268
// We should have already excluded this shard before routing to it.
269269
// If we somehow land here, then we match nothing.
270270
return new MatchNoDocsQuery("this shard is not part of the slice");

0 commit comments

Comments
 (0)