diff options
4 files changed, 56 insertions, 20 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunction.java index 064ab4ba65..e7a1b38972 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunction.java @@ -71,7 +71,7 @@ public final class FilesetEntryFunction implements SkyFunction { // The absence of "direct" traversal indicates the presence of a "nested" fileset and // getNestedTraversal will return the list FilesetTraversalParams corresponding to each // FilesetEntry of the nested Fileset. - ImmutableList<SkyKey> nestedKeys = FilesetEntryValue.keys(t.getNestedTraversal()); + ImmutableList<SkyKey> nestedKeys = FilesetEntryKey.keys(t.getNestedTraversal()); Map<SkyKey, SkyValue> results = env.getValues(nestedKeys); if (env.valuesMissing()) { return null; diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FilesetEntryKey.java b/src/main/java/com/google/devtools/build/lib/skyframe/FilesetEntryKey.java new file mode 100644 index 0000000000..47f8cbc8a5 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skyframe/FilesetEntryKey.java @@ -0,0 +1,51 @@ +// Copyright 2017 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.skyframe; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Interner; +import com.google.devtools.build.lib.actions.FilesetTraversalParams; +import com.google.devtools.build.lib.concurrent.BlazeInterners; +import com.google.devtools.build.skyframe.SkyFunctionName; +import com.google.devtools.build.skyframe.SkyKey; +import java.util.stream.StreamSupport; + +/** A {@link SkyKey} for the {@link FilesetEntryFunction} */ +@AutoValue +public abstract class FilesetEntryKey implements SkyKey { + private static final Interner<FilesetEntryKey> INTERNER = BlazeInterners.newWeakInterner(); + + abstract FilesetTraversalParams params(); + + @Override + public Object argument() { + return params(); + } + + @Override + public SkyFunctionName functionName() { + return SkyFunctions.FILESET_ENTRY; + } + + public static FilesetEntryKey key(FilesetTraversalParams param) { + return INTERNER.intern(new AutoValue_FilesetEntryKey(param)); + } + + public static ImmutableList<SkyKey> keys(Iterable<FilesetTraversalParams> params) { + return StreamSupport.stream(params.spliterator(), /*parallel=*/ false) + .map(FilesetEntryKey::key) + .collect(ImmutableList.toImmutableList()); + } +} diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FilesetEntryValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/FilesetEntryValue.java index 3ed1ecec0f..d9104ee57c 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/FilesetEntryValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/FilesetEntryValue.java @@ -13,14 +13,9 @@ // limitations under the License. package com.google.devtools.build.lib.skyframe; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.actions.FilesetOutputSymlink; -import com.google.devtools.build.lib.actions.FilesetTraversalParams; -import com.google.devtools.build.skyframe.LegacySkyKey; -import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; -import java.util.stream.StreamSupport; /** Output symlinks produced by a whole FilesetEntry or by a single file in FilesetEntry.files. */ public final class FilesetEntryValue implements SkyValue { @@ -46,16 +41,6 @@ public final class FilesetEntryValue implements SkyValue { return symlinks; } - public static SkyKey key(FilesetTraversalParams params) { - return LegacySkyKey.create(SkyFunctions.FILESET_ENTRY, params); - } - - public static ImmutableList<SkyKey> keys(Iterable<FilesetTraversalParams> paramsIterable) { - return StreamSupport.stream(paramsIterable.spliterator(), /*parallel=*/ false) - .map(FilesetEntryValue::key) - .collect(ImmutableList.toImmutableList()); - } - @Override public boolean equals(Object obj) { if (this == obj) { diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java index 662ca86435..66c4d16eaf 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java @@ -174,7 +174,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase { } private FilesetEntryValue evalFilesetTraversal(FilesetTraversalParams params) throws Exception { - SkyKey key = FilesetEntryValue.key(params); + SkyKey key = FilesetEntryKey.key(params); EvaluationResult<FilesetEntryValue> result = eval(key); assertThat(result.hasError()).isFalse(); return result.get(key); @@ -348,7 +348,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase { assertSymlinksCreatedInOrder(params, outA, outAsym); break; case REPORT_ERROR: - SkyKey key = FilesetEntryValue.key(params); + SkyKey key = FilesetEntryKey.key(params); EvaluationResult<SkyValue> result = eval(key); assertThat(result.hasError()).isTrue(); assertThat(result.getError(key).getException()) @@ -435,7 +435,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase { assertSymlinksCreatedInOrder(params, outA, outASym); break; case REPORT_ERROR: - SkyKey key = FilesetEntryValue.key(params); + SkyKey key = FilesetEntryKey.key(params); EvaluationResult<SkyValue> result = eval(key); assertThat(result.hasError()).isTrue(); assertThat(result.getError(key).getException()) @@ -528,7 +528,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase { assertSymlinksCreatedInOrder(params, outBuild, outA, outAsym); break; case REPORT_ERROR: - SkyKey key = FilesetEntryValue.key(params); + SkyKey key = FilesetEntryKey.key(params); EvaluationResult<SkyValue> result = eval(key); assertThat(result.hasError()).isTrue(); assertThat(result.getError(key).getException()) |