Skip to content

Commit

Permalink
Don't directly use the SkyQueryEnvironment's graph to find rdeps duri…
Browse files Browse the repository at this point in the history
…ng a query.

PiperOrigin-RevId: 288521382
  • Loading branch information
shreyax authored and copybara-github committed Jan 7, 2020
1 parent 1d6828a commit 5e69f08
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected Visit getVisitResult(Iterable<DepAndRdepAtDepth> depAndRdepAtDepths)
// Retrieve the reverse deps as SkyKeys and defer the targetification and filtering to next
// recursive visitation.
Map<SkyKey, Iterable<SkyKey>> unfilteredRdepsOfRdeps =
env.graph.getReverseDeps(uniqueValidRdepsBelowDepthBound);
env.getReverseDepLabelsOfLabels(uniqueValidRdepsBelowDepthBound);

ImmutableList.Builder<DepAndRdepAtDepth> depAndRdepAtDepthsToVisitBuilder =
ImmutableList.builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ protected Visit getVisitResult(Iterable<DepAndRdep> depAndRdeps)
// need to filter out disallowed edges, but cannot do so before targetification occurs. This
// means we may be wastefully visiting nodes via disallowed edges.
ImmutableList.Builder<DepAndRdep> depAndRdepsToVisitBuilder = ImmutableList.builder();
env.graph
.getReverseDeps(uniqueValidRdeps)
env.getReverseDepLabelsOfLabels(uniqueValidRdeps)
.entrySet()
.forEach(
reverseDepsEntry ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,12 @@ private Map<SkyKey, Collection<Target>> targetifyValues(

private Map<SkyKey, Collection<Target>> getRawReverseDeps(
Iterable<SkyKey> transitiveTraversalKeys) throws InterruptedException {
return targetifyValues(graph.getReverseDeps(transitiveTraversalKeys));
return targetifyValues(getReverseDepLabelsOfLabels(transitiveTraversalKeys));
}

protected Map<SkyKey, Iterable<SkyKey>> getReverseDepLabelsOfLabels(Iterable<SkyKey> labels)
throws InterruptedException {
return graph.getReverseDeps(labels);
}

private Set<Label> getAllowedDeps(Rule rule) throws InterruptedException {
Expand Down Expand Up @@ -549,14 +554,13 @@ protected Map<SkyKey, Iterable<SkyKey>> getFwdDepLabels(Iterable<SkyKey> targetL
public Collection<Target> getReverseDeps(
Iterable<Target> targets, QueryExpressionContext<Target> context)
throws InterruptedException {
return getReverseDepsOfLabels(Iterables.transform(targets, Target::getLabel));
return processRawReverseDeps(
getReverseDepsOfLabels(Iterables.transform(targets, Target::getLabel)));
}

protected Collection<Target> getReverseDepsOfLabels(Iterable<Label> targetLabels)
protected Map<SkyKey, Collection<Target>> getReverseDepsOfLabels(Iterable<Label> targetLabels)
throws InterruptedException {
Map<SkyKey, Collection<Target>> rawReverseDeps =
getRawReverseDeps(Iterables.transform(targetLabels, label -> label));
return processRawReverseDeps(rawReverseDeps);
return getRawReverseDeps(Iterables.transform(targetLabels, label -> label));
}

/** Targetify SkyKeys of reverse deps and filter out targets whose deps are not allowed. */
Expand Down

0 comments on commit 5e69f08

Please sign in to comment.