From e933d5edbcd9d46d3a636c1265250e9c45861804 Mon Sep 17 00:00:00 2001 From: Janak Ramakrishnan Date: Fri, 8 Jan 2016 16:43:54 +0000 Subject: When transforming labels into targets in SkyQueryEnvironment, stream the result to a callback instead of returning it directly. This means that the targets a precomputed pattern resolves to can be processed incrementally. This is the sixth and hopefully final step in a series to allow processing large sets of targets in query target patterns via streaming batches rather than all at once. This should improve performance for SkyQueryEnvironment for certain classes of large queries. -- MOS_MIGRATED_REVID=111697983 --- .../build/lib/query2/SkyQueryEnvironment.java | 70 +++++++++++++++------- 1 file changed, 48 insertions(+), 22 deletions(-) (limited to 'src') 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 f6181f29ea..7df803396a 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 @@ -14,7 +14,6 @@ package com.google.devtools.build.lib.query2; import com.google.common.base.Function; -import com.google.common.base.Functions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.ArrayListMultimap; @@ -185,10 +184,10 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment { private Map> makeTargetsMap(Map> input) { ImmutableMap.Builder> result = ImmutableMap.builder(); - Map allTargets = makeTargetsWithAssociations( - Sets.newHashSet(Iterables.concat(input.values()))); + Map allTargets = + makeTargetsFromSkyKeys(Sets.newHashSet(Iterables.concat(input.values()))); - for (Map.Entry entry : makeTargetsWithAssociations(input.keySet()).entrySet()) { + for (Map.Entry entry : makeTargetsFromSkyKeys(input.keySet()).entrySet()) { Iterable skyKeys = input.get(entry.getKey()); Set targets = CompactHashSet.createWithExpectedSize(Iterables.size(skyKeys)); for (SkyKey key : skyKeys) { @@ -316,8 +315,7 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment { aggregator.processLastPending(); } - @Override - public Uniquifier createUniquifier() { + private static Uniquifier uniquifier() { return new AbstractUniquifier() { @Override protected Label extractKey(Target target) { @@ -326,6 +324,11 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment { }; } + @Override + public Uniquifier createUniquifier() { + return uniquifier(); + } + /** * Wraps a {@link Callback} with three additional filtering mechanisms. First, it * validates the scope of the targets it's given before it passes them to the delegate Callback. @@ -366,7 +369,7 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment { Set