diff options
author | 2018-03-02 17:48:57 -0800 | |
---|---|---|
committer | 2018-03-02 17:51:19 -0800 | |
commit | 5fb2a487e53cc3d80e3654d5b63d062f7f70588b (patch) | |
tree | 82b23b68d09c451a8950468668150acdf89533e9 /src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionValue.java | |
parent | 46f7106d0b20ae0ba245c3609545600ae379cea4 (diff) |
Replace LegacySkyKey by AbstractSkyKey or custom SkyKeys. AbstractSkyKey doesn't save memory in the 32-bit case, but makes it easier for people to see how many SkyKeys we have.
There's some unnecessary interning in tests, but it was easier to copypasta and doesn't harm anything, I think.
PiperOrigin-RevId: 187694309
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionValue.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionValue.java | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionValue.java index b435720123..20a4dc9e3e 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionValue.java @@ -14,11 +14,13 @@ package com.google.devtools.build.lib.skyframe; import com.google.auto.value.AutoValue; -import com.google.common.base.Function; +import com.google.common.collect.Interner; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.TopLevelArtifactContext; -import com.google.devtools.build.skyframe.LegacySkyKey; +import com.google.devtools.build.lib.concurrent.BlazeInterners; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; +import com.google.devtools.build.skyframe.SkyFunctionName; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; import java.util.Collection; @@ -36,9 +38,7 @@ public class TestCompletionValue implements SkyValue { ConfiguredTargetKey lac, final TopLevelArtifactContext topLevelArtifactContext, final boolean exclusiveTesting) { - return LegacySkyKey.create( - SkyFunctions.TEST_COMPLETION, - TestCompletionKey.create(lac, topLevelArtifactContext, exclusiveTesting)); + return TestCompletionKey.create(lac, topLevelArtifactContext, exclusiveTesting); } public static Iterable<SkyKey> keys(Collection<ConfiguredTarget> targets, @@ -46,31 +46,35 @@ public class TestCompletionValue implements SkyValue { final boolean exclusiveTesting) { return Iterables.transform( targets, - new Function<ConfiguredTarget, SkyKey>() { - @Override - public SkyKey apply(ConfiguredTarget ct) { - return LegacySkyKey.create( - SkyFunctions.TEST_COMPLETION, - TestCompletionKey.create( - ConfiguredTargetKey.of(ct), topLevelArtifactContext, exclusiveTesting)); - } - }); + ct -> + TestCompletionKey.create( + ConfiguredTargetKey.of(ct), topLevelArtifactContext, exclusiveTesting)); } + @AutoCodec @AutoValue - abstract static class TestCompletionKey { + abstract static class TestCompletionKey implements SkyKey { + private static final Interner<TestCompletionKey> interner = BlazeInterners.newWeakInterner(); - public static TestCompletionKey create( + @AutoCodec.VisibleForSerialization + @AutoCodec.Instantiator + static TestCompletionKey create( ConfiguredTargetKey configuredTargetKey, TopLevelArtifactContext topLevelArtifactContext, boolean exclusiveTesting) { - return new AutoValue_TestCompletionValue_TestCompletionKey( - configuredTargetKey, topLevelArtifactContext, exclusiveTesting); + return interner.intern( + new AutoValue_TestCompletionValue_TestCompletionKey( + configuredTargetKey, topLevelArtifactContext, exclusiveTesting)); } abstract ConfiguredTargetKey configuredTargetKey(); public abstract TopLevelArtifactContext topLevelArtifactContext(); public abstract boolean exclusiveTesting(); + + @Override + public SkyFunctionName functionName() { + return SkyFunctions.TEST_COMPLETION; + } } } |