From 72660e2293d873ab3170891d87d7a564c6a3513f Mon Sep 17 00:00:00 2001 From: shahan Date: Fri, 8 Jun 2018 08:39:36 -0700 Subject: [PATCH] Deletes default implemetation of MetadataProvider.getInput Small misc cleanups. PiperOrigin-RevId: 199797948 --- .../devtools/build/lib/actions/MetadataProvider.java | 9 +++------ .../devtools/build/lib/skyframe/ActionFileSystem.java | 11 ----------- .../build/lib/exec/util/FakeActionInputFileCache.java | 5 +++++ .../build/lib/remote/FakeActionInputFileCache.java | 5 +++++ 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java b/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java index 60db714d177b79..43938a732b8614 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java +++ b/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java @@ -28,8 +28,8 @@ public interface MetadataProvider { * then t >= p. Aside from these properties, t can be any value and may vary arbitrarily across * calls. * - *

Returned {@link Metadata} instance correspond to the final target of a symlink, and - * therefore must not have a type of {@link FileStateType#SYMLINK} themselves. + *

Returned {@link FileArtifactValue} instance corresponds to the final target of a symlink and + * therefore must not have a type of {@link FileStateType#SYMLINK}. * *

The return value is owned by the cache and must not be modified. * @@ -44,8 +44,5 @@ public interface MetadataProvider { /** Looks up an input from its exec path. */ @Nullable - default ActionInput getInput(String execPath) { - // TODO(shahan): make sure all instances have an implementation and delete the default here. - return null; - } + ActionInput getInput(String execPath); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java index 03b1896ea83d9c..92f51c4ee7fe0b 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java @@ -44,7 +44,6 @@ import java.io.OutputStream; import java.util.Collection; import java.util.HashMap; -import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; import javax.annotation.Nullable; @@ -66,7 +65,6 @@ final class ActionFileSystem extends FileSystem implements MetadataProvider, Inj private final FileSystem delegate; private final PathFragment execRootFragment; - private final Path execRootPath; private final ImmutableList sourceRoots; private final ActionInputMap inputArtifactData; @@ -74,9 +72,6 @@ final class ActionFileSystem extends FileSystem implements MetadataProvider, Inj /** exec path → artifact and metadata */ private final HashMap optionalInputs; - /** digest → artifacts in {@link inputs} */ - private final ConcurrentHashMap optionalInputsByDigest; - /** exec path → artifact and metadata */ private final ImmutableMap outputs; @@ -103,7 +98,6 @@ final class ActionFileSystem extends FileSystem implements MetadataProvider, Inj this.delegate = delegate; this.execRootFragment = execRoot.asFragment(); - this.execRootPath = getPath(execRootFragment); this.sourceRoots = sourceRoots .stream() @@ -128,8 +122,6 @@ final class ActionFileSystem extends FileSystem implements MetadataProvider, Inj input.getExecPath(), unused -> new OptionalInputMetadata(input)); } - this.optionalInputsByDigest = new ConcurrentHashMap<>(); - this.outputs = Streams.stream(outputArtifacts) .collect( @@ -497,9 +489,6 @@ public FileArtifactValue get() throws IOException { if (metadata == null) { throw new ActionExecutionFunction.MissingDepException(); } - if (metadata.getType().exists() && metadata.getDigest() != null) { - optionalInputsByDigest.put(toByteString(metadata.getDigest()), artifact); - } } } } diff --git a/src/test/java/com/google/devtools/build/lib/exec/util/FakeActionInputFileCache.java b/src/test/java/com/google/devtools/build/lib/exec/util/FakeActionInputFileCache.java index f43d4237d2ea79..12e9d5dcf6729a 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/util/FakeActionInputFileCache.java +++ b/src/test/java/com/google/devtools/build/lib/exec/util/FakeActionInputFileCache.java @@ -35,4 +35,9 @@ public void put(ActionInput artifact, FileArtifactValue metadata) { public FileArtifactValue getMetadata(ActionInput input) throws IOException { return Preconditions.checkNotNull(inputs.get(input)); } + + @Override + public ActionInput getInput(String execPath) { + throw new UnsupportedOperationException(); + } } diff --git a/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java b/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java index ccc0a4139fd2bf..0a67d6265b53f4 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java +++ b/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java @@ -50,6 +50,11 @@ public FileArtifactValue getMetadata(ActionInput input) throws IOException { HashCode.fromString(hexDigest).asBytes(), FileContentsProxy.create(stat), stat.getSize()); } + @Override + public ActionInput getInput(String execPath) { + throw new UnsupportedOperationException(); + } + void setDigest(ActionInput input, String digest) { cas.put(input, digest); }