Skip to content

Commit

Permalink
Simplify the BatchStat interface.
Browse files Browse the repository at this point in the history
The includeDigest and includeLinks parameters are always set to true in existing usages.

PiperOrigin-RevId: 567546858
Change-Id: I88698362d08d211b0828a10da76d0e837ef09936
  • Loading branch information
tjgq authored and copybara-github committed Sep 22, 2023
1 parent 04a0567 commit 01a7c72
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,7 @@ && shouldCheckFile(knownModifiedOutputFiles, artifact)) {
List<Artifact> artifacts = ImmutableList.copyOf(fileToKeyAndValue.keySet());
List<FileStatusWithDigest> stats;
try {
stats =
batchStatter.batchStat(
/* includeDigest= */ true,
/* includeLinks= */ true,
Artifact.asPathFragments(artifacts));
stats = batchStatter.batchStat(Artifact.asPathFragments(artifacts));
} catch (IOException e) {
logger.atWarning().withCause(e).log(
"Unable to process batch stat, falling back to individual stats");
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/com/google/devtools/build/lib/vfs/BatchStat.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@
public interface BatchStat {

/**
* @param includeDigest whether to include a file digest in the return values.
* @param includeLinks whether to include a symlink stat in the return values.
* @param paths The input paths to stat(), relative to the exec root.
* @return an array list of FileStatusWithDigest in the same order as the input. May
* contain null values.
* @throws IOException on unexpected failure.
* Calls stat() on a set of paths.
*
* @param paths The input paths to stat(), relative to the exec root. Symlinks are not followed.
* @return A list of {@link FileStatusWithDigest} in the same order as the input. If a path does
* not exist, {@code null} is returned in the corresponding position.
* @throws IOException on I/O errors.
* @throws InterruptedException on interrupt.
*/
public List<FileStatusWithDigest> batchStat(boolean includeDigest,
boolean includeLinks,
Iterable<PathFragment> paths)
public List<FileStatusWithDigest> batchStat(Iterable<PathFragment> paths)
throws IOException, InterruptedException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ BatchStat getBatchStat(FileSystem fileSystem) {
ENABLED {
@Override
BatchStat getBatchStat(FileSystem fileSystem) {
return (useDigest, includeLinks, paths) -> {
return (paths) -> {
List<FileStatusWithDigest> stats = new ArrayList<>();
for (PathFragment pathFrag : paths) {
stats.add(
Expand Down Expand Up @@ -1228,8 +1228,7 @@ public void testDirtyActionsBatchStat() throws Exception {
checkDirtyActions(
new BatchStat() {
@Override
public List<FileStatusWithDigest> batchStat(
boolean useDigest, boolean includeLinks, Iterable<PathFragment> paths)
public List<FileStatusWithDigest> batchStat(Iterable<PathFragment> paths)
throws IOException {
List<FileStatusWithDigest> stats = new ArrayList<>();
for (PathFragment pathFrag : paths) {
Expand All @@ -1249,8 +1248,7 @@ public void testDirtyActionsBatchStatWithDigest() throws Exception {
checkDirtyActions(
new BatchStat() {
@Override
public List<FileStatusWithDigest> batchStat(
boolean useDigest, boolean includeLinks, Iterable<PathFragment> paths)
public List<FileStatusWithDigest> batchStat(Iterable<PathFragment> paths)
throws IOException {
List<FileStatusWithDigest> stats = new ArrayList<>();
for (PathFragment pathFrag : paths) {
Expand All @@ -1269,8 +1267,7 @@ public void testDirtyActionsBatchStatFallback() throws Exception {
checkDirtyActions(
new BatchStat() {
@Override
public List<FileStatusWithDigest> batchStat(
boolean useDigest, boolean includeLinks, Iterable<PathFragment> paths)
public List<FileStatusWithDigest> batchStat(Iterable<PathFragment> paths)
throws IOException {
throw new IOException("try again");
}
Expand Down

0 comments on commit 01a7c72

Please sign in to comment.