You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by us...@apache.org on 2009/06/07 23:52:42 UTC

svn commit: r782469 - in /lucene/java/trunk: ./ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/ contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/ contrib/benchmark/src/java/org/apache/lucene/benchmark/standard/ contri...

Author: uschindler
Date: Sun Jun  7 21:52:41 2009
New Revision: 782469

URL: http://svn.apache.org/viewvc?rev=782469&view=rev
Log:
LUCENE-1672: Deprecate all String/File ctors/opens in IndexReader/IndexWriter/IndexSearcher

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/standard/StandardBenchmarker.java
    lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java
    lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
    lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java
    lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/IndexMergeTool.java
    lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java
    lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java
    lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java
    lucene/java/trunk/src/demo/org/apache/lucene/demo/DeleteFiles.java
    lucene/java/trunk/src/java/org/apache/lucene/index/CheckIndex.java
    lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexModifier.java
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java
    lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java
    lucene/java/trunk/src/java/overview.html
    lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java
    lucene/java/trunk/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Sun Jun  7 21:52:41 2009
@@ -185,6 +185,12 @@
     iterator has exhausted. Otherwise it should return the current doc ID.
     (Shai Erera via Mike McCandless)
 
+19. LUCENE-1672: All ctors/opens and other methods using String/File to
+    specify the directory in IndexReader, IndexWriter, and IndexSearcher
+    were deprecated. You should instantiate the Directory manually before
+    and pass it to these classes (LUCENE-1451, LUCENE-1658).
+    (Uwe Schindler)
+
 Bug fixes
 
 1. LUCENE-1415: MultiPhraseQuery has incorrect hashCode() and equals()

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java (original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java Sun Jun  7 21:52:41 2009
@@ -128,7 +128,7 @@
         FileUtils.fullyDelete(indexDir);
       }
       indexDir.mkdirs();
-      directory = FSDirectory.getDirectory(indexDir);
+      directory = FSDirectory.open(indexDir);
     } else {
       directory = new RAMDirectory();
     }

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java (original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java Sun Jun  7 21:52:41 2009
@@ -52,7 +52,7 @@
       System.err.println("Usage: java QualityQueriesFinder <index-dir>");
       System.exit(1);
     }
-    QualityQueriesFinder qqf = new QualityQueriesFinder(FSDirectory.getDirectory(new File(args[0])));
+    QualityQueriesFinder qqf = new QualityQueriesFinder(FSDirectory.open(new File(args[0])));
     String q[] = qqf.bestQueries("body",20);
     for (int i=0; i<q.length; i++) {
       System.out.println(newline+formatQueryAsTrecTopic(i,q[i],null,null));

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/standard/StandardBenchmarker.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/standard/StandardBenchmarker.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/standard/StandardBenchmarker.java (original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/standard/StandardBenchmarker.java Sun Jun  7 21:52:41 2009
@@ -92,7 +92,7 @@
             try
             {
                 reset(indexDir);
-                params[i].setDirectory(FSDirectory.getDirectory(indexDir));
+                params[i].setDirectory(FSDirectory.open(indexDir));
                 params[i].setQueries(qds);
                 System.out.println(params[i]);
                 runBenchmark(params[i], options);

Modified: lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java (original)
+++ lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java Sun Jun  7 21:52:41 2009
@@ -82,7 +82,7 @@
     // validate topics & judgments match each other
     judge.validateData(qqs, logger);
     
-    IndexSearcher searcher = new IndexSearcher(FSDirectory.getDirectory(new File(workDir,"index")));
+    IndexSearcher searcher = new IndexSearcher(FSDirectory.open(new File(workDir,"index")));
 
     QualityQueryParser qqParser = new SimpleQQParser("title","body");
     QualityBenchmark qrun = new QualityBenchmark(qqs, qqParser, searcher, docNameField);

Modified: lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java (original)
+++ lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java Sun Jun  7 21:52:41 2009
@@ -47,7 +47,7 @@
 public class TestIndicesEquals extends TestCase {
 
 //  public void test2() throws Exception {
-//    FSDirectory fsdir = FSDirectory.getDirectory("/tmp/fatcorpus");
+//    FSDirectory fsdir = FSDirectory.open(new File("/tmp/fatcorpus"));
 //    IndexReader ir = IndexReader.open(fsdir);
 //    InstantiatedIndex ii = new InstantiatedIndex(ir);
 //    ir.close();

Modified: lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java (original)
+++ lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/index/FieldNormModifier.java Sun Jun  7 21:52:41 2009
@@ -17,6 +17,7 @@
  */
 
 import java.io.IOException;
+import java.io.File;
 import java.util.Date;
 
 import org.apache.lucene.search.Similarity;
@@ -62,7 +63,7 @@
       }
     }
 
-    Directory d = FSDirectory.getDirectory(args[0], false);
+    Directory d = FSDirectory.open(new File(args[0]));
     FieldNormModifier fnm = new FieldNormModifier(d, s);
 
     for (int i = 2; i < args.length; i++) {

Modified: lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/IndexMergeTool.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/IndexMergeTool.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/IndexMergeTool.java (original)
+++ lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/IndexMergeTool.java Sun Jun  7 21:52:41 2009
@@ -41,7 +41,7 @@
 
     Directory[] indexes = new Directory[args.length - 1];
     for (int i = 1; i < args.length; i++) {
-      indexes[i  - 1] = FSDirectory.getDirectory(args[i], false);
+      indexes[i  - 1] = FSDirectory.open(new File(args[i]));
     }
 
     System.out.println("Merging...");

Modified: lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java (original)
+++ lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/LengthNormModifier.java Sun Jun  7 21:52:41 2009
@@ -65,7 +65,7 @@
     }
     
     File index = new File(args[0]);
-    Directory d = FSDirectory.getDirectory(index,false);
+    Directory d = FSDirectory.open(index);
     
     LengthNormModifier lnm = new LengthNormModifier(d, s);
     

Modified: lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java (original)
+++ lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java Sun Jun  7 21:52:41 2009
@@ -19,6 +19,7 @@
 
 import java.io.IOException;
 import java.io.StringReader;
+import java.io.File;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -68,7 +69,7 @@
 							   "java org.apache.lucene.wordnet.SynExpand <index path> <query>");
 		}
 
-		FSDirectory directory = FSDirectory.getDirectory(args[0], false);
+		FSDirectory directory = FSDirectory.open(new File(args[0]));
 		IndexSearcher searcher = new IndexSearcher(directory);
 
 		String query = args[1];

Modified: lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java (original)
+++ lucene/java/trunk/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java Sun Jun  7 21:52:41 2009
@@ -19,6 +19,7 @@
 
 import java.io.IOException;
 import java.io.StringReader;
+import java.io.File;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -51,7 +52,7 @@
 							   "java org.apache.lucene.wordnet.SynLookup <index path> <word>");
 		}
 
-		FSDirectory directory = FSDirectory.getDirectory(args[0], false);
+		FSDirectory directory = FSDirectory.open(new File(args[0]));
 		IndexSearcher searcher = new IndexSearcher(directory);
 
 		String word = args[1];

Modified: lucene/java/trunk/src/demo/org/apache/lucene/demo/DeleteFiles.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/demo/org/apache/lucene/demo/DeleteFiles.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/src/demo/org/apache/lucene/demo/DeleteFiles.java (original)
+++ lucene/java/trunk/src/demo/org/apache/lucene/demo/DeleteFiles.java Sun Jun  7 21:52:41 2009
@@ -17,6 +17,8 @@
  * limitations under the License.
  */
 
+import java.io.File;
+
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.index.IndexReader;
@@ -37,7 +39,7 @@
       System.exit(1);
     }
     try {
-      Directory directory = FSDirectory.getDirectory("index");
+      Directory directory = FSDirectory.open(new File("index"));
       IndexReader reader = IndexReader.open(directory);
 
       Term term = new Term("path", args[0]);

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/CheckIndex.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/CheckIndex.java Sun Jun  7 21:52:41 2009
@@ -26,6 +26,7 @@
 import java.text.NumberFormat;
 import java.io.PrintStream;
 import java.io.IOException;
+import java.io.File;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -702,7 +703,7 @@
     System.out.println("\nOpening index @ " + indexPath + "\n");
     Directory dir = null;
     try {
-      dir = FSDirectory.getDirectory(indexPath);
+      dir = FSDirectory.open(new File(indexPath));
     } catch (Throwable t) {
       System.out.println("ERROR: could not open directory \"" + indexPath + "\"; exiting");
       t.printStackTrace(System.out);

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java Sun Jun  7 21:52:41 2009
@@ -456,12 +456,16 @@
 
     DirectoryReader reader = null;
 
-    // While trying to reopen, we temporarily mark our
-    // closeDirectory as false.  This way any exceptions hit
-    // partway while opening the reader, which is expected
-    // eg if writer is committing, won't close our
-    // directory.  We restore this value below:
-    final boolean myCloseDirectory = closeDirectory;
+    /* TODO: Remove this in 3.0 - the directory is then
+     * no longer owned by the IndexReader and must not be
+     * closed.
+     * While trying to reopen, we temporarily mark our
+     * closeDirectory as false.  This way any exceptions hit
+     * partway while opening the reader, which is expected
+     * eg if writer is committing, won't close our
+     * directory.  We restore this value below:
+     */
+    final boolean myCloseDirectory = closeDirectory; // @deprectated
     closeDirectory = false;
 
     try {

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexModifier.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexModifier.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexModifier.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexModifier.java Sun Jun  7 21:52:41 2009
@@ -97,7 +97,7 @@
 
   protected Directory directory = null;
   protected Analyzer analyzer = null;
-  protected boolean open = false;
+  protected boolean open = false, closeDir = false;
 
   // Lucene defaults:
   protected PrintStream infoStream = null;
@@ -138,6 +138,7 @@
    */
   public IndexModifier(String dirName, Analyzer analyzer, boolean create) throws CorruptIndexException, LockObtainFailedException, IOException {
     Directory dir = FSDirectory.getDirectory(dirName);
+    this.closeDir = true;
     init(dir, analyzer, create);
   }
 
@@ -156,6 +157,7 @@
    */
   public IndexModifier(File file, Analyzer analyzer, boolean create) throws CorruptIndexException, LockObtainFailedException, IOException {
     Directory dir = FSDirectory.getDirectory(file);
+    this.closeDir = true;
     init(dir, analyzer, create);
   }
 
@@ -578,6 +580,10 @@
         indexReader = null;
       }
       open = false;
+      if (closeDir) {
+        directory.close();
+      }
+      closeDir = false;
     }
   }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java Sun Jun  7 21:52:41 2009
@@ -204,7 +204,8 @@
    *  path.
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
-   * @deprecated Use {@link #open(Directory, boolean)} instead
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #open(Directory, boolean)} instead
    * @param path the path to the index directory */
   public static IndexReader open(String path) throws CorruptIndexException, IOException {
     return open(FSDirectory.getDirectory(path), true, null, null, false);
@@ -220,7 +221,9 @@
    * @param path the path to the index directory
    * @param readOnly true if this should be a readOnly
    * reader
-   * @deprecated Use {@link #open(Directory, boolean)} instead*/
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #open(Directory, boolean)} instead
+   */
   public static IndexReader open(String path, boolean readOnly) throws CorruptIndexException, IOException {
     return open(FSDirectory.getDirectory(path), true, null, null, readOnly);
   }
@@ -230,7 +233,8 @@
    * @param path the path to the index directory
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
-   * @deprecated Use {@link #open(Directory, boolean)} instead
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #open(Directory, boolean)} instead
    */
   public static IndexReader open(File path) throws CorruptIndexException, IOException {
     return open(FSDirectory.getDirectory(path), true, null, null, false);
@@ -246,8 +250,9 @@
    * @param path the path to the index directory
    * @param readOnly true if this should be a readOnly
    * reader
-   * @deprecated Use {@link #open(Directory, boolean)}
-   * instead */
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #open(Directory, boolean)} instead
+   */
   public static IndexReader open(File path, boolean readOnly) throws CorruptIndexException, IOException {
     return open(FSDirectory.getDirectory(path), true, null, null, readOnly);
   }
@@ -257,7 +262,8 @@
    * @param directory the index directory
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
-   * @deprecated Use {@link #open(Directory, boolean)} instead
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #open(Directory, boolean)} instead
    */
   public static IndexReader open(final Directory directory) throws CorruptIndexException, IOException {
     return open(directory, false, null, null, false);
@@ -281,7 +287,8 @@
    * {@link IndexCommit}.
    * @param commit the commit point to open
    * @throws CorruptIndexException if the index is corrupt
-   * @deprecated Use {@link #open(IndexCommit, boolean)} instead
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #open(IndexCommit, boolean)} instead
    * @throws IOException if there is a low-level IO error
    */
   public static IndexReader open(final IndexCommit commit) throws CorruptIndexException, IOException {
@@ -308,8 +315,8 @@
    * @param deletionPolicy a custom deletion policy (only used
    *  if you use this reader to perform deletes or to set
    *  norms); see {@link IndexWriter} for details.
-   * @deprecated Use {@link #open(Directory,
-   * IndexDeletionPolicy, boolean)} instead
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #open(Directory, IndexDeletionPolicy, boolean)} instead
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
    */
@@ -344,8 +351,8 @@
    * @param deletionPolicy a custom deletion policy (only used
    *  if you use this reader to perform deletes or to set
    *  norms); see {@link IndexWriter} for details.
-   * @deprecated Use {@link #open(IndexCommit,
-   * IndexDeletionPolicy, boolean)} instead
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #open(IndexCommit, IndexDeletionPolicy, boolean)} instead
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
    */
@@ -500,6 +507,8 @@
    * {@link #isCurrent()} instead. 
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #lastModified(Directory)} instead
    */
   public static long lastModified(String directory) throws CorruptIndexException, IOException {
     return lastModified(new File(directory));
@@ -511,13 +520,16 @@
    * {@link #isCurrent()} instead. 
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #lastModified(Directory)} instead
    */
   public static long lastModified(File fileDirectory) throws CorruptIndexException, IOException {
-    return ((Long) new SegmentInfos.FindSegmentsFile(fileDirectory) {
-        public Object doBody(String segmentFileName) {
-          return new Long(FSDirectory.fileModified(fileDirectory, segmentFileName));
-        }
-      }.run()).longValue();
+    Directory dir = FSDirectory.getDirectory(fileDirectory); // use new static method here
+    try {
+      return lastModified(dir);
+    } finally {
+      dir.close();
+    }
   }
 
   /**
@@ -544,6 +556,8 @@
    * @return version number.
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #getCurrentVersion(Directory)} instead
    */
   public static long getCurrentVersion(String directory) throws CorruptIndexException, IOException {
     return getCurrentVersion(new File(directory));
@@ -558,7 +572,8 @@
    * @return version number.
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
-   * @deprecated Use {@link #getCurrentVersion(Directory)} instead
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #getCurrentVersion(Directory)} instead
    */
   public static long getCurrentVersion(File directory) throws CorruptIndexException, IOException {
     Directory dir = FSDirectory.getDirectory(directory);
@@ -741,6 +756,8 @@
    * <code>false</code> is returned.
    * @param  directory the directory to check for an index
    * @return <code>true</code> if an index exists; <code>false</code> otherwise
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #indexExists(Directory)} instead
    */
   public static boolean indexExists(String directory) {
     return indexExists(new File(directory));
@@ -751,6 +768,8 @@
    * If the directory does not exist or if there is no index in it.
    * @param  directory the directory to check for an index
    * @return <code>true</code> if an index exists; <code>false</code> otherwise
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #indexExists(Directory)} instead
    */
 
   public static boolean indexExists(File directory) {
@@ -1159,7 +1178,8 @@
    * currently locked.
    * @param directory the directory to check for a lock
    * @throws IOException if there is a low-level IO error
-   * @deprecated Please use {@link IndexWriter#isLocked(Directory)} instead
+   * @deprecated This method will be removed in the 3.0 release.
+   * Please use {@link IndexWriter#isLocked(Directory)} instead
    */
   public static boolean isLocked(Directory directory) throws IOException {
     return
@@ -1171,7 +1191,8 @@
    * currently locked.
    * @param directory the directory to check for a lock
    * @throws IOException if there is a low-level IO error
-   * @deprecated Please use {@link IndexWriter#isLocked(Directory)} instead
+   * @deprecated This method will be removed in the 3.0 release.
+   * Use {@link #isLocked(Directory)} instead
    */
   public static boolean isLocked(String directory) throws IOException {
     Directory dir = FSDirectory.getDirectory(directory);
@@ -1186,7 +1207,8 @@
    * Caution: this should only be used by failure recovery code,
    * when it is known that no other process nor thread is in fact
    * currently accessing this index.
-   * @deprecated Please use {@link IndexWriter#unlock(Directory)} instead
+   * @deprecated This method will be removed in the 3.0 release.
+   * Please use {@link IndexWriter#unlock(Directory)} instead
    */
   public static void unlock(Directory directory) throws IOException {
     directory.makeLock(IndexWriter.WRITE_LOCK_NAME).release();
@@ -1236,7 +1258,7 @@
       File file = new File(filename);
       String dirname = file.getAbsoluteFile().getParent();
       filename = file.getName();
-      dir = FSDirectory.getDirectory(dirname);
+      dir = FSDirectory.open(new File(dirname));
       cfr = new CompoundFileReader(dir, filename);
 
       String [] files = cfr.list();

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java Sun Jun  7 21:52:41 2009
@@ -17,7 +17,6 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.IndexOutput;
@@ -523,13 +522,8 @@
    */
   public abstract static class FindSegmentsFile {
     
-    File fileDirectory;
     Directory directory;
 
-    public FindSegmentsFile(File directory) {
-      this.fileDirectory = directory;
-    }
-
     public FindSegmentsFile(Directory directory) {
       this.directory = directory;
     }
@@ -582,10 +576,7 @@
 
           long genA = -1;
 
-          if (directory != null)
-            files = directory.listAll();
-          else
-            files = FSDirectory.listAll(fileDirectory);
+          files = directory.listAll();
           
           if (files != null)
             genA = getCurrentSegmentGeneration(files);
@@ -732,10 +723,7 @@
                                                                                gen-1);
 
             final boolean prevExists;
-            if (directory != null)
-              prevExists = directory.fileExists(prevSegmentFileName);
-            else
-              prevExists = new File(fileDirectory, prevSegmentFileName).exists();
+            prevExists = directory.fileExists(prevSegmentFileName);
 
             if (prevExists) {
               message("fallback to prior segment file '" + prevSegmentFileName + "'");

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java Sun Jun  7 21:52:41 2009
@@ -46,7 +46,7 @@
   /** Creates a searcher searching the index in the named directory.
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
-   * @deprecated Use {@link #IndexSearcher(String, boolean)} instead
+   * @deprecated Use {@link #IndexSearcher(Directory, boolean)} instead
    */
   public IndexSearcher(String path) throws CorruptIndexException, IOException {
     this(IndexReader.open(path), true);
@@ -62,6 +62,7 @@
    * will be opened readOnly
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
+   * @deprecated Use {@link #IndexSearcher(Directory, boolean)} instead
    */
   public IndexSearcher(String path, boolean readOnly) throws CorruptIndexException, IOException {
     this(IndexReader.open(path, readOnly), true);

Modified: lucene/java/trunk/src/java/overview.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/overview.html?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/src/java/overview.html (original)
+++ lucene/java/trunk/src/java/overview.html Sun Jun  7 21:52:41 2009
@@ -40,7 +40,7 @@
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//&nbsp;Store&nbsp;the&nbsp;index&nbsp;in&nbsp;memory:</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">Directory&nbsp;directory&nbsp;=&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">RAMDirectory</font><font color="#000000">()</font><font color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//&nbsp;To&nbsp;store&nbsp;an&nbsp;index&nbsp;on&nbsp;disk,&nbsp;use&nbsp;this&nbsp;instead:</font><br />
-<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//Directory&nbsp;directory&nbsp;=&nbsp;FSDirectory.getDirectory(&#34;/tmp/testindex&#34;);</font><br />
+<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//Directory&nbsp;directory&nbsp;=&nbsp;FSDirectory.open(&#34;/tmp/testindex&#34;);</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">IndexWriter&nbsp;iwriter&nbsp;=&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">IndexWriter</font><font color="#000000">(</font><font color="#000000">directory,&nbsp;analyzer,&nbsp;true,</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">IndexWriter.MaxFieldLength</font><font color="#000000">(</font><font color="#990000">25000</font><font color="#000000">))</font><font color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">Document&nbsp;doc&nbsp;=&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">Document</font><font color="#000000">()</font><font color="#000000">;</font><br />

Modified: lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java Sun Jun  7 21:52:41 2009
@@ -49,7 +49,7 @@
     // Store the index in memory:
     Directory directory = new RAMDirectory();
     // To store an index on disk, use this instead:
-    //Directory directory = FSDirectory.getDirectory("/tmp/testindex");
+    //Directory directory = FSDirectory.open(new File("/tmp/testindex"));
     IndexWriter iwriter = new IndexWriter(directory, analyzer, true,
                                           new IndexWriter.MaxFieldLength(25000));
     Document doc = new Document();

Modified: lucene/java/trunk/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java?rev=782469&r1=782468&r2=782469&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java Sun Jun  7 21:52:41 2009
@@ -54,7 +54,7 @@
     try {
       // Sometimes past test leaves the dir
       _TestUtil.rmDir(dir);
-      Directory fsDir = FSDirectory.getDirectory(dir);
+      Directory fsDir = FSDirectory.open(dir);
       runTest(fsDir);
       fsDir.close();
     } finally {