diff options
author | 2016-04-29 22:58:37 +0000 | |
---|---|---|
committer | 2016-05-02 09:10:16 +0000 | |
commit | 2cdbb29ebfccb6b4177e6f11f1c8bbf2e557575c (patch) | |
tree | 7a9b8153fb053a35fb3268a309b9a10234d63dd8 /src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java | |
parent | e9cd0f315750a4b313768165b0b80ea1e81416d5 (diff) |
Delay retrieval of the blacklist patterns file from the graph until we actually need it.
--
MOS_MIGRATED_REVID=121160209
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java index 0097b169e0..349661d8dd 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java @@ -16,6 +16,8 @@ package com.google.devtools.build.lib.query2; import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableList; @@ -110,7 +112,7 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> { protected WalkableGraph graph; private ImmutableList<TargetPatternKey> universeTargetPatternKeys; - private ImmutableSet<PathFragment> blacklistPatterns; + private Supplier<ImmutableSet<PathFragment>> blacklistPatternsSupplier; private final Map<String, Set<Label>> precomputedPatterns = new HashMap<>(); private final BlazeTargetAccessor accessor = new BlazeTargetAccessor(this); @@ -131,6 +133,21 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> { } }; + private static class BlacklistSupplier implements Supplier<ImmutableSet<PathFragment>> { + private final WalkableGraph graph; + + BlacklistSupplier(WalkableGraph graph) { + this.graph = graph; + } + + @Override + public ImmutableSet<PathFragment> get() { + return ((BlacklistedPackagePrefixesValue) + graph.getValue(BlacklistedPackagePrefixesValue.key())) + .getPatterns(); + } + } + public SkyQueryEnvironment(boolean keepGoing, boolean strictScope, int loadingPhaseThreads, Predicate<Label> labelFilter, EventHandler eventHandler, @@ -159,10 +176,7 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> { } graph = result.getWalkableGraph(); - blacklistPatterns = - Preconditions.checkNotNull( - (BlacklistedPackagePrefixesValue) graph.getValue(BlacklistedPackagePrefixesValue.key())) - .getPatterns(); + blacklistPatternsSupplier = Suppliers.memoize(new BlacklistSupplier(graph)); SkyKey universeKey = graphFactory.getUniverseKey(universeScope, parserPrefix); universeTargetPatternKeys = @@ -475,7 +489,7 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> { provider, eventHandler, targetPatternKey.getPolicy(), threadPool); TargetPattern parsedPattern = targetPatternKey.getParsedPattern(); ImmutableSet<PathFragment> subdirectoriesToExclude = - targetPatternKey.getAllSubdirectoriesToExclude(blacklistPatterns); + targetPatternKey.getAllSubdirectoriesToExclude(blacklistPatternsSupplier.get()); FilteringBatchingUniquifyingCallback wrapper = new FilteringBatchingUniquifyingCallback(callback); parsedPattern.eval(resolver, subdirectoriesToExclude, wrapper, QueryException.class); |