Skip to content

Commit

Permalink
Deletes default implemetation of MetadataProvider.getInput
Browse files Browse the repository at this point in the history
Small misc cleanups.

PiperOrigin-RevId: 199797948
  • Loading branch information
aoeui authored and Copybara-Service committed Jun 8, 2018
1 parent 2091a2e commit 72660e2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <p>Returned {@link Metadata} instance correspond to the final target of a symlink, and
* therefore must not have a type of {@link FileStateType#SYMLINK} themselves.
* <p>Returned {@link FileArtifactValue} instance corresponds to the final target of a symlink and
* therefore must not have a type of {@link FileStateType#SYMLINK}.
*
* <p>The return value is owned by the cache and must not be modified.
*
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -66,17 +65,13 @@ final class ActionFileSystem extends FileSystem implements MetadataProvider, Inj
private final FileSystem delegate;

private final PathFragment execRootFragment;
private final Path execRootPath;
private final ImmutableList<PathFragment> sourceRoots;

private final ActionInputMap inputArtifactData;

/** exec path → artifact and metadata */
private final HashMap<PathFragment, OptionalInputMetadata> optionalInputs;

/** digest → artifacts in {@link inputs} */
private final ConcurrentHashMap<ByteString, Artifact> optionalInputsByDigest;

/** exec path → artifact and metadata */
private final ImmutableMap<PathFragment, OutputMetadata> outputs;

Expand All @@ -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()
Expand All @@ -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(
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 72660e2

Please sign in to comment.