Skip to content

Commit

Permalink
add hook for Directory impls to directly supply their size (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
magibney authored Sep 13, 2023
1 parent c238c08 commit 110a296
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,14 @@ public boolean isAbsolute(String path) {
return Path.of(path).isAbsolute();
}

public interface SizeAware {
long size() throws IOException;
}

public static long sizeOfDirectory(Directory directory) throws IOException {
if (directory instanceof SizeAware) {
return ((SizeAware) directory).size();
}
final String[] files = directory.listAll();
long size = 0;

Expand Down

0 comments on commit 110a296

Please sign in to comment.