You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "dsmiley (via GitHub)" <gi...@apache.org> on 2024/04/11 22:57:29 UTC

Re: [PR] SOLR-16866: Reorder nested directory deletions to avoid NoSuchFileException [solr]

dsmiley commented on code in PR #2349:
URL: https://github.com/apache/solr/pull/2349#discussion_r1561834394


##########
solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java:
##########
@@ -302,6 +294,53 @@ private boolean closeCacheValue(CacheValue cacheValue) {
     return cl;
   }
 
+  private static Iterable<CacheValue> sorted(Set<CacheValue> vals) {
+    if (vals.size() < 2) {
+      return vals;
+    }
+    // here we reverse-sort entries by path, in order to trivially ensure that
+    // subpaths are removed before parent paths.
+    CacheValue[] ret = vals.toArray(new CacheValue[0]);
+    Arrays.sort(ret, (a, b) -> b.path.compareTo(a.path));
+    return Arrays.asList(ret);

Review Comment:
   minor: this would be nicer as a single statement using Java streams



##########
solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java:
##########
@@ -70,13 +71,9 @@ public CacheValue(String path, Directory directory) {
     public boolean closeCacheValueCalled = false;
     public boolean doneWithDir = false;
     private boolean deleteAfterCoreClose = false;
-    public Set<CacheValue> removeEntries = new HashSet<>();

Review Comment:
   It's nice to see one less data structure to track



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org