diff options
author | Googler <noreply@google.com> | 2016-10-31 14:54:37 +0000 |
---|---|---|
committer | Laszlo Csomor <laszlocsomor@google.com> | 2016-10-31 15:05:43 +0000 |
commit | 2dd4c183294b46a2509aef395596d39a17b7536f (patch) | |
tree | 0bd30facdea92546b41cbd31e56bc17c750aff52 /src/main/java/com/google/devtools | |
parent | a5b1674d7b237965694217b82c907ac5d64ce053 (diff) |
Add method getCurrentlyAvailableNodes to QueryableGraph and Walkable Graph
It allows all graph implementations to return the list of nodes which are
immediately available to be fetched. NOTE: Not-currently-available here does
not mean the nodes do not exist in the graph. It simply means they are not
ready to be fetched immediately yet.
--
MOS_MIGRATED_REVID=137701432
Diffstat (limited to 'src/main/java/com/google/devtools')
4 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java b/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java index 5c22a05de2..27475dbbb3 100644 --- a/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java +++ b/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java @@ -126,4 +126,9 @@ public class DelegatingWalkableGraph implements WalkableGraph { return result; } + @Override + public Iterable<SkyKey> getCurrentlyAvailableNodes(Iterable<SkyKey> keys, Reason reason) { + return graph.getCurrentlyAvailableNodes(keys, reason); + } + } diff --git a/src/main/java/com/google/devtools/build/skyframe/InMemoryGraphImpl.java b/src/main/java/com/google/devtools/build/skyframe/InMemoryGraphImpl.java index 77b1259ce9..71c3ad34c1 100644 --- a/src/main/java/com/google/devtools/build/skyframe/InMemoryGraphImpl.java +++ b/src/main/java/com/google/devtools/build/skyframe/InMemoryGraphImpl.java @@ -17,6 +17,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.MapMaker; import com.google.common.collect.Maps; import java.util.Collections; @@ -127,4 +128,15 @@ public class InMemoryGraphImpl implements InMemoryGraph { boolean keepsEdges() { return keepEdges; } + + @Override + public Iterable<SkyKey> getCurrentlyAvailableNodes(Iterable<SkyKey> keys, Reason reason) { + ImmutableSet.Builder<SkyKey> builder = ImmutableSet.builder(); + for (SkyKey key : keys) { + if (get(null, reason, key) != null) { + builder.add(key); + } + } + return builder.build(); + } } diff --git a/src/main/java/com/google/devtools/build/skyframe/QueryableGraph.java b/src/main/java/com/google/devtools/build/skyframe/QueryableGraph.java index 028684471b..7c4971efe9 100644 --- a/src/main/java/com/google/devtools/build/skyframe/QueryableGraph.java +++ b/src/main/java/com/google/devtools/build/skyframe/QueryableGraph.java @@ -49,6 +49,17 @@ public interface QueryableGraph { @Nullable SkyKey requestor, Reason reason, Iterable<SkyKey> keys) throws InterruptedException; /** + * Examines all the given keys. Returns an iterable of keys whose corresponding nodes are + * currently available to be fetched. + * + * <p>Note: An unavailable node does not mean it is not in the graph. It only means it's not ready + * to be fetched immediately. + * + * @param reason the reason the nodes are being requested. + */ + Iterable<SkyKey> getCurrentlyAvailableNodes(Iterable<SkyKey> keys, Reason reason); + + /** * The reason that a node is being looked up in the Skyframe graph. * * <p>Alternate graph implementations may wish to make use of this information. diff --git a/src/main/java/com/google/devtools/build/skyframe/WalkableGraph.java b/src/main/java/com/google/devtools/build/skyframe/WalkableGraph.java index 9f71f1fdb1..240ea7c0a8 100644 --- a/src/main/java/com/google/devtools/build/skyframe/WalkableGraph.java +++ b/src/main/java/com/google/devtools/build/skyframe/WalkableGraph.java @@ -15,6 +15,7 @@ package com.google.devtools.build.skyframe; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; import com.google.devtools.build.lib.events.EventHandler; +import com.google.devtools.build.skyframe.QueryableGraph.Reason; import java.util.Collection; import java.util.Map; import javax.annotation.Nullable; @@ -80,6 +81,15 @@ public interface WalkableGraph { */ Map<SkyKey, Iterable<SkyKey>> getReverseDeps(Iterable<SkyKey> keys) throws InterruptedException; + /** + * Examines all the given keys. Returns an iterable of keys whose corresponding nodes are + * currently available to be fetched. + * + * <p>Note: An unavailable node does not mean it is not in the graph. It only means it's not ready + * to be fetched immediately. + */ + Iterable<SkyKey> getCurrentlyAvailableNodes(Iterable<SkyKey> keys, Reason reason); + /** Provides a WalkableGraph on demand after preparing it. */ interface WalkableGraphFactory { EvaluationResult<SkyValue> prepareAndGet(Collection<String> roots, String offset, |