import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static java.util.Objects.requireNonNull;
-import static org.sonar.core.util.stream.MoreCollectors.toArrayList;
+import static org.sonar.core.util.stream.MoreCollectors.toHashSet;
import static org.sonar.server.rule.index.RuleIndexDefinition.INDEX_TYPE_RULE;
import static org.sonar.server.rule.index.RuleIndexDefinition.INDEX_TYPE_RULE_EXTENSION;
BulkIndexer bulkIndexer = createBulkIndexer(Size.REGULAR, new ResiliencyIndexingListener(dbClient, dbSession, items));
bulkIndexer.start();
- List<RuleKey> ruleKeys = items
+ Set<RuleKey> ruleKeys = items
.stream()
.filter(i -> {
requireNonNull(i.getDocId(), () -> "BUG - " + i + " has not been persisted before indexing");
return i.getDocType() == EsQueueDto.Type.RULE;
})
.map(i -> RuleKey.parse(i.getDocId()))
- .collect(toArrayList(items.size()));
+ .collect(toHashSet(items.size()));
dbClient.ruleDao().scrollIndexingRulesByKeys(dbSession, ruleKeys,
// only index requests, no deletion requests.
// the remaining items reference rows that don't exist in db. They must
// be deleted from index.
- ruleKeys.forEach(r -> bulkIndexer.addDeletion(RuleIndexDefinition.INDEX_TYPE_RULE, r.toString(), r.toString()));
- ruleKeys.forEach(r -> bulkIndexer.addDeletion(RuleIndexDefinition.INDEX_TYPE_RULE_EXTENSION, RuleExtensionDoc.idOf(r, RuleExtensionScope.system()), r.toString()));
+ ruleKeys.forEach(r -> {
+ bulkIndexer.addDeletion(RuleIndexDefinition.INDEX_TYPE_RULE, r.toString(), r.toString());
+ bulkIndexer.addDeletion(RuleIndexDefinition.INDEX_TYPE_RULE_EXTENSION, RuleExtensionDoc.idOf(r, RuleExtensionScope.system()), r.toString());
+ });
return bulkIndexer.stop();
}
BulkIndexer bulkIndexer = createBulkIndexer(Size.REGULAR, new ResiliencyIndexingListener(dbClient, dbSession, items));
bulkIndexer.start();
- List<RuleExtensionId> docIds = items
+ Set<RuleExtensionId> docIds = items
.stream()
.filter(i -> {
requireNonNull(i.getDocId(), () -> "BUG - " + i + " has not been persisted before indexing");
return i.getDocType() == EsQueueDto.Type.RULE_EXTENSION;
})
.map(RuleIndexer::explodeRuleExtensionDocId)
- .collect(toArrayList(items.size()));
+ .collect(toHashSet(items.size()));
dbClient.ruleDao().scrollIndexingRuleExtensionsByIds(dbSession, docIds,
// only index requests, no deletion requests.
import static java.util.Collections.singletonList;
import static java.util.Objects.requireNonNull;
-import static org.sonar.core.util.stream.MoreCollectors.toArrayList;
+import static org.sonar.core.util.stream.MoreCollectors.toHashSet;
import static org.sonar.server.user.index.UserIndexDefinition.INDEX_TYPE_USER;
public class UserIndexer implements StartupIndexer, ResilientIndexer {
if (items.isEmpty()) {
return new IndexingResult();
}
- List<String> logins = items
+ Set<String> logins = items
.stream()
.filter(i -> {
requireNonNull(i.getDocId(), () -> "BUG - " + i + " has not been persisted before indexing");
return i.getDocType() == EsQueueDto.Type.USER;
})
.map(EsQueueDto::getDocId)
- .collect(toArrayList(items.size()));
+ .collect(toHashSet(items.size()));
ListMultimap<String, String> organizationUuidsByLogin = ArrayListMultimap.create();
dbClient.organizationMemberDao().selectForUserIndexing(dbSession, logins, organizationUuidsByLogin::put);