Skip to content

Commit

Permalink
use Set instead of List for better lookup
Browse files Browse the repository at this point in the history
Signed-off-by: bansvaru <[email protected]>
  • Loading branch information
linuxpi committed Sep 1, 2023
1 parent 16be1de commit 15ad7b0
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -200,14 +202,14 @@ private void validate(
) {
String errorMsg = "cannot restore index [%s] because an open index with same name/uuid already exists in the cluster.";

List<String> graveyardIndexNames = new ArrayList<>();
List<String> graveyardIndexUUID = new ArrayList<>();
List<String> liveClusterIndexUUIDs = currentState.metadata()
Set<String> graveyardIndexNames = new HashSet<>();
Set<String> graveyardIndexUUID = new HashSet<>();
Set<String> liveClusterIndexUUIDs = currentState.metadata()
.indices()
.values()
.stream()
.map(IndexMetadata::getIndexUUID)
.collect(Collectors.toList());
.collect(Collectors.toSet());

currentState.metadata().indexGraveyard().getTombstones().forEach(tombstone -> {
graveyardIndexNames.add(tombstone.getIndex().getName());
Expand Down

0 comments on commit 15ad7b0

Please sign in to comment.