From 110a296f00ee71dec863983f96cb0c916e8cb156 Mon Sep 17 00:00:00 2001 From: Michael Gibney Date: Wed, 13 Sep 2023 14:20:10 -0400 Subject: [PATCH] add hook for Directory impls to directly supply their size (#141) --- .../src/java/org/apache/solr/core/DirectoryFactory.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java index 34bed4dc50e..b860d4608c3 100644 --- a/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java +++ b/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java @@ -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;