aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2016-12-29 21:49:56 +0000
committerGravatar John Cater <jcater@google.com>2017-01-03 15:03:05 +0000
commit112840b4d6fafd04e2381a2e52fbad848a818ea6 (patch)
treef82825c5b02480612178f8238812590925c67909 /src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java
parentc31f351a191d6927a6483384826297e5549cf426 (diff)
Remove WalkableGraph#exists and allow WalkableGraph#getValue and WalkableGraph#getException to be given non-existent keys without crashing. Add WalkableGraph#isCycle to fill the gap in testing for the difference between non-existence and depending on a cycle.
-- PiperOrigin-RevId: 143205289 MOS_MIGRATED_REVID=143205289
Diffstat (limited to 'src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java')
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java34
1 files changed, 20 insertions, 14 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 27475dbbb3..8abf5de670 100644
--- a/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java
+++ b/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java
@@ -32,26 +32,18 @@ public class DelegatingWalkableGraph implements WalkableGraph {
this.graph = graph;
}
+ @Nullable
private NodeEntry getEntryForValue(SkyKey key) throws InterruptedException {
NodeEntry entry =
- Preconditions.checkNotNull(
- graph.getBatch(null, Reason.WALKABLE_GRAPH_VALUE, ImmutableList.of(key)).get(key),
- key);
- Preconditions.checkState(entry.isDone(), "%s %s", key, entry);
- return entry;
- }
-
- @Override
- public boolean exists(SkyKey key) throws InterruptedException {
- NodeEntry entry =
- graph.getBatch(null, Reason.EXISTENCE_CHECKING, ImmutableList.of(key)).get(key);
- return entry != null && entry.isDone();
+ graph.getBatch(null, Reason.WALKABLE_GRAPH_VALUE, ImmutableList.of(key)).get(key);
+ return entry != null && entry.isDone() ? entry : null;
}
@Nullable
@Override
public SkyValue getValue(SkyKey key) throws InterruptedException {
- return getEntryForValue(key).getValue();
+ NodeEntry entry = getEntryForValue(key);
+ return entry == null ? null : entry.getValue();
}
private static SkyValue getValue(NodeEntry entry) throws InterruptedException {
@@ -93,10 +85,24 @@ public class DelegatingWalkableGraph implements WalkableGraph {
return result;
}
+ @Override
+ public boolean isCycle(SkyKey key) throws InterruptedException {
+ NodeEntry entry = getEntryForValue(key);
+ if (entry == null) {
+ return false;
+ }
+ ErrorInfo errorInfo = entry.getErrorInfo();
+ return errorInfo != null && errorInfo.getCycleInfo() != null;
+ }
+
@Nullable
@Override
public Exception getException(SkyKey key) throws InterruptedException {
- ErrorInfo errorInfo = getEntryForValue(key).getErrorInfo();
+ NodeEntry entry = getEntryForValue(key);
+ if (entry == null) {
+ return null;
+ }
+ ErrorInfo errorInfo = entry.getErrorInfo();
return errorInfo == null ? null : errorInfo.getException();
}