aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java
diff options
context:
space:
mode:
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.java62
1 files changed, 33 insertions, 29 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 c56bf55132..5c22a05de2 100644
--- a/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java
+++ b/src/main/java/com/google/devtools/build/skyframe/DelegatingWalkableGraph.java
@@ -13,8 +13,6 @@
// limitations under the License.
package com.google.devtools.build.skyframe;
-import com.google.common.base.Function;
-import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.devtools.build.lib.util.Preconditions;
@@ -22,7 +20,6 @@ import com.google.devtools.build.skyframe.QueryableGraph.Reason;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-
import javax.annotation.Nullable;
/**
@@ -35,7 +32,7 @@ public class DelegatingWalkableGraph implements WalkableGraph {
this.graph = graph;
}
- private NodeEntry getEntryForValue(SkyKey key) {
+ private NodeEntry getEntryForValue(SkyKey key) throws InterruptedException {
NodeEntry entry =
Preconditions.checkNotNull(
graph.getBatch(null, Reason.WALKABLE_GRAPH_VALUE, ImmutableList.of(key)).get(key),
@@ -45,7 +42,7 @@ public class DelegatingWalkableGraph implements WalkableGraph {
}
@Override
- public boolean exists(SkyKey key) {
+ 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();
@@ -53,32 +50,35 @@ public class DelegatingWalkableGraph implements WalkableGraph {
@Nullable
@Override
- public SkyValue getValue(SkyKey key) {
+ public SkyValue getValue(SkyKey key) throws InterruptedException {
return getEntryForValue(key).getValue();
}
- private static final Function<NodeEntry, SkyValue> GET_SKY_VALUE_FUNCTION =
- new Function<NodeEntry, SkyValue>() {
- @Nullable
- @Override
- public SkyValue apply(NodeEntry entry) {
- return entry.isDone() ? entry.getValue() : null;
- }
- };
+ private static SkyValue getValue(NodeEntry entry) throws InterruptedException {
+ return entry.isDone() ? entry.getValue() : null;
+ }
@Override
- public Map<SkyKey, SkyValue> getSuccessfulValues(Iterable<SkyKey> keys) {
- return Maps.filterValues(
- Maps.transformValues(
- graph.getBatch(null, Reason.WALKABLE_GRAPH_VALUE, keys),
- GET_SKY_VALUE_FUNCTION),
- Predicates.notNull());
+ public Map<SkyKey, SkyValue> getSuccessfulValues(Iterable<SkyKey> keys)
+ throws InterruptedException {
+ Map<SkyKey, ? extends NodeEntry> batchGet =
+ graph.getBatch(null, Reason.WALKABLE_GRAPH_VALUE, keys);
+ Map<SkyKey, SkyValue> result = Maps.newHashMapWithExpectedSize(batchGet.size());
+ for (Entry<SkyKey, ? extends NodeEntry> entryPair : batchGet.entrySet()) {
+ SkyValue value = getValue(entryPair.getValue());
+ if (value != null) {
+ result.put(entryPair.getKey(), value);
+ }
+ }
+ return result;
}
@Override
- public Map<SkyKey, Exception> getMissingAndExceptions(Iterable<SkyKey> keys) {
+ public Map<SkyKey, Exception> getMissingAndExceptions(Iterable<SkyKey> keys)
+ throws InterruptedException {
Map<SkyKey, Exception> result = new HashMap<>();
- Map<SkyKey, NodeEntry> graphResult = graph.getBatch(null, Reason.WALKABLE_GRAPH_VALUE, keys);
+ Map<SkyKey, ? extends NodeEntry> graphResult =
+ graph.getBatch(null, Reason.WALKABLE_GRAPH_VALUE, keys);
for (SkyKey key : keys) {
NodeEntry nodeEntry = graphResult.get(key);
if (nodeEntry == null || !nodeEntry.isDone()) {
@@ -95,16 +95,18 @@ public class DelegatingWalkableGraph implements WalkableGraph {
@Nullable
@Override
- public Exception getException(SkyKey key) {
+ public Exception getException(SkyKey key) throws InterruptedException {
ErrorInfo errorInfo = getEntryForValue(key).getErrorInfo();
return errorInfo == null ? null : errorInfo.getException();
}
@Override
- public Map<SkyKey, Iterable<SkyKey>> getDirectDeps(Iterable<SkyKey> keys) {
- Map<SkyKey, NodeEntry> entries = graph.getBatch(null, Reason.WALKABLE_GRAPH_DEPS, keys);
+ public Map<SkyKey, Iterable<SkyKey>> getDirectDeps(Iterable<SkyKey> keys)
+ throws InterruptedException {
+ Map<SkyKey, ? extends NodeEntry> entries =
+ graph.getBatch(null, Reason.WALKABLE_GRAPH_DEPS, keys);
Map<SkyKey, Iterable<SkyKey>> result = new HashMap<>(entries.size());
- for (Entry<SkyKey, NodeEntry> entry : entries.entrySet()) {
+ for (Entry<SkyKey, ? extends NodeEntry> entry : entries.entrySet()) {
Preconditions.checkState(entry.getValue().isDone(), entry);
result.put(entry.getKey(), entry.getValue().getDirectDeps());
}
@@ -112,10 +114,12 @@ public class DelegatingWalkableGraph implements WalkableGraph {
}
@Override
- public Map<SkyKey, Iterable<SkyKey>> getReverseDeps(Iterable<SkyKey> keys) {
- Map<SkyKey, NodeEntry> entries = graph.getBatch(null, Reason.WALKABLE_GRAPH_RDEPS, keys);
+ public Map<SkyKey, Iterable<SkyKey>> getReverseDeps(Iterable<SkyKey> keys)
+ throws InterruptedException {
+ Map<SkyKey, ? extends NodeEntry> entries =
+ graph.getBatch(null, Reason.WALKABLE_GRAPH_RDEPS, keys);
Map<SkyKey, Iterable<SkyKey>> result = new HashMap<>(entries.size());
- for (Entry<SkyKey, NodeEntry> entry : entries.entrySet()) {
+ for (Entry<SkyKey, ? extends NodeEntry> entry : entries.entrySet()) {
Preconditions.checkState(entry.getValue().isDone(), entry);
result.put(entry.getKey(), entry.getValue().getReverseDeps());
}