aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-08-09 15:59:24 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-09 16:01:37 -0700
commitd0a3c5eb67320906e4b937df5434f0e673cb6dce (patch)
treebd53ecfb3e65235f83e18d2d56382fb1468d1e2c /src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java
parent39974a43abdd32e3a1acbc7da945b08da9983e4e (diff)
Batch all DependencyResolver#getTarget calls. This leads to some duplicate iteration, but that should be cheap, while requesting packages sequentially can hurt...
PiperOrigin-RevId: 208126130
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java
index 083688d02b..1f92bea669 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java
@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Streams;
import com.google.common.eventbus.EventBus;
import com.google.devtools.build.lib.actions.ArtifactFactory;
import com.google.devtools.build.lib.actions.PackageRoots;
@@ -90,6 +91,8 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
/**
* A util class that contains all the helper stuff previously in BuildView that only exists to give
@@ -310,13 +313,25 @@ public class BuildViewForTesting {
}
@Override
- protected Target getTarget(Target from, Label label, NestedSetBuilder<Cause> rootCauses)
- throws InterruptedException {
- try {
- return skyframeExecutor.getPackageManager().getTarget(eventHandler, label);
- } catch (NoSuchThingException e) {
- throw new IllegalStateException(e);
- }
+ protected Map<Label, Target> getTargets(
+ Iterable<Label> labels,
+ Target fromTarget,
+ NestedSetBuilder<Cause> rootCauses,
+ int labelsSizeHint) {
+ return Streams.stream(labels)
+ .distinct()
+ .collect(
+ Collectors.toMap(
+ Function.identity(),
+ label -> {
+ try {
+ return skyframeExecutor.getPackageManager().getTarget(eventHandler, label);
+ } catch (NoSuchPackageException
+ | NoSuchTargetException
+ | InterruptedException e) {
+ throw new IllegalStateException(e);
+ }
+ }));
}
@Override