aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Miguel Alcon Pinto <malcon@google.com>2015-10-20 20:21:12 +0000
committerGravatar Han-Wen Nienhuys <hanwen@google.com>2015-10-21 14:36:15 +0000
commit714873552264cc7eca6c1ec98b3b811837e3d707 (patch)
treec003785859c7b74090d5444e128b5726692af01c /src
parent2e03909339ea2bc122582cabb0fa8e33a8960293 (diff)
Use a thin graph when querying reverse deps (or others that don't need the values).
-- MOS_MIGRATED_REVID=105893837
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java29
1 files changed, 20 insertions, 9 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 1565090442..82cad233fb 100644
--- a/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java
+++ b/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java
@@ -28,19 +28,30 @@ import javax.annotation.Nullable;
* {@link WalkableGraph} that looks nodes up in a {@link QueryableGraph}.
*/
public class DelegatingWalkableGraph implements WalkableGraph {
- private final QueryableGraph graph;
+
+ private final QueryableGraph fullGraph;
+ private final QueryableGraph thinGraph;
public DelegatingWalkableGraph(QueryableGraph graph) {
- this.graph = graph;
+ this(graph, graph);
+ }
+
+ /**
+ * Use this constructor when you want to differentiate reads that require the node value vs reads
+ * that only traverse dependencies.
+ */
+ public DelegatingWalkableGraph(QueryableGraph fullGraph, QueryableGraph thinGraph) {
+ this.fullGraph = fullGraph;
+ this.thinGraph = thinGraph;
}
private NodeEntry getEntry(SkyKey key) {
- NodeEntry entry = Preconditions.checkNotNull(graph.get(key), key);
+ NodeEntry entry = Preconditions.checkNotNull(fullGraph.get(key), key);
Preconditions.checkState(entry.isDone(), "%s %s", key, entry);
return entry;
}
- private Map<SkyKey, NodeEntry> getEntries(Iterable<SkyKey> keys) {
+ private static Map<SkyKey, NodeEntry> getEntries(Iterable<SkyKey> keys, QueryableGraph graph) {
Map<SkyKey, NodeEntry> result = graph.getBatch(keys);
Preconditions.checkState(result.size() == Iterables.size(keys), "%s %s", keys, result);
for (Map.Entry<SkyKey, NodeEntry> entry : result.entrySet()) {
@@ -51,7 +62,7 @@ public class DelegatingWalkableGraph implements WalkableGraph {
@Override
public boolean exists(SkyKey key) {
- NodeEntry entry = graph.get(key);
+ NodeEntry entry = thinGraph.get(key);
return entry != null && entry.isDone();
}
@@ -72,14 +83,14 @@ public class DelegatingWalkableGraph implements WalkableGraph {
@Override
public Map<SkyKey, SkyValue> getSuccessfulValues(Iterable<SkyKey> keys) {
- return Maps.filterValues(Maps.transformValues(graph.getBatch(keys), GET_SKY_VALUE_FUNCTION),
+ return Maps.filterValues(Maps.transformValues(fullGraph.getBatch(keys), GET_SKY_VALUE_FUNCTION),
Predicates.notNull());
}
@Override
public Map<SkyKey, Exception> getMissingAndExceptions(Iterable<SkyKey> keys) {
Map<SkyKey, Exception> result = new HashMap<>();
- Map<SkyKey, NodeEntry> graphResult = graph.getBatch(keys);
+ Map<SkyKey, NodeEntry> graphResult = fullGraph.getBatch(keys);
for (SkyKey key : keys) {
NodeEntry nodeEntry = graphResult.get(key);
if (nodeEntry == null || !nodeEntry.isDone()) {
@@ -111,7 +122,7 @@ public class DelegatingWalkableGraph implements WalkableGraph {
@Override
public Map<SkyKey, Iterable<SkyKey>> getDirectDeps(Iterable<SkyKey> keys) {
- return Maps.transformValues(getEntries(keys), GET_DIRECT_DEPS_FUNCTION);
+ return Maps.transformValues(getEntries(keys, thinGraph), GET_DIRECT_DEPS_FUNCTION);
}
private static final Function<NodeEntry, Iterable<SkyKey>> GET_REVERSE_DEPS_FUNCTION =
@@ -124,6 +135,6 @@ public class DelegatingWalkableGraph implements WalkableGraph {
@Override
public Map<SkyKey, Iterable<SkyKey>> getReverseDeps(Iterable<SkyKey> keys) {
- return Maps.transformValues(getEntries(keys), GET_REVERSE_DEPS_FUNCTION);
+ return Maps.transformValues(getEntries(keys, thinGraph), GET_REVERSE_DEPS_FUNCTION);
}
}