You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by to...@apache.org on 2021/12/07 06:34:46 UTC

[lucene] branch branch_9x updated: LUCENE-10287: Re-add abstract FSDirectory class as a supported directory (#522)

This is an automated email from the ASF dual-hosted git repository.

tomoko pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 3eadfd4  LUCENE-10287: Re-add abstract FSDirectory class as a supported directory (#522)
3eadfd4 is described below

commit 3eadfd45967132def4a7e1b8f267aae4bc594966
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Tue Dec 7 15:32:12 2021 +0900

    LUCENE-10287: Re-add abstract FSDirectory class as a supported directory (#522)
---
 .../components/dialog/menubar/OpenIndexDialogFactory.java   |  9 ++-------
 .../java/org/apache/lucene/luke/models/util/IndexUtils.java | 13 +++++++++++++
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/lucene/luke/src/java/org/apache/lucene/luke/app/desktop/components/dialog/menubar/OpenIndexDialogFactory.java b/lucene/luke/src/java/org/apache/lucene/luke/app/desktop/components/dialog/menubar/OpenIndexDialogFactory.java
index 9627a15..a523cd4 100644
--- a/lucene/luke/src/java/org/apache/lucene/luke/app/desktop/components/dialog/menubar/OpenIndexDialogFactory.java
+++ b/lucene/luke/src/java/org/apache/lucene/luke/app/desktop/components/dialog/menubar/OpenIndexDialogFactory.java
@@ -55,9 +55,8 @@ import org.apache.lucene.luke.app.desktop.util.FontUtils;
 import org.apache.lucene.luke.app.desktop.util.MessageUtils;
 import org.apache.lucene.luke.app.desktop.util.StyleConstants;
 import org.apache.lucene.luke.models.LukeException;
+import org.apache.lucene.luke.models.util.IndexUtils;
 import org.apache.lucene.luke.util.LoggerFactory;
-import org.apache.lucene.store.MMapDirectory;
-import org.apache.lucene.store.NIOFSDirectory;
 import org.apache.lucene.util.NamedThreadFactory;
 import org.apache.lucene.util.SuppressForbidden;
 
@@ -127,7 +126,7 @@ public final class OpenIndexDialogFactory implements DialogOpener.DialogFactory
         Executors.newFixedThreadPool(1, new NamedThreadFactory("load-directory-types"));
     executorService.execute(
         () -> {
-          for (String clazzName : supportedDirImpls()) {
+          for (String clazzName : IndexUtils.supportedDirectoryImpls()) {
             dirImplCombo.addItem(clazzName);
           }
         });
@@ -254,10 +253,6 @@ public final class OpenIndexDialogFactory implements DialogOpener.DialogFactory
     return panel;
   }
 
-  private String[] supportedDirImpls() {
-    return new String[] {MMapDirectory.class.getName(), NIOFSDirectory.class.getName()};
-  }
-
   private JPanel buttons() {
     JPanel panel = new JPanel(new FlowLayout(FlowLayout.TRAILING));
     panel.setOpaque(false);
diff --git a/lucene/luke/src/java/org/apache/lucene/luke/models/util/IndexUtils.java b/lucene/luke/src/java/org/apache/lucene/luke/models/util/IndexUtils.java
index 099326f..a8c35f5 100644
--- a/lucene/luke/src/java/org/apache/lucene/luke/models/util/IndexUtils.java
+++ b/lucene/luke/src/java/org/apache/lucene/luke/models/util/IndexUtils.java
@@ -47,6 +47,8 @@ import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.LockFactory;
+import org.apache.lucene.store.MMapDirectory;
+import org.apache.lucene.store.NIOFSDirectory;
 import org.apache.lucene.util.Bits;
 
 /**
@@ -109,6 +111,17 @@ public final class IndexUtils {
   }
 
   /**
+   * Returns supported {@link Directory} implementations.
+   *
+   * @return class names of supported directory implementation
+   */
+  public static String[] supportedDirectoryImpls() {
+    return new String[] {
+      FSDirectory.class.getName(), MMapDirectory.class.getName(), NIOFSDirectory.class.getName()
+    };
+  }
+
+  /**
    * Opens an index directory for given index path.
    *
    * <p>This can be used to open/repair corrupted indexes.