]> source.dussan.org Git - sonarqube.git/commitdiff
ComponentDao#selectByKeys() supports more than 1'000 inputs
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Sun, 2 Aug 2015 18:44:17 +0000 (20:44 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 5 Aug 2015 17:32:10 +0000 (19:32 +0200)
sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java

index 0d9e254ecb86b49d02e64473d47b5438bcd77647..794546ae1ca25bdd7574b67437b435f7a1d4ec98 100644 (file)
@@ -38,6 +38,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.RowNotFoundException;
 
 import static com.google.common.collect.Maps.newHashMapWithExpectedSize;
+import static org.sonar.db.DatabaseUtils.executeLargeInputs;
 
 public class ComponentDao implements Dao {
 
@@ -131,7 +132,20 @@ public class ComponentDao implements Dao {
   }
 
   public List<ComponentDto> selectByKeys(DbSession session, Collection<String> keys) {
-    return mapper(session).selectByKeys(keys);
+    return executeLargeInputs(keys, new KeyToDto(mapper(session)));
+  }
+
+  private static class KeyToDto implements Function<List<String>, List<ComponentDto>> {
+    private final ComponentMapper mapper;
+
+    private KeyToDto(ComponentMapper mapper) {
+      this.mapper = mapper;
+    }
+
+    @Override
+    public List<ComponentDto> apply(@Nonnull List<String> partitionOfKeys) {
+      return mapper.selectByKeys(partitionOfKeys);
+    }
   }
 
   public ComponentDto selectOrFailByKey(DbSession session, String key) {