mikemccand commented on a change in pull request #2052:
URL: https://github.com/apache/lucene-solr/pull/2052#discussion_r537569680



##########
File path: 
lucene/misc/src/java/org/apache/lucene/misc/store/DirectIODirectory.java
##########
@@ -154,14 +146,43 @@ public IndexOutput createOutput(String name, IOContext 
context) throws IOExcepti
     if (context.context != Context.MERGE || 
context.mergeInfo.estimatedMergeBytes < minBytesDirect) {
       return delegate.createOutput(name, context);
     } else {
-      return new NativeUnixIndexOutput(getDirectory().resolve(name), name, 
mergeBufferSize);
+      return new DirectIOIndexOutput(getDirectory().resolve(name), name, 
mergeBufferSize);
     }
   }
 
-  @SuppressForbidden(reason = "java.io.File: native API requires old-style 
FileDescriptor")
-  private final static class NativeUnixIndexOutput extends IndexOutput {
+  @Override
+  public void deleteFile(String name) throws IOException {
+    delegate.deleteFile(name);
+  }
+
+  @Override
+  public Set<String> getPendingDeletions() throws IOException {
+    return delegate.getPendingDeletions();
+  }
+
+  @Override
+  public String[] listAll() throws IOException {
+    return delegate.listAll();
+  }
+
+  @Override
+  public long fileLength(String name) throws IOException {
+    return delegate.fileLength(name);
+  }
+
+  @Override
+  public void rename(String source, String dest) throws IOException {
+    delegate.rename(source, dest);
+  }
+
+  @Override
+  public void close() throws IOException {
+    delegate.close();

Review comment:
       Maybe use `IOUtils.close(...)` here instead?  It will try to close both 
even if one of them throws exception.

##########
File path: 
lucene/misc/src/java/org/apache/lucene/misc/store/DirectIODirectory.java
##########
@@ -154,14 +146,43 @@ public IndexOutput createOutput(String name, IOContext 
context) throws IOExcepti
     if (context.context != Context.MERGE || 
context.mergeInfo.estimatedMergeBytes < minBytesDirect) {
       return delegate.createOutput(name, context);
     } else {
-      return new NativeUnixIndexOutput(getDirectory().resolve(name), name, 
mergeBufferSize);
+      return new DirectIOIndexOutput(getDirectory().resolve(name), name, 
mergeBufferSize);
     }
   }
 
-  @SuppressForbidden(reason = "java.io.File: native API requires old-style 
FileDescriptor")
-  private final static class NativeUnixIndexOutput extends IndexOutput {
+  @Override
+  public void deleteFile(String name) throws IOException {
+    delegate.deleteFile(name);
+  }
+
+  @Override
+  public Set<String> getPendingDeletions() throws IOException {

Review comment:
       I wonder if we should simply extend `FilterDirectory` here?  Let that 
class (designed for such delegation) handle delegating all existing `Directory` 
methods?  It would lower the risk that a new `Directory` method fails to get 
delegated here ...
   
   But, we can do this as followon issue.




----------------------------------------------------------------
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.

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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to