lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r354934 - /lucene/java/trunk/src/java/org/apache/lucene/index/IndexModifier.java
Date Thu, 08 Dec 2005 02:14:30 GMT
Author: ehatcher
Date: Wed Dec  7 18:14:25 2005
New Revision: 354934

URL: http://svn.apache.org/viewcvs?rev=354934&view=rev
Log:
Likewise rename the delete methods for IndexModifier, deprecating the old (though not strictly
necessary since IndexModifier was added after 1.4.3)


Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexModifier.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexModifier.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/index/IndexModifier.java?rev=354934&r1=354933&r2=354934&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 Wed Dec  7 18:14:25
2005
@@ -58,7 +58,7 @@
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">indexModifier.flush</font><font color="#000000">()</font><font
color="#000000">;</font><br/>
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">System.out.println</font><font color="#000000">(</font><font
color="#000000">indexModifier.docCount</font><font color="#000000">()&nbsp;</font><font
color="#000000">+&nbsp;</font><font color="#2a00ff">&#34;&nbsp;docs&nbsp;in&nbsp;index&#34;</font><font
color="#000000">)</font><font color="#000000">;</font><br/>
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">indexModifier.close</font><font color="#000000">()</font><font
color="#000000">;</font></code>
-    
+
    </td>
   <!-- end source code -->
    </tr>
@@ -67,31 +67,31 @@
 <!-- =       END of automatically generated HTML code       = -->
 <!-- ======================================================== -->
  *
- * <p>Not all methods of IndexReader and IndexWriter are offered by this 
- * class. If you need access to additional methods, either use those classes 
+ * <p>Not all methods of IndexReader and IndexWriter are offered by this
+ * class. If you need access to additional methods, either use those classes
  * directly or implement your own class that extends <code>IndexModifier</code>.
- *  
+ *
  * <p>Although an instance of this class can be used from more than one
- * thread, you will not get the best performance. You might want to use 
- * IndexReader and IndexWriter directly for that (but you will need to 
+ * thread, you will not get the best performance. You might want to use
+ * IndexReader and IndexWriter directly for that (but you will need to
  * care about synchronization yourself then).
- * 
+ *
  * <p>While you can freely mix calls to add() and delete() using this class,
  * you should batch you calls for best performance. For example, if you
  * want to update 20 documents, you should first delete all those documents,
  * then add all the new documents.
- * 
+ *
  * @author Daniel Naber
  */
 public class IndexModifier {
-  
+
   protected IndexWriter indexWriter = null;
   protected IndexReader indexReader = null;
-  
+
   protected Directory directory = null;
   protected Analyzer analyzer = null;
   protected boolean open = false;
-  
+
   // Lucene defaults:
   protected PrintStream infoStream = null;
   protected boolean useCompoundFile = true;
@@ -101,7 +101,7 @@
 
   /**
    * Open an index with write access.
-   *  
+   *
    * @param directory the index directory
    * @param analyzer the analyzer to use for adding new documents
    * @param create <code>true</code> to create the index or overwrite the existing
one;
@@ -113,7 +113,7 @@
 
   /**
    * Open an index with write access.
-   *  
+   *
    * @param dirName the index directory
    * @param analyzer the analyzer to use for adding new documents
    * @param create <code>true</code> to create the index or overwrite the existing
one;
@@ -123,10 +123,10 @@
     Directory dir = FSDirectory.getDirectory(dirName, create);
     init(dir, analyzer, create);
   }
-  
+
   /**
    * Open an index with write access.
-   *  
+   *
    * @param file the index directory
    * @param analyzer the analyzer to use for adding new documents
    * @param create <code>true</code> to create the index or overwrite the existing
one;
@@ -249,29 +249,54 @@
    * term with the appropriate field and the unique ID string as its text and
    * passes it to this method.  Returns the number of documents deleted.
    * @return the number of documents deleted
-   * @see IndexReader#delete(Term)
+   * @see IndexReader#deleteDocuments(Term)
    * @throws IllegalStateException if the index is closed
    */
-  public int delete(Term term) throws IOException {
+  public int deleteDocuments(Term term) throws IOException {
     synchronized(directory) {
       assureOpen();
       createIndexReader();
-      return indexReader.delete(term);
+      return indexReader.deleteDocuments(term);
     }
   }
 
   /**
+   * Deletes all documents containing <code>term</code>.
+   * This is useful if one uses a document field to hold a unique ID string for
+   * the document.  Then to delete such a document, one merely constructs a
+   * term with the appropriate field and the unique ID string as its text and
+   * passes it to this method.  Returns the number of documents deleted.
+   * @return the number of documents deleted
+   * @see IndexReader#deleteDocuments(Term)
+   * @throws IllegalStateException if the index is closed
+   * @deprecated Use {@link #deleteDocuments(Term)} instead.
+   */
+  public int delete(Term term) throws IOException {
+    return deleteDocuments(term);
+  }
+
+  /**
    * Deletes the document numbered <code>docNum</code>.
-   * @see IndexReader#delete(int)
+   * @see IndexReader#deleteDocument(int)
    * @throws IllegalStateException if the index is closed
    */
-  public void delete(int docNum) throws IOException {
+  public void deleteDocument(int docNum) throws IOException {
     synchronized(directory) {
       assureOpen();
       createIndexReader();
-      indexReader.delete(docNum);
+      indexReader.deleteDocument(docNum);
     }
   }
+
+  /**
+   * Deletes the document numbered <code>docNum</code>.
+   * @see IndexReader#deleteDocument(int)
+   * @throws IllegalStateException if the index is closed
+   * @deprecated Use {@link #deleteDocument(int)} instead.
+   */
+  public void delete(int docNum) throws IOException {
+    deleteDocument(docNum);
+  }
   
   /**
    * Returns the number of documents currently in this index.
@@ -320,7 +345,7 @@
       this.infoStream = infoStream;
     }
   }
-  
+
   /**
    * @throws IOException
    * @see IndexModifier#setInfoStream(PrintStream)
@@ -361,7 +386,7 @@
       return indexWriter.getUseCompoundFile();
     }
   }
-  
+
   /**
    * The maximum number of terms that will be indexed for a single field in a
    * document.  This limits the amount of memory required for indexing, so that
@@ -397,7 +422,7 @@
       return indexWriter.getMaxFieldLength();
     }
   }
-  
+
   /**
    * The maximum number of terms that will be indexed for a single field in a
    * document.  This limits the amount of memory required for indexing, so that
@@ -443,7 +468,7 @@
    * for batch index creation, and smaller values (&lt; 10) for indices that are
    * interactively maintained.
    * <p>This must never be less than 2.  The default value is 10.
-   * 
+   *
    * @see IndexWriter#setMergeFactor(int)
    * @throws IllegalStateException if the index is closed
    */
@@ -471,7 +496,7 @@
 
   /**
    * Close this index, writing all pending changes to disk.
-   * 
+   *
    * @throws IllegalStateException if the index has been closed before already
    */
   public void close() throws IOException {
@@ -488,11 +513,11 @@
       open = false;
     }
   }
-  
+
   public String toString() {
     return "Index@" + directory;
   }
-  
+
   /*
   // used as an example in the javadoc:
   public static void main(String[] args) throws IOException {



Mime
View raw message