Skip to content

Commit

Permalink
changing the dedup logic
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <[email protected]>
  • Loading branch information
bharath-techie committed May 24, 2023
1 parent a06440b commit 991de84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ public TransportPitSegmentsAction(
*/
@Override
protected void doExecute(Task task, PitSegmentsRequest request, ActionListener<IndicesSegmentResponse> listener) {
// remove pit id duplicates from the request
Set<String> pitIdSet = new LinkedHashSet<>(request.getPitIds());
request.clearAndSetPitIds(new ArrayList<>(pitIdSet));
if (request.getPitIds().size() == 1 && "_all".equals(request.getPitIds().get(0))) {
pitService.getAllPits(ActionListener.wrap(response -> {
request.clearAndSetPitIds(response.getPitInfos().stream().map(ListPitInfo::getPitId).collect(Collectors.toList()));
Expand All @@ -118,7 +115,9 @@ protected void doExecute(Task task, PitSegmentsRequest request, ActionListener<I
@Override
protected ShardsIterator shards(ClusterState clusterState, PitSegmentsRequest request, String[] concreteIndices) {
final ArrayList<ShardRouting> iterators = new ArrayList<>();
for (String pitId : request.getPitIds()) {
// remove duplicates from the request
final Set<String> uniquePitIds = new LinkedHashSet<>(request.getPitIds());
for (String pitId : uniquePitIds) {
SearchContextId searchContext = decode(namedWriteableRegistry, pitId);
for (Map.Entry<ShardId, SearchContextIdForNode> entry : searchContext.shards().entrySet()) {
final SearchContextIdForNode perNode = entry.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public TransportDeletePitAction(
*/
@Override
protected void doExecute(Task task, DeletePitRequest request, ActionListener<DeletePitResponse> listener) {
// remove pit id duplicates from the request
Set<String> pitIdSet = new LinkedHashSet<>(request.getPitIds());
request.clearAndSetPitIds(new ArrayList<>(pitIdSet));
if (request.getPitIds().size() == 1 && "_all".equals(request.getPitIds().get(0))) {
deleteAllPits(listener);
} else {
Expand All @@ -63,7 +60,9 @@ protected void doExecute(Task task, DeletePitRequest request, ActionListener<Del
*/
private void deletePits(ActionListener<DeletePitResponse> listener, DeletePitRequest request) {
Map<String, List<PitSearchContextIdForNode>> nodeToContextsMap = new HashMap<>();
for (String pitId : request.getPitIds()) {
// remove duplicates from the request
final Set<String> uniquePitIds = new LinkedHashSet<>(request.getPitIds());
for (String pitId : uniquePitIds) {
SearchContextId contextId = SearchContextId.decode(namedWriteableRegistry, pitId);
for (SearchContextIdForNode contextIdForNode : contextId.shards().values()) {
PitSearchContextIdForNode pitSearchContext = new PitSearchContextIdForNode(pitId, contextIdForNode);
Expand Down

0 comments on commit 991de84

Please sign in to comment.