aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2016-07-08 17:38:27 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-07-11 09:39:22 +0000
commitcc7712f0acff385046d76b9012eeb342452d93ac (patch)
treef5d532b527aab6ece71fa4502f898db75dd0aea2
parenta59a8b83cd57720fd9579378a96965c6b56dccc1 (diff)
Refactor QueryableGraph and ThinNodeQueryableGraph to be independent interfaces, in preparation for further changes.
-- MOS_MIGRATED_REVID=126924789
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/DelegatingNodeEntry.java8
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/DeletableGraph.java (renamed from src/main/java/com/google/devtools/build/skyframe/DirtiableGraph.java)10
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/EagerInvalidator.java27
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/EvaluableGraph.java2
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/InMemoryGraph.java2
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java5
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/InvalidatableGraph.java (renamed from src/main/java/com/google/devtools/build/skyframe/ThinNodeQueryableGraph.java)16
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/InvalidatingNodeVisitor.java12
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/MemoizingEvaluator.java26
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/NodeEntry.java53
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/ProcessableGraph.java7
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/QueryableGraph.java12
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/ThinNodeEntry.java34
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java6
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/BUILD2
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/DeterministicHelper.java (renamed from src/test/java/com/google/devtools/build/skyframe/DeterministicGraph.java)89
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/DeterministicInMemoryGraph.java20
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java17
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java12
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java (renamed from src/test/java/com/google/devtools/build/skyframe/NotifyingGraph.java)127
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/NotifyingInMemoryGraph.java13
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/ParallelEvaluatorTest.java20
23 files changed, 277 insertions, 249 deletions
diff --git a/src/main/java/com/google/devtools/build/skyframe/DelegatingNodeEntry.java b/src/main/java/com/google/devtools/build/skyframe/DelegatingNodeEntry.java
index 8e9ddb62b7..d714924e29 100644
--- a/src/main/java/com/google/devtools/build/skyframe/DelegatingNodeEntry.java
+++ b/src/main/java/com/google/devtools/build/skyframe/DelegatingNodeEntry.java
@@ -157,22 +157,22 @@ public abstract class DelegatingNodeEntry implements NodeEntry {
@Override
public Iterable<SkyKey> getDirectDeps() {
- return getThinDelegate().getDirectDeps();
+ return getDelegate().getDirectDeps();
}
@Override
public void removeReverseDep(SkyKey reverseDep) {
- getThinDelegate().removeReverseDep(reverseDep);
+ getDelegate().removeReverseDep(reverseDep);
}
@Override
public void removeInProgressReverseDep(SkyKey reverseDep) {
- getThinDelegate().removeInProgressReverseDep(reverseDep);
+ getDelegate().removeInProgressReverseDep(reverseDep);
}
@Override
public Iterable<SkyKey> getReverseDeps() {
- return getThinDelegate().getReverseDeps();
+ return getDelegate().getReverseDeps();
}
@Override
diff --git a/src/main/java/com/google/devtools/build/skyframe/DirtiableGraph.java b/src/main/java/com/google/devtools/build/skyframe/DeletableGraph.java
index fe7e88bdb8..d091f083d6 100644
--- a/src/main/java/com/google/devtools/build/skyframe/DirtiableGraph.java
+++ b/src/main/java/com/google/devtools/build/skyframe/DeletableGraph.java
@@ -19,13 +19,11 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
* Interface for classes that need to remove values from graph. Currently just used by {@link
* EagerInvalidator}.
*
- * <p>This class is not intended for direct use, and is only exposed as public for use in
- * evaluation implementations outside of this package.
+ * <p>This class is not intended for direct use, and is only exposed as public for use in evaluation
+ * implementations outside of this package.
*/
@ThreadSafe
-public interface DirtiableGraph extends QueryableGraph {
- /**
- * Remove the value with given name from the graph.
- */
+public interface DeletableGraph {
+ /** Remove the value with given name from the graph. */
void remove(SkyKey key);
}
diff --git a/src/main/java/com/google/devtools/build/skyframe/EagerInvalidator.java b/src/main/java/com/google/devtools/build/skyframe/EagerInvalidator.java
index bb6d2b2685..b7c1ee9545 100644
--- a/src/main/java/com/google/devtools/build/skyframe/EagerInvalidator.java
+++ b/src/main/java/com/google/devtools/build/skyframe/EagerInvalidator.java
@@ -43,9 +43,14 @@ public final class EagerInvalidator {
* long as the full upward transitive closure of the nodes is specified for deletion, the graph
* remains consistent.
*/
- public static void delete(DirtiableGraph graph, Iterable<SkyKey> diff,
- EvaluationProgressReceiver invalidationReceiver, InvalidationState state,
- boolean traverseGraph, DirtyKeyTracker dirtyKeyTracker) throws InterruptedException {
+ public static void delete(
+ InMemoryGraph graph,
+ Iterable<SkyKey> diff,
+ EvaluationProgressReceiver invalidationReceiver,
+ InvalidationState state,
+ boolean traverseGraph,
+ DirtyKeyTracker dirtyKeyTracker)
+ throws InterruptedException {
DeletingNodeVisitor visitor =
createDeletingVisitorIfNeeded(
graph, diff, invalidationReceiver, state, traverseGraph, dirtyKeyTracker);
@@ -56,7 +61,7 @@ public final class EagerInvalidator {
@Nullable
static DeletingNodeVisitor createDeletingVisitorIfNeeded(
- DirtiableGraph graph,
+ InMemoryGraph graph,
Iterable<SkyKey> diff,
EvaluationProgressReceiver invalidationReceiver,
InvalidationState state,
@@ -70,7 +75,7 @@ public final class EagerInvalidator {
@Nullable
static DirtyingNodeVisitor createInvalidatingVisitorIfNeeded(
- ThinNodeQueryableGraph graph,
+ InvalidatableGraph graph,
Iterable<SkyKey> diff,
EvaluationProgressReceiver invalidationReceiver,
InvalidationState state,
@@ -84,7 +89,7 @@ public final class EagerInvalidator {
@Nullable
private static DirtyingNodeVisitor createInvalidatingVisitorIfNeeded(
- ThinNodeQueryableGraph graph,
+ InvalidatableGraph graph,
Iterable<SkyKey> diff,
EvaluationProgressReceiver invalidationReceiver,
InvalidationState state,
@@ -110,7 +115,7 @@ public final class EagerInvalidator {
* an executor constructed with the provided factory.
*/
public static void invalidate(
- ThinNodeQueryableGraph graph,
+ InvalidatableGraph graph,
Iterable<SkyKey> diff,
EvaluationProgressReceiver invalidationReceiver,
InvalidationState state,
@@ -130,7 +135,7 @@ public final class EagerInvalidator {
* the provided {@link ForkJoinPool}.
*/
public static void invalidate(
- ThinNodeQueryableGraph graph,
+ InvalidatableGraph graph,
Iterable<SkyKey> diff,
EvaluationProgressReceiver invalidationReceiver,
InvalidationState state,
@@ -154,11 +159,9 @@ public final class EagerInvalidator {
}
}
- /**
- * Invalidates given values and their upward transitive closure in the graph.
- */
+ /** Invalidates given values and their upward transitive closure in the graph. */
public static void invalidate(
- DirtiableGraph graph,
+ InvalidatableGraph graph,
Iterable<SkyKey> diff,
EvaluationProgressReceiver invalidationReceiver,
InvalidationState state,
diff --git a/src/main/java/com/google/devtools/build/skyframe/EvaluableGraph.java b/src/main/java/com/google/devtools/build/skyframe/EvaluableGraph.java
index 7527146b30..b3d8bd0ac2 100644
--- a/src/main/java/com/google/devtools/build/skyframe/EvaluableGraph.java
+++ b/src/main/java/com/google/devtools/build/skyframe/EvaluableGraph.java
@@ -22,7 +22,7 @@ import java.util.Map;
* single version of the graph.
*/
@ThreadSafe
-interface EvaluableGraph extends QueryableGraph {
+interface EvaluableGraph extends QueryableGraph, DeletableGraph {
/**
* Like {@link QueryableGraph#getBatch}, except it creates a new node for each key not already
* present in the graph. Thus, the returned map will have an entry for each key in {@code keys}.
diff --git a/src/main/java/com/google/devtools/build/skyframe/InMemoryGraph.java b/src/main/java/com/google/devtools/build/skyframe/InMemoryGraph.java
index 02735c0e8e..5d508a9eb1 100644
--- a/src/main/java/com/google/devtools/build/skyframe/InMemoryGraph.java
+++ b/src/main/java/com/google/devtools/build/skyframe/InMemoryGraph.java
@@ -16,7 +16,7 @@ package com.google.devtools.build.skyframe;
import java.util.Map;
/** {@link ProcessableGraph} that exposes the contents of the entire graph. */
-interface InMemoryGraph extends ProcessableGraph {
+interface InMemoryGraph extends ProcessableGraph, InvalidatableGraph {
/**
* Returns a read-only live view of the nodes in the graph. All node are included. Dirty values
* include their Node value. Values in error have a null value.
diff --git a/src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java b/src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java
index a5e22221e6..5d853b7aff 100644
--- a/src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java
+++ b/src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java
@@ -284,9 +284,8 @@ public final class InMemoryMemoizingEvaluator implements MemoizingEvaluator {
}
@Override
- public void injectGraphTransformerForTesting(
- Function<ThinNodeQueryableGraph, ProcessableGraph> transformer) {
- this.graph = (InMemoryGraph) transformer.apply(this.graph);
+ public void injectGraphTransformerForTesting(GraphTransformerForTesting transformer) {
+ this.graph = transformer.transform(this.graph);
}
public ProcessableGraph getGraphForTesting() {
diff --git a/src/main/java/com/google/devtools/build/skyframe/ThinNodeQueryableGraph.java b/src/main/java/com/google/devtools/build/skyframe/InvalidatableGraph.java
index eeb3ef5867..243740705a 100644
--- a/src/main/java/com/google/devtools/build/skyframe/ThinNodeQueryableGraph.java
+++ b/src/main/java/com/google/devtools/build/skyframe/InvalidatableGraph.java
@@ -17,20 +17,14 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
import java.util.Map;
-import javax.annotation.Nullable;
-
/**
- * A graph that exposes thin representations of its entries and structure, for use by classes that
- * must traverse it, but not read its entries' values.
+ * A graph that exposes thin representations of its entries and structure, for use during
+ * invalidation.
+ *
+ * <p>Public only for use in alternative graph implementations.
*/
@ThreadSafe
-public interface ThinNodeQueryableGraph {
- /**
- * Returns the thin node with the given name, or {@code null} if the node does not exist.
- */
- @Nullable
- ThinNodeEntry get(SkyKey key);
-
+public interface InvalidatableGraph {
/**
* Fetches all the given thin nodes. Returns a map {@code m} such that, for all {@code k} in
* {@code keys}, {@code m.get(k).equals(e)} iff {@code get(k) == e} and {@code e != null}, and
diff --git a/src/main/java/com/google/devtools/build/skyframe/InvalidatingNodeVisitor.java b/src/main/java/com/google/devtools/build/skyframe/InvalidatingNodeVisitor.java
index 6eec236b4e..1fe90d193e 100644
--- a/src/main/java/com/google/devtools/build/skyframe/InvalidatingNodeVisitor.java
+++ b/src/main/java/com/google/devtools/build/skyframe/InvalidatingNodeVisitor.java
@@ -62,7 +62,7 @@ import javax.annotation.Nullable;
*
* <p>This is intended only for use in alternative {@code MemoizingEvaluator} implementations.
*/
-public abstract class InvalidatingNodeVisitor<TGraph extends ThinNodeQueryableGraph> {
+public abstract class InvalidatingNodeVisitor<TGraph extends InvalidatableGraph> {
// Default thread count is equal to the number of cores to exploit
// that level of hardware parallelism, since invalidation should be CPU-bound.
@@ -236,13 +236,13 @@ public abstract class InvalidatingNodeVisitor<TGraph extends ThinNodeQueryableGr
}
/** A node-deleting implementation. */
- static class DeletingNodeVisitor extends InvalidatingNodeVisitor<DirtiableGraph> {
+ static class DeletingNodeVisitor extends InvalidatingNodeVisitor<InMemoryGraph> {
private final Set<SkyKey> visited = Sets.newConcurrentHashSet();
private final boolean traverseGraph;
DeletingNodeVisitor(
- DirtiableGraph graph,
+ InMemoryGraph graph,
EvaluationProgressReceiver invalidationReceiver,
InvalidationState state,
boolean traverseGraph,
@@ -338,7 +338,7 @@ public abstract class InvalidatingNodeVisitor<TGraph extends ThinNodeQueryableGr
}
/** A node-dirtying implementation. */
- static class DirtyingNodeVisitor extends InvalidatingNodeVisitor<ThinNodeQueryableGraph> {
+ static class DirtyingNodeVisitor extends InvalidatingNodeVisitor<InvalidatableGraph> {
private final Set<SkyKey> changed =
Collections.newSetFromMap(
@@ -351,7 +351,7 @@ public abstract class InvalidatingNodeVisitor<TGraph extends ThinNodeQueryableGr
private final boolean supportInterruptions;
protected DirtyingNodeVisitor(
- ThinNodeQueryableGraph graph,
+ InvalidatableGraph graph,
EvaluationProgressReceiver invalidationReceiver,
InvalidationState state,
DirtyKeyTracker dirtyKeyTracker,
@@ -365,7 +365,7 @@ public abstract class InvalidatingNodeVisitor<TGraph extends ThinNodeQueryableGr
* passing {@code false} for {@param supportInterruptions}.
*/
protected DirtyingNodeVisitor(
- ThinNodeQueryableGraph graph,
+ InvalidatableGraph graph,
EvaluationProgressReceiver invalidationReceiver,
InvalidationState state,
DirtyKeyTracker dirtyKeyTracker,
diff --git a/src/main/java/com/google/devtools/build/skyframe/MemoizingEvaluator.java b/src/main/java/com/google/devtools/build/skyframe/MemoizingEvaluator.java
index 269ea0927b..4d5d21c5de 100644
--- a/src/main/java/com/google/devtools/build/skyframe/MemoizingEvaluator.java
+++ b/src/main/java/com/google/devtools/build/skyframe/MemoizingEvaluator.java
@@ -14,7 +14,6 @@
package com.google.devtools.build.skyframe;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.collect.nestedset.NestedSetVisitor;
@@ -126,19 +125,18 @@ public interface MemoizingEvaluator {
/**
* Tests that want finer control over the graph being used may provide a {@code transformer} here.
- * This {@code transformer} will be applied to the graph for each invalidation/evaluation. While
- * the graph returned by {@code transformer#apply} must technically be a {@link ProcessableGraph},
- * if a {@link ThinNodeQueryableGraph} was given as the argument to {@code transformer#apply},
- * then only the methods in {@link ThinNodeQueryableGraph} will be called on the returned graph,
- * in other words it will be treated as a {@link ThinNodeQueryableGraph}. Thus, the returned graph
- * is free not to actually implement the remaining methods in {@link ProcessableGraph} in that
- * case.
- *
- * <p>Similarly, if the argument to {@code transformer#apply} is an {@link InMemoryGraph}, then
- * the resulting graph must be an {@link InMemoryGraph}.
- * */
- void injectGraphTransformerForTesting(
- Function<ThinNodeQueryableGraph, ProcessableGraph> transformer);
+ * This {@code transformer} will be applied to the graph for each invalidation/evaluation.
+ */
+ void injectGraphTransformerForTesting(GraphTransformerForTesting transformer);
+
+ /** Transforms a graph, possibly injecting other functionality. */
+ interface GraphTransformerForTesting {
+ InMemoryGraph transform(InMemoryGraph graph);
+
+ InvalidatableGraph transform(InvalidatableGraph graph);
+
+ ProcessableGraph transform(ProcessableGraph graph);
+ }
/**
* Write the graph to the output stream. Not necessarily thread-safe. Use only for debugging
diff --git a/src/main/java/com/google/devtools/build/skyframe/NodeEntry.java b/src/main/java/com/google/devtools/build/skyframe/NodeEntry.java
index 7b38324110..8b7b09193d 100644
--- a/src/main/java/com/google/devtools/build/skyframe/NodeEntry.java
+++ b/src/main/java/com/google/devtools/build/skyframe/NodeEntry.java
@@ -83,6 +83,37 @@ public interface NodeEntry extends ThinNodeEntry {
@ThreadSafe
SkyValue getValue();
+ /**
+ * Returns an immutable iterable of the direct deps of this node. This method may only be called
+ * after the evaluation of this node is complete.
+ *
+ * <p>This method is not very efficient, but is only be called in limited circumstances -- when
+ * the node is about to be deleted, or when the node is expected to have no direct deps (in which
+ * case the overhead is not so bad). It should not be called repeatedly for the same node, since
+ * each call takes time proportional to the number of direct deps of the node.
+ */
+ @ThreadSafe
+ Iterable<SkyKey> getDirectDeps();
+
+ /** Removes a reverse dependency. */
+ @ThreadSafe
+ void removeReverseDep(SkyKey reverseDep);
+
+ /**
+ * Removes a reverse dependency.
+ *
+ * <p>May only be called if this entry is not done (i.e. {@link #isDone} is false) and {@param
+ * reverseDep} is present in {@link #getReverseDeps}
+ */
+ @ThreadSafe
+ void removeInProgressReverseDep(SkyKey reverseDep);
+
+ /**
+ * Returns a copy of the set of reverse dependencies. Note that this introduces a potential
+ * check-then-act race; {@link #removeReverseDep} may fail for a key that is returned here.
+ */
+ @ThreadSafe
+ Iterable<SkyKey> getReverseDeps();
/**
* Returns raw {@link SkyValue} stored in this entry, which may include metadata associated with
@@ -236,22 +267,22 @@ public interface NodeEntry extends ThinNodeEntry {
/**
* Should only be called if the entry is dirty. During the examination to see if the entry must be
- * re-evaluated, this method returns the next group of children to be checked. Callers should
- * have already called {@link #getDirtyState} and received a return value of
- * {@link DirtyState#CHECK_DEPENDENCIES} before calling this method -- any other
- * return value from {@link #getDirtyState} means that this method must not be called, since
- * whether or not the node needs to be rebuilt is already known.
+ * re-evaluated, this method returns the next group of children to be checked. Callers should have
+ * already called {@link #getDirtyState} and received a return value of {@link
+ * DirtyState#CHECK_DEPENDENCIES} before calling this method -- any other return value from {@link
+ * #getDirtyState} means that this method must not be called, since whether or not the node needs
+ * to be rebuilt is already known.
*
- * <p>Deps are returned in groups. The deps in each group were requested in parallel by the
- * {@code SkyFunction} last build, meaning independently of the values of any other deps in this
- * group (although possibly depending on deps in earlier groups). Thus the caller may check all
- * the deps in this group in parallel, since the deps in all previous groups are verified
- * unchanged. See {@link SkyFunction.Environment#getValues} for more on dependency groups.
+ * <p>Deps are returned in groups. The deps in each group were requested in parallel by the {@code
+ * SkyFunction} last build, meaning independently of the values of any other deps in this group
+ * (although possibly depending on deps in earlier groups). Thus the caller may check all the deps
+ * in this group in parallel, since the deps in all previous groups are verified unchanged. See
+ * {@link SkyFunction.Environment#getValues} for more on dependency groups.
*
* <p>The caller should register these as deps of this entry using {@link #addTemporaryDirectDeps}
* before checking them.
*
- * @see BuildingState#getNextDirtyDirectDeps()
+ * @see DirtyBuildingState#getNextDirtyDirectDeps()
*/
@ThreadSafe
Collection<SkyKey> getNextDirtyDirectDeps();
diff --git a/src/main/java/com/google/devtools/build/skyframe/ProcessableGraph.java b/src/main/java/com/google/devtools/build/skyframe/ProcessableGraph.java
index bc391a852f..532a151ef8 100644
--- a/src/main/java/com/google/devtools/build/skyframe/ProcessableGraph.java
+++ b/src/main/java/com/google/devtools/build/skyframe/ProcessableGraph.java
@@ -19,9 +19,8 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
* A graph that is both Dirtiable (values can be deleted) and Evaluable (values can be added). All
* methods in this interface (as inherited from super-interfaces) should be thread-safe.
*
- * <p>This class is not intended for direct use, and is only exposed as public for use in
- * evaluation implementations outside of this package.
+ * <p>This class is not intended for direct use, and is only exposed as public for use in evaluation
+ * implementations outside of this package.
*/
@ThreadSafe
-public interface ProcessableGraph extends DirtiableGraph, EvaluableGraph {
-}
+public interface ProcessableGraph extends DeletableGraph, EvaluableGraph {}
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 ee096996ac..04198286d8 100644
--- a/src/main/java/com/google/devtools/build/skyframe/QueryableGraph.java
+++ b/src/main/java/com/google/devtools/build/skyframe/QueryableGraph.java
@@ -19,16 +19,11 @@ import java.util.Map;
import javax.annotation.Nullable;
-/**
- * A graph that exposes its entries and structure, for use by classes that must traverse it.
- */
+/** A graph that exposes its entries and structure, for use by classes that must traverse it. */
@ThreadSafe
-public interface QueryableGraph extends ThinNodeQueryableGraph {
- /**
- * Returns the node with the given name, or {@code null} if the node does not exist.
- */
+public interface QueryableGraph {
+ /** Returns the node with the given name, or {@code null} if the node does not exist. */
@Nullable
- @Override
NodeEntry get(SkyKey key);
/**
@@ -36,6 +31,5 @@ public interface QueryableGraph extends ThinNodeQueryableGraph {
* {@code keys}, {@code m.get(k).equals(e)} iff {@code get(k) == e} and {@code e != null}, and
* {@code !m.containsKey(k)} iff {@code get(k) == null}.
*/
- @Override
Map<SkyKey, NodeEntry> getBatch(Iterable<SkyKey> keys);
}
diff --git a/src/main/java/com/google/devtools/build/skyframe/ThinNodeEntry.java b/src/main/java/com/google/devtools/build/skyframe/ThinNodeEntry.java
index 1a5c075073..f81355c271 100644
--- a/src/main/java/com/google/devtools/build/skyframe/ThinNodeEntry.java
+++ b/src/main/java/com/google/devtools/build/skyframe/ThinNodeEntry.java
@@ -32,40 +32,6 @@ public interface ThinNodeEntry {
boolean isDone();
/**
- * Returns an immutable iterable of the direct deps of this node. This method may only be called
- * after the evaluation of this node is complete.
- *
- * <p>This method is not very efficient, but is only be called in limited circumstances --
- * when the node is about to be deleted, or when the node is expected to have no direct deps (in
- * which case the overhead is not so bad). It should not be called repeatedly for the same node,
- * since each call takes time proportional to the number of direct deps of the node.
- */
- @ThreadSafe
- Iterable<SkyKey> getDirectDeps();
-
- /**
- * Removes a reverse dependency.
- */
- @ThreadSafe
- void removeReverseDep(SkyKey reverseDep);
-
- /**
- * Removes a reverse dependency.
- *
- * <p>May only be called if this entry is not done (i.e. {@link #isDone} is false) and
- * {@param reverseDep} is present in {@link #getReverseDeps}
- */
- @ThreadSafe
- void removeInProgressReverseDep(SkyKey reverseDep);
-
- /**
- * Returns a copy of the set of reverse dependencies. Note that this introduces a potential
- * check-then-act race; {@link #removeReverseDep} may fail for a key that is returned here.
- */
- @ThreadSafe
- Iterable<SkyKey> getReverseDeps();
-
- /**
* Returns true if the entry is marked dirty, meaning that at least one of its transitive
* dependencies is marked changed.
*/
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
index 75a5f67c01..f48c02cee5 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
@@ -53,9 +53,9 @@ import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
-import com.google.devtools.build.skyframe.NotifyingGraph.EventType;
-import com.google.devtools.build.skyframe.NotifyingGraph.Listener;
-import com.google.devtools.build.skyframe.NotifyingGraph.Order;
+import com.google.devtools.build.skyframe.NotifyingHelper.EventType;
+import com.google.devtools.build.skyframe.NotifyingHelper.Listener;
+import com.google.devtools.build.skyframe.NotifyingHelper.Order;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.TrackingAwaiter;
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java
index be2f42344f..d8acbcffc9 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java
@@ -38,9 +38,9 @@ import com.google.devtools.build.lib.skyframe.PrecomputedValue.Injected;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
-import com.google.devtools.build.skyframe.DeterministicGraph;
+import com.google.devtools.build.skyframe.DeterministicHelper;
import com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator;
-import com.google.devtools.build.skyframe.NotifyingGraph.Listener;
+import com.google.devtools.build.skyframe.NotifyingHelper.Listener;
import java.util.ArrayList;
import java.util.List;
@@ -131,7 +131,7 @@ public abstract class BuildViewTestBase extends AnalysisTestCase {
InMemoryMemoizingEvaluator memoizingEvaluator =
(InMemoryMemoizingEvaluator) skyframeExecutor.getEvaluatorForTesting();
memoizingEvaluator.injectGraphTransformerForTesting(
- DeterministicGraph.makeTransformer(listener, deterministic));
+ DeterministicHelper.makeTransformer(listener, deterministic));
}
protected void runTestForMultiCpuAnalysisFailure(String badCpu, String goodCpu) throws Exception {
diff --git a/src/test/java/com/google/devtools/build/skyframe/BUILD b/src/test/java/com/google/devtools/build/skyframe/BUILD
index 21b63420ea..4286728837 100644
--- a/src/test/java/com/google/devtools/build/skyframe/BUILD
+++ b/src/test/java/com/google/devtools/build/skyframe/BUILD
@@ -12,7 +12,7 @@ TESTUTIL_FILES = [
"TrackingInvalidationReceiver.java",
"WalkableGraphUtils.java",
# Truth Subject, SubjectFactory, and Graph files.
-] + glob(["*Subject.java"]) + glob(["*SubjectFactory.java"]) + glob(["*Graph.java"])
+] + glob(["*Subject.java"]) + glob(["*SubjectFactory.java"]) + glob(["*Graph.java"]) + glob(["*Helper.java"])
java_library(
name = "testutil",
diff --git a/src/test/java/com/google/devtools/build/skyframe/DeterministicGraph.java b/src/test/java/com/google/devtools/build/skyframe/DeterministicHelper.java
index 85df5c59d5..655333af08 100644
--- a/src/test/java/com/google/devtools/build/skyframe/DeterministicGraph.java
+++ b/src/test/java/com/google/devtools/build/skyframe/DeterministicHelper.java
@@ -13,7 +13,6 @@
// limitations under the License.
package com.google.devtools.build.skyframe;
-import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import java.util.Collection;
@@ -26,38 +25,34 @@ import java.util.TreeSet;
import javax.annotation.Nullable;
/**
- * {@link NotifyingGraph} that returns reverse deps, temporary direct deps, and the results of
+ * {@link NotifyingHelper} that returns reverse deps, temporary direct deps, and the results of
* batch requests ordered alphabetically by sky key string representation.
*/
-public class DeterministicGraph<TGraph extends ThinNodeQueryableGraph>
- extends NotifyingGraph<TGraph> {
- public static final Function<ThinNodeQueryableGraph, ProcessableGraph> MAKE_DETERMINISTIC =
- new Function<ThinNodeQueryableGraph, ProcessableGraph>() {
- @Override
- public ProcessableGraph apply(ThinNodeQueryableGraph queryableGraph) {
- if (queryableGraph instanceof InMemoryGraph) {
- return new DeterministicInMemoryGraph((InMemoryGraph) queryableGraph);
- } else {
- return new DeterministicGraph<>(queryableGraph);
- }
- }
- };
+public class DeterministicHelper extends NotifyingHelper {
+ static final MemoizingEvaluator.GraphTransformerForTesting MAKE_DETERMINISTIC =
+ makeTransformer(Listener.NULL_LISTENER, /*deterministic=*/ true);
- public static Function<ThinNodeQueryableGraph, ProcessableGraph> makeTransformer(
+ public static MemoizingEvaluator.GraphTransformerForTesting makeTransformer(
final Listener listener, boolean deterministic) {
if (deterministic) {
- return new Function<ThinNodeQueryableGraph, ProcessableGraph>() {
+ return new MemoizingEvaluator.GraphTransformerForTesting() {
+ @Override
+ public InMemoryGraph transform(InMemoryGraph graph) {
+ return new DeterministicInMemoryGraph(graph, listener);
+ }
+
+ @Override
+ public InvalidatableGraph transform(InvalidatableGraph graph) {
+ return new DeterministicInvalidatableGraph(graph, listener);
+ }
+
@Override
- public ProcessableGraph apply(ThinNodeQueryableGraph queryableGraph) {
- if (queryableGraph instanceof InMemoryGraph) {
- return new DeterministicInMemoryGraph((InMemoryGraph) queryableGraph, listener);
- } else {
- return new DeterministicGraph<>(queryableGraph, listener);
- }
+ public ProcessableGraph transform(ProcessableGraph graph) {
+ return new DeterministicProcessableGraph(graph, listener);
}
};
} else {
- return NotifyingGraph.makeNotifyingTransformer(listener);
+ return NotifyingHelper.makeNotifyingTransformer(listener);
}
}
@@ -69,12 +64,12 @@ public class DeterministicGraph<TGraph extends ThinNodeQueryableGraph>
}
};
- DeterministicGraph(TGraph delegate, Listener listener) {
- super(delegate, listener);
+ DeterministicHelper(Listener listener) {
+ super(listener);
}
- DeterministicGraph(TGraph delegate) {
- super(delegate, NotifyingGraph.Listener.NULL_LISTENER);
+ DeterministicHelper() {
+ super(NotifyingHelper.Listener.NULL_LISTENER);
}
@Nullable
@@ -89,14 +84,40 @@ public class DeterministicGraph<TGraph extends ThinNodeQueryableGraph>
return result;
}
- @Override
- public Map<SkyKey, NodeEntry> getBatch(Iterable<SkyKey> keys) {
- return makeDeterministic(super.getBatch(keys));
+ private static class DeterministicInvalidatableGraph extends NotifyingInvalidatableGraph {
+ DeterministicInvalidatableGraph(InvalidatableGraph delegate, Listener graphListener) {
+ super(delegate, new DeterministicHelper(graphListener));
+ }
+
+ @Override
+ public Map<SkyKey, NodeEntry> getBatch(Iterable<SkyKey> keys) {
+ return makeDeterministic(super.getBatch(keys));
+ }
}
- @Override
- public Map<SkyKey, NodeEntry> createIfAbsentBatch(Iterable<SkyKey> keys) {
- return makeDeterministic(super.createIfAbsentBatch(keys));
+ static class DeterministicProcessableGraph extends NotifyingProcessableGraph {
+ DeterministicProcessableGraph(ProcessableGraph delegate, Listener graphListener) {
+ super(delegate, new DeterministicHelper(graphListener));
+ }
+
+ DeterministicProcessableGraph(ProcessableGraph delegate) {
+ this(delegate, Listener.NULL_LISTENER);
+ }
+
+ @Override
+ public void remove(SkyKey key) {
+ delegate.remove(key);
+ }
+
+ @Override
+ public Map<SkyKey, NodeEntry> createIfAbsentBatch(Iterable<SkyKey> keys) {
+ return makeDeterministic(super.createIfAbsentBatch(keys));
+ }
+
+ @Override
+ public Map<SkyKey, NodeEntry> getBatch(Iterable<SkyKey> keys) {
+ return makeDeterministic(super.getBatch(keys));
+ }
}
/**
diff --git a/src/test/java/com/google/devtools/build/skyframe/DeterministicInMemoryGraph.java b/src/test/java/com/google/devtools/build/skyframe/DeterministicInMemoryGraph.java
index 9e16284d14..a0233838ec 100644
--- a/src/test/java/com/google/devtools/build/skyframe/DeterministicInMemoryGraph.java
+++ b/src/test/java/com/google/devtools/build/skyframe/DeterministicInMemoryGraph.java
@@ -16,32 +16,28 @@ package com.google.devtools.build.skyframe;
import java.util.Map;
/**
- * {@link DeterministicGraph} that implements the {@link InMemoryGraph} interface. Sadly, cannot be
- * a {@link NotifyingInMemoryGraph} due to Java's forbidding multiple inheritance.
+ * {@link DeterministicHelper.DeterministicProcessableGraph} that implements the {@link
+ * InMemoryGraph} interface. Sadly, cannot be a {@link NotifyingInMemoryGraph} due to Java's
+ * forbidding multiple inheritance.
*/
-class DeterministicInMemoryGraph extends DeterministicGraph<InMemoryGraph>
+class DeterministicInMemoryGraph extends DeterministicHelper.DeterministicProcessableGraph
implements InMemoryGraph {
-
- DeterministicInMemoryGraph(InMemoryGraph delegate, Listener graphListener) {
+ DeterministicInMemoryGraph(InMemoryGraph delegate, NotifyingHelper.Listener graphListener) {
super(delegate, graphListener);
}
- DeterministicInMemoryGraph(InMemoryGraph delegate) {
- super(delegate);
- }
-
@Override
public Map<SkyKey, SkyValue> getValues() {
- return delegate.getValues();
+ return ((InMemoryGraph) delegate).getValues();
}
@Override
public Map<SkyKey, SkyValue> getDoneValues() {
- return delegate.getDoneValues();
+ return ((InMemoryGraph) delegate).getDoneValues();
}
@Override
public Map<SkyKey, NodeEntry> getAllValues() {
- return delegate.getAllValues();
+ return ((InMemoryGraph) delegate).getAllValues();
}
}
diff --git a/src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java b/src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java
index 19769888fb..dbc418f79f 100644
--- a/src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java
+++ b/src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java
@@ -84,8 +84,11 @@ public class EagerInvalidatorTest {
}
@SuppressWarnings("unused") // Overridden by subclasses.
- void invalidate(DirtiableGraph graph, EvaluationProgressReceiver invalidationReceiver,
- SkyKey... keys) throws InterruptedException { throw new UnsupportedOperationException(); }
+ void invalidate(
+ InMemoryGraph graph, EvaluationProgressReceiver invalidationReceiver, SkyKey... keys)
+ throws InterruptedException {
+ throw new UnsupportedOperationException();
+ }
boolean gcExpected() { throw new UnsupportedOperationException(); }
@@ -595,8 +598,9 @@ public class EagerInvalidatorTest {
@RunWith(JUnit4.class)
public static class DeletingInvalidatorTest extends EagerInvalidatorTest {
@Override
- protected void invalidate(DirtiableGraph graph, EvaluationProgressReceiver invalidationReceiver,
- SkyKey... keys) throws InterruptedException {
+ protected void invalidate(
+ InMemoryGraph graph, EvaluationProgressReceiver invalidationReceiver, SkyKey... keys)
+ throws InterruptedException {
Iterable<SkyKey> diff = ImmutableList.copyOf(keys);
DeletingNodeVisitor deletingNodeVisitor =
EagerInvalidator.createDeletingVisitorIfNeeded(
@@ -665,8 +669,9 @@ public class EagerInvalidatorTest {
@RunWith(JUnit4.class)
public static class DirtyingInvalidatorTest extends EagerInvalidatorTest {
@Override
- protected void invalidate(DirtiableGraph graph, EvaluationProgressReceiver invalidationReceiver,
- SkyKey... keys) throws InterruptedException {
+ protected void invalidate(
+ InMemoryGraph graph, EvaluationProgressReceiver invalidationReceiver, SkyKey... keys)
+ throws InterruptedException {
Iterable<SkyKey> diff = ImmutableList.copyOf(keys);
DirtyingNodeVisitor dirtyingNodeVisitor =
EagerInvalidator.createInvalidatingVisitorIfNeeded(
diff --git a/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java b/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java
index 61c98215ff..ffdad2aa55 100644
--- a/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java
+++ b/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java
@@ -51,9 +51,9 @@ import com.google.devtools.build.skyframe.GraphTester.NotComparableStringValue;
import com.google.devtools.build.skyframe.GraphTester.StringValue;
import com.google.devtools.build.skyframe.GraphTester.TestFunction;
import com.google.devtools.build.skyframe.GraphTester.ValueComputer;
-import com.google.devtools.build.skyframe.NotifyingGraph.EventType;
-import com.google.devtools.build.skyframe.NotifyingGraph.Listener;
-import com.google.devtools.build.skyframe.NotifyingGraph.Order;
+import com.google.devtools.build.skyframe.NotifyingHelper.EventType;
+import com.google.devtools.build.skyframe.NotifyingHelper.Listener;
+import com.google.devtools.build.skyframe.NotifyingHelper.Order;
import com.google.devtools.build.skyframe.SkyFunction.Environment;
import com.google.devtools.build.skyframe.SkyFunctionException.Transience;
@@ -1248,7 +1248,7 @@ public class MemoizingEvaluatorTest {
// Mark dep1 changed, so otherTop will be dirty and request re-evaluation of dep1.
tester.getOrCreate(dep1, /*markAsModified=*/true);
SkyKey topKey = GraphTester.toSkyKey("top");
- // Note that since DeterministicGraph alphabetizes reverse deps, it is important that
+ // Note that since DeterministicHelper alphabetizes reverse deps, it is important that
// "cycle2" comes before "top".
final SkyKey cycle1Key = GraphTester.toSkyKey("cycle1");
final SkyKey cycle2Key = GraphTester.toSkyKey("cycle2");
@@ -4013,11 +4013,11 @@ public class MemoizingEvaluatorTest {
private void injectGraphListenerForTesting(Listener listener, boolean deterministic) {
tester.evaluator.injectGraphTransformerForTesting(
- DeterministicGraph.makeTransformer(listener, deterministic));
+ DeterministicHelper.makeTransformer(listener, deterministic));
}
private void makeGraphDeterministic() {
- tester.evaluator.injectGraphTransformerForTesting(DeterministicGraph.MAKE_DETERMINISTIC);
+ tester.evaluator.injectGraphTransformerForTesting(DeterministicHelper.MAKE_DETERMINISTIC);
}
private static final class PassThroughSelected implements ValueComputer {
diff --git a/src/test/java/com/google/devtools/build/skyframe/NotifyingGraph.java b/src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java
index 22dbc35e4a..2f973b5bcd 100644
--- a/src/test/java/com/google/devtools/build/skyframe/NotifyingGraph.java
+++ b/src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java
@@ -13,7 +13,6 @@
// limitations under the License.
package com.google.devtools.build.skyframe;
-import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Maps;
@@ -28,36 +27,34 @@ import javax.annotation.Nullable;
/**
* Class that allows clients to be notified on each access of the graph. Clients can simply track
- * accesses, or they can block to achieve desired synchronization. Clients should call
- * {@link TrackingAwaiter#INSTANCE#assertNoErrors} at the end of tests in case exceptions were
- * swallowed in async threads.
- *
- * <p>While this class nominally always implements a {@link ProcessableGraph}, it will throw if any
- * of the methods in {@link ProcessableGraph} that are not in {@link ThinNodeQueryableGraph} are
- * called on it and its {@link #delegate} is not a {@link ProcessableGraph}. This lack of type
- * safety is so that a {@code NotifyingGraph} can be returned by {@link #makeNotifyingTransformer}
- * and used in {@link MemoizingEvaluator#injectGraphTransformerForTesting}.
+ * accesses, or they can block to achieve desired synchronization. Clients should call {@link
+ * TrackingAwaiter#INSTANCE#assertNoErrors} at the end of tests in case exceptions were swallowed in
+ * async threads.
*/
-public class NotifyingGraph<TGraph extends ThinNodeQueryableGraph> implements ProcessableGraph {
- public static Function<ThinNodeQueryableGraph, ProcessableGraph> makeNotifyingTransformer(
+public class NotifyingHelper {
+ public static MemoizingEvaluator.GraphTransformerForTesting makeNotifyingTransformer(
final Listener listener) {
- return new Function<ThinNodeQueryableGraph, ProcessableGraph>() {
- @Nullable
+ return new MemoizingEvaluator.GraphTransformerForTesting() {
@Override
- public ProcessableGraph apply(ThinNodeQueryableGraph queryableGraph) {
- if (queryableGraph instanceof InMemoryGraph) {
- return new NotifyingInMemoryGraph((InMemoryGraph) queryableGraph, listener);
- } else {
- return new NotifyingGraph<>(queryableGraph, listener);
- }
+ public InMemoryGraph transform(InMemoryGraph graph) {
+ return new NotifyingInMemoryGraph(graph, listener);
+ }
+
+ @Override
+ public InvalidatableGraph transform(InvalidatableGraph graph) {
+ return new NotifyingInvalidatableGraph(graph, listener);
+ }
+
+ @Override
+ public ProcessableGraph transform(ProcessableGraph graph) {
+ return new NotifyingProcessableGraph(graph, listener);
}
};
}
- protected final TGraph delegate;
- private final Listener graphListener;
+ protected final Listener graphListener;
- private final EntryTransformer<SkyKey, ThinNodeEntry, NodeEntry> wrapEntry =
+ protected final EntryTransformer<SkyKey, ThinNodeEntry, NodeEntry> wrapEntry =
new EntryTransformer<SkyKey, ThinNodeEntry, NodeEntry>() {
@Nullable
@Override
@@ -66,47 +63,73 @@ public class NotifyingGraph<TGraph extends ThinNodeQueryableGraph> implements Pr
}
};
- NotifyingGraph(TGraph delegate, Listener graphListener) {
- this.delegate = delegate;
+ NotifyingHelper(Listener graphListener) {
this.graphListener = new ErrorRecordingDelegatingListener(graphListener);
}
- private ProcessableGraph getProcessableDelegate() {
- return (ProcessableGraph) delegate;
+ /** Subclasses should override if they wish to subclass NotifyingNodeEntry. */
+ @Nullable
+ protected NotifyingNodeEntry wrapEntry(SkyKey key, @Nullable ThinNodeEntry entry) {
+ return entry == null ? null : new NotifyingNodeEntry(key, entry);
}
- @Override
- public void remove(SkyKey key) {
- getProcessableDelegate().remove(key);
- }
+ static class NotifyingInvalidatableGraph implements InvalidatableGraph {
+ private final InvalidatableGraph delegate;
+ private final NotifyingHelper notifyingHelper;
- @Override
- public Map<SkyKey, NodeEntry> createIfAbsentBatch(Iterable<SkyKey> keys) {
- for (SkyKey key : keys) {
- graphListener.accept(key, EventType.CREATE_IF_ABSENT, Order.BEFORE, null);
+ NotifyingInvalidatableGraph(InvalidatableGraph delegate, Listener graphListener) {
+ this.notifyingHelper = new NotifyingHelper(graphListener);
+ this.delegate = delegate;
}
- return Maps.transformEntries(getProcessableDelegate().createIfAbsentBatch(keys), wrapEntry);
- }
- @Override
- public Map<SkyKey, NodeEntry> getBatch(Iterable<SkyKey> keys) {
- if (delegate instanceof ProcessableGraph) {
- return Maps.transformEntries(getProcessableDelegate().getBatch(keys), wrapEntry);
- } else {
- return Maps.transformEntries(delegate.getBatch(keys), wrapEntry);
+ NotifyingInvalidatableGraph(InvalidatableGraph delegate, NotifyingHelper helper) {
+ this.notifyingHelper = helper;
+ this.delegate = delegate;
}
- }
- @Nullable
- @Override
- public NodeEntry get(SkyKey key) {
- return wrapEntry(key, getProcessableDelegate().get(key));
+ @Override
+ public Map<SkyKey, NodeEntry> getBatch(Iterable<SkyKey> keys) {
+ return Maps.transformEntries(delegate.getBatch(keys), notifyingHelper.wrapEntry);
+ }
}
- /** Subclasses should override if they wish to subclass NotifyingNodeEntry. */
- @Nullable
- protected NotifyingNodeEntry wrapEntry(SkyKey key, @Nullable ThinNodeEntry entry) {
- return entry == null ? null : new NotifyingNodeEntry(key, entry);
+ static class NotifyingProcessableGraph implements ProcessableGraph {
+ protected final ProcessableGraph delegate;
+ protected final NotifyingHelper notifyingHelper;
+
+ NotifyingProcessableGraph(ProcessableGraph delegate, Listener graphListener) {
+ this.notifyingHelper = new NotifyingHelper(graphListener);
+ this.delegate = delegate;
+ }
+
+ NotifyingProcessableGraph(ProcessableGraph delegate, NotifyingHelper helper) {
+ this.notifyingHelper = helper;
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void remove(SkyKey key) {
+ delegate.remove(key);
+ }
+
+ @Override
+ public Map<SkyKey, NodeEntry> createIfAbsentBatch(Iterable<SkyKey> keys) {
+ for (SkyKey key : keys) {
+ notifyingHelper.graphListener.accept(key, EventType.CREATE_IF_ABSENT, Order.BEFORE, null);
+ }
+ return Maps.transformEntries(delegate.createIfAbsentBatch(keys), notifyingHelper.wrapEntry);
+ }
+
+ @Override
+ public Map<SkyKey, NodeEntry> getBatch(Iterable<SkyKey> keys) {
+ return Maps.transformEntries(delegate.getBatch(keys), notifyingHelper.wrapEntry);
+ }
+
+ @Nullable
+ @Override
+ public NodeEntry get(SkyKey key) {
+ return notifyingHelper.wrapEntry(key, delegate.get(key));
+ }
}
/**
diff --git a/src/test/java/com/google/devtools/build/skyframe/NotifyingInMemoryGraph.java b/src/test/java/com/google/devtools/build/skyframe/NotifyingInMemoryGraph.java
index 9b90491b74..752dac7001 100644
--- a/src/test/java/com/google/devtools/build/skyframe/NotifyingInMemoryGraph.java
+++ b/src/test/java/com/google/devtools/build/skyframe/NotifyingInMemoryGraph.java
@@ -15,24 +15,25 @@ package com.google.devtools.build.skyframe;
import java.util.Map;
-/** {@link NotifyingGraph} that additionally implements the {@link InMemoryGraph} interface. */
-class NotifyingInMemoryGraph extends NotifyingGraph<InMemoryGraph> implements InMemoryGraph {
- NotifyingInMemoryGraph(InMemoryGraph delegate, Listener graphListener) {
+/** {@link NotifyingHelper} that additionally implements the {@link InMemoryGraph} interface. */
+class NotifyingInMemoryGraph extends NotifyingHelper.NotifyingProcessableGraph
+ implements InMemoryGraph {
+ NotifyingInMemoryGraph(InMemoryGraph delegate, NotifyingHelper.Listener graphListener) {
super(delegate, graphListener);
}
@Override
public Map<SkyKey, SkyValue> getValues() {
- return delegate.getValues();
+ return ((InMemoryGraph) delegate).getValues();
}
@Override
public Map<SkyKey, SkyValue> getDoneValues() {
- return delegate.getDoneValues();
+ return ((InMemoryGraph) delegate).getDoneValues();
}
@Override
public Map<SkyKey, NodeEntry> getAllValues() {
- return delegate.getAllValues();
+ return ((InMemoryGraph) delegate).getAllValues();
}
}
diff --git a/src/test/java/com/google/devtools/build/skyframe/ParallelEvaluatorTest.java b/src/test/java/com/google/devtools/build/skyframe/ParallelEvaluatorTest.java
index 0b3d8fc22a..56dcfb51f8 100644
--- a/src/test/java/com/google/devtools/build/skyframe/ParallelEvaluatorTest.java
+++ b/src/test/java/com/google/devtools/build/skyframe/ParallelEvaluatorTest.java
@@ -43,9 +43,9 @@ import com.google.devtools.build.lib.events.EventKind;
import com.google.devtools.build.lib.testutil.TestThread;
import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.skyframe.GraphTester.StringValue;
-import com.google.devtools.build.skyframe.NotifyingGraph.EventType;
-import com.google.devtools.build.skyframe.NotifyingGraph.Listener;
-import com.google.devtools.build.skyframe.NotifyingGraph.Order;
+import com.google.devtools.build.skyframe.NotifyingHelper.EventType;
+import com.google.devtools.build.skyframe.NotifyingHelper.Listener;
+import com.google.devtools.build.skyframe.NotifyingHelper.Order;
import com.google.devtools.build.skyframe.ParallelEvaluator.EventFilter;
import com.google.devtools.build.skyframe.SkyFunctionException.Transience;
@@ -1276,7 +1276,7 @@ public class ParallelEvaluatorTest {
* we should detect cycle.
*/
private void cycleAndErrorInBubbleUp(boolean keepGoing) throws Exception {
- graph = new DeterministicGraph<>(new InMemoryGraphImpl());
+ graph = new DeterministicHelper.DeterministicProcessableGraph(new InMemoryGraphImpl());
tester = new GraphTester();
SkyKey errorKey = GraphTester.toSkyKey("error");
SkyKey cycleKey = GraphTester.toSkyKey("cycle");
@@ -1323,7 +1323,7 @@ public class ParallelEvaluatorTest {
*/
@Test
public void cycleAndErrorAndOtherInBubbleUp() throws Exception {
- graph = new DeterministicGraph<>(new InMemoryGraphImpl());
+ graph = new DeterministicHelper.DeterministicProcessableGraph(new InMemoryGraphImpl());
tester = new GraphTester();
SkyKey errorKey = GraphTester.toSkyKey("error");
SkyKey cycleKey = GraphTester.toSkyKey("cycle");
@@ -1366,7 +1366,7 @@ public class ParallelEvaluatorTest {
* Here, we add an additional top-level key in error, just to mix it up.
*/
private void cycleAndErrorAndError(boolean keepGoing) throws Exception {
- graph = new DeterministicGraph<>(new InMemoryGraphImpl());
+ graph = new DeterministicHelper.DeterministicProcessableGraph(new InMemoryGraphImpl());
tester = new GraphTester();
SkyKey errorKey = GraphTester.toSkyKey("error");
SkyKey cycleKey = GraphTester.toSkyKey("cycle");
@@ -1999,7 +1999,7 @@ public class ParallelEvaluatorTest {
}
});
graph =
- new NotifyingGraph<>(
+ new NotifyingHelper.NotifyingProcessableGraph(
new InMemoryGraphImpl(),
new Listener() {
@Override
@@ -2032,7 +2032,7 @@ public class ParallelEvaluatorTest {
@Test
public void cachedErrorsFromKeepGoingUsedOnNoKeepGoing() throws Exception {
- graph = new DeterministicGraph<>(new InMemoryGraphImpl());
+ graph = new DeterministicHelper.DeterministicProcessableGraph(new InMemoryGraphImpl());
tester = new GraphTester();
SkyKey errorKey = GraphTester.toSkyKey("error");
SkyKey parent1Key = GraphTester.toSkyKey("parent1");
@@ -2052,7 +2052,7 @@ public class ParallelEvaluatorTest {
@Test
public void cachedTopLevelErrorsShouldHaltNoKeepGoingBuildEarly() throws Exception {
- graph = new DeterministicGraph<>(new InMemoryGraphImpl());
+ graph = new DeterministicHelper.DeterministicProcessableGraph(new InMemoryGraphImpl());
tester = new GraphTester();
SkyKey errorKey = GraphTester.toSkyKey("error");
tester.getOrCreate(errorKey).setHasError(true);
@@ -2082,7 +2082,7 @@ public class ParallelEvaluatorTest {
private void runUnhandledTransitiveErrors(boolean keepGoing,
final boolean explicitlyPropagateError) throws Exception {
- graph = new DeterministicGraph<>(new InMemoryGraphImpl());
+ graph = new DeterministicHelper.DeterministicProcessableGraph(new InMemoryGraphImpl());
tester = new GraphTester();
SkyKey grandparentKey = GraphTester.toSkyKey("grandparent");
final SkyKey parentKey = GraphTester.toSkyKey("parent");