aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-05-22 20:08:41 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-22 20:09:58 -0700
commit4089f8b965bfaabb49764f20d66fc67969e4ec37 (patch)
tree64035f6a0a750aeb5fb6c837d0a76eb6691b14ed /src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java
parent5bd2365d342ad1766e037b7dbe734f4d4e510da6 (diff)
Add events and get rid of ErrorInfoEncoder. Clean up some signatures and visibility in Skyframe classes.
PiperOrigin-RevId: 197665817
Diffstat (limited to 'src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java')
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java b/src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java
index ce92dfd2b2..a0c5108590 100644
--- a/src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java
+++ b/src/main/java/com/google/devtools/build/skyframe/ValueWithMetadata.java
@@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
package com.google.devtools.build.skyframe;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
@@ -34,7 +37,7 @@ public abstract class ValueWithMetadata implements SkyValue {
private static final NestedSet<Postable> NO_POSTS =
NestedSetBuilder.<Postable>emptySet(Order.STABLE_ORDER);
- public ValueWithMetadata(SkyValue value) {
+ private ValueWithMetadata(SkyValue value) {
this.value = value;
}
@@ -47,12 +50,12 @@ public abstract class ValueWithMetadata implements SkyValue {
ErrorInfo errorInfo,
NestedSet<TaggedEvents> transitiveEvents,
NestedSet<Postable> transitivePostables) {
- return new ErrorInfoValue(errorInfo, null, transitiveEvents, transitivePostables);
+ return (ValueWithMetadata) normal(null, errorInfo, transitiveEvents, transitivePostables);
}
/**
- * Builds a value entry value that has a value value, and possibly an error (constructed from its
- * children's errors).
+ * Builds a SkyValue that has a value, and possibly an error, and possibly events/postables. If it
+ * has only a value, returns just the value in order to save memory.
*
* <p>This is public only for use in alternative {@code MemoizingEvaluator} implementations.
*/
@@ -83,8 +86,8 @@ public abstract class ValueWithMetadata implements SkyValue {
public abstract NestedSet<Postable> getTransitivePostables();
/** Implementation of {@link ValueWithMetadata} for the value case. */
+ @VisibleForTesting
public static class ValueWithEvents extends ValueWithMetadata {
-
private final NestedSet<TaggedEvents> transitiveEvents;
private final NestedSet<Postable> transitivePostables;
@@ -97,7 +100,7 @@ public abstract class ValueWithMetadata implements SkyValue {
this.transitivePostables = Preconditions.checkNotNull(transitivePostables);
}
- public static ValueWithEvents createValueWithEvents(
+ private static ValueWithEvents createValueWithEvents(
SkyValue value,
NestedSet<TaggedEvents> transitiveEvents,
NestedSet<Postable> transitivePostables) {
@@ -154,7 +157,13 @@ public abstract class ValueWithMetadata implements SkyValue {
}
@Override
- public String toString() { return value.toString(); }
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("value", value)
+ .add("transitiveEvents size", Iterables.size(transitiveEvents))
+ .add("transitivePostables size", Iterables.size(transitivePostables))
+ .toString();
+ }
}
private static final class NotComparableValueWithEvents extends ValueWithEvents