aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/query2
diff options
context:
space:
mode:
authorGravatar nharmata <nharmata@google.com>2018-04-13 11:55:00 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-13 11:56:42 -0700
commit7bcdceb2b6593bb2f9ad491433534fedb1188b23 (patch)
treef822fa14589122016ec0a3f9d5b6cbea3cedeb32 /src/main/java/com/google/devtools/build/lib/query2
parentaa0713912454fc8a6a13f8202e86a416d352bd6f (diff)
Perform the TTV-land DTC visitation during SkyQuery's internal parallel visitation of the DTC of
the 'universe' argument of the 'rdeps' function. TTVs alone are sufficient. RELNOTES: None PiperOrigin-RevId: 192801683
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/query2')
-rw-r--r--src/main/java/com/google/devtools/build/lib/query2/ParallelSkyQueryUtils.java25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/ParallelSkyQueryUtils.java b/src/main/java/com/google/devtools/build/lib/query2/ParallelSkyQueryUtils.java
index e0a09851fa..a418f41bdf 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/ParallelSkyQueryUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/ParallelSkyQueryUtils.java
@@ -17,6 +17,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ArrayListMultimap;
@@ -142,7 +143,7 @@ public class ParallelSkyQueryUtils {
() -> {
Callback<Target> visitorCallback =
ParallelVisitor.createParallelVisitorCallback(
- new TransitiveClosureVisitor.Factory(
+ new TransitiveTraversalValueDTCVisitor.Factory(
env,
env.createSkyKeyUniquifier(),
processResultsBatchSize,
@@ -703,13 +704,15 @@ public class ParallelSkyQueryUtils {
}
}
- /** Helper class that computes DTC in the form of {@link SkyKey} via BFS. */
- // TODO(nharmata): This should only be for the TTV-land DTC (i.e. only follow TTV -> TTV edges).
- private static class TransitiveClosureVisitor extends ParallelVisitor<SkyKey, SkyKey> {
+ /**
+ * Helper class that computes the TTV-only DTC of some given TTV keys, via BFS following all
+ * TTV->TTV dep edges.
+ */
+ private static class TransitiveTraversalValueDTCVisitor extends ParallelVisitor<SkyKey, SkyKey> {
private final SkyQueryEnvironment env;
private final Uniquifier<SkyKey> uniquifier;
- private TransitiveClosureVisitor(
+ private TransitiveTraversalValueDTCVisitor(
SkyQueryEnvironment env,
Uniquifier<SkyKey> uniquifier,
int processResultsBatchSize,
@@ -738,7 +741,7 @@ public class ParallelSkyQueryUtils {
@Override
public ParallelVisitor<SkyKey, SkyKey> create() {
- return new TransitiveClosureVisitor(
+ return new TransitiveTraversalValueDTCVisitor(
env, uniquifier, processResultsBatchSize, aggregateAllCallback);
}
}
@@ -751,15 +754,19 @@ public class ParallelSkyQueryUtils {
}
@Override
- protected Visit getVisitResult(Iterable<SkyKey> values) throws InterruptedException {
- Multimap<SkyKey, SkyKey> deps = env.getDirectDepsOfSkyKeys(values);
+ protected Visit getVisitResult(Iterable<SkyKey> ttvKeys) throws InterruptedException {
+ Multimap<SkyKey, SkyKey> deps = env.getDirectDepsOfSkyKeys(ttvKeys);
return new Visit(
/*keysToUseForResult=*/ deps.keySet(),
- /*keysToVisit=*/ ImmutableSet.copyOf(deps.values()));
+ /*keysToVisit=*/ deps.values().stream()
+ .filter(SkyQueryEnvironment.IS_TTV)
+ .collect(ImmutableList.toImmutableList()));
}
@Override
protected Iterable<SkyKey> preprocessInitialVisit(Iterable<SkyKey> keys) {
+ // ParallelVisitorCallback passes in TTV keys.
+ Preconditions.checkState(Iterables.all(keys, SkyQueryEnvironment.IS_TTV), keys);
return keys;
}