You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Uwe Schindler <uw...@thetaphi.de> on 2014/05/20 18:16:05 UTC

RE: svn commit: r1596301 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/CHANGES.txt lucene/core/ lucene/core/src/java/org/apache/lucene/index/IndexWriter.java

Hi,

this is a binary backwards break in 4.x, because the method signature, user's code was compiled against in previous versions, is removed for no reason. In 4.x I would keep the one-arg methods, but just let it delegate to the vararg version. The javadocs can stay the same.
In fact this change requires to recompile your source-code (source-code compatibility is ensured) but does not provide binary compatibility.

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: shaie@apache.org [mailto:shaie@apache.org]
> Sent: Tuesday, May 20, 2014 6:02 PM
> To: commits@lucene.apache.org
> Subject: svn commit: r1596301 - in /lucene/dev/branches/branch_4x: ./
> lucene/ lucene/CHANGES.txt lucene/core/
> lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
> 
> Author: shaie
> Date: Tue May 20 16:02:17 2014
> New Revision: 1596301
> 
> URL: http://svn.apache.org/r1596301
> Log:
> LUCENE-5679: remove the single-parameter deleteDocuments() versions, in
> favor of the vararg ones
> 
> Modified:
>     lucene/dev/branches/branch_4x/   (props changed)
>     lucene/dev/branches/branch_4x/lucene/   (props changed)
>     lucene/dev/branches/branch_4x/lucene/CHANGES.txt   (contents, props
> changed)
>     lucene/dev/branches/branch_4x/lucene/core/   (props changed)
> 
> lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/i
> ndex/IndexWriter.java
> 
> Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
> URL:
> http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHA
> NGES.txt?rev=1596301&r1=1596300&r2=1596301&view=diff
> ==========================================================
> ====================
> --- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
> +++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Tue May 20
> 16:02:17
> +++ 2014
> @@ -61,6 +61,10 @@ API Changes
>  * LUCENE-5640: The Token class was deprecated. Since Lucene 2.9,
> TokenStreams
>    are using Attributes, Token is no longer used.  (Uwe Schindler, Robert Muir)
> 
> +* LUCENE-5679: Consolidated IndexWriter.deleteDocuments(Term) and
> +  IndexWriter.deleteDocuments(Query) with their varargs counterparts.
> +  (Shai Erera)
> +
>  Optimizations
> 
>  * LUCENE-5603: hunspell stemmer more efficiently strips prefixes
> 
> Modified:
> lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/i
> ndex/IndexWriter.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/cor
> e/src/java/org/apache/lucene/index/IndexWriter.java?rev=1596301&r1=159
> 6300&r2=1596301&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/i
> ndex/IndexWriter.java (original)
> +++
> lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene
> +++ /index/IndexWriter.java Tue May 20 16:02:17 2014
> @@ -77,8 +77,8 @@ import org.apache.lucene.util.ThreadInte
>    and otherwise open the existing index.</p>
> 
>    <p>In either case, documents are added with {@link
> #addDocument(Iterable)
> -  addDocument} and removed with {@link #deleteDocuments(Term)} or
> {@link
> -  #deleteDocuments(Query)}. A document can be updated with {@link
> +  addDocument} and removed with {@link #deleteDocuments(Term...)} or
> + {@link  #deleteDocuments(Query...)}. A document can be updated with
> + {@link
>    #updateDocument(Term, Iterable) updateDocument} (which just deletes
>    and then adds the entire document). When finished adding, deleting
>    and updating documents, {@link #close() close} should be called.</p> @@ -
> 1323,28 +1323,6 @@ public class IndexWriter implements Clos
>      }
>    }
> 
> -  /**
> -   * Deletes the document(s) containing <code>term</code>.
> -   *
> -   * <p><b>NOTE</b>: if this method hits an OutOfMemoryError
> -   * you should immediately close the writer.  See <a
> -   * href="#OOME">above</a> for details.</p>
> -   *
> -   * @param term the term to identify the documents to be deleted
> -   * @throws CorruptIndexException if the index is corrupt
> -   * @throws IOException if there is a low-level IO error
> -   */
> -  public void deleteDocuments(Term term) throws IOException {
> -    ensureOpen();
> -    try {
> -      if (docWriter.deleteTerms(term)) {
> -        processEvents(true, false);
> -      }
> -    } catch (OutOfMemoryError oom) {
> -      handleOOM(oom, "deleteDocuments(Term)");
> -    }
> -  }
> -
>    /** Expert: attempts to delete by document ID, as long as
>     *  the provided reader is a near-real-time reader (from {@link
>     *  DirectoryReader#open(IndexWriter,boolean)}).  If the @@ -1357,8
> +1335,7 @@ public class IndexWriter implements Clos
>     *  <b>NOTE</b>: this method can only delete documents
>     *  visible to the currently open NRT reader.  If you need
>     *  to delete documents indexed after opening the NRT
> -   *  reader you must use the other deleteDocument methods
> -   *  (e.g., {@link #deleteDocuments(Term)}). */
> +   *  reader you must use {@link #deleteDocuments(Term...)}). */
>    public synchronized boolean tryDeleteDocument(IndexReader readerIn, int
> docID) throws IOException {
> 
>      final AtomicReader reader;
> @@ -1447,28 +1424,6 @@ public class IndexWriter implements Clos
>    }
> 
>    /**
> -   * Deletes the document(s) matching the provided query.
> -   *
> -   * <p><b>NOTE</b>: if this method hits an OutOfMemoryError
> -   * you should immediately close the writer.  See <a
> -   * href="#OOME">above</a> for details.</p>
> -   *
> -   * @param query the query to identify the documents to be deleted
> -   * @throws CorruptIndexException if the index is corrupt
> -   * @throws IOException if there is a low-level IO error
> -   */
> -  public void deleteDocuments(Query query) throws IOException {
> -    ensureOpen();
> -    try {
> -      if (docWriter.deleteQueries(query)) {
> -        processEvents(true, false);
> -      }
> -    } catch (OutOfMemoryError oom) {
> -      handleOOM(oom, "deleteDocuments(Query)");
> -    }
> -  }
> -
> -  /**
>     * Deletes the document(s) matching any of the provided queries.
>     * All given deletes are applied and flushed atomically at the same time.
>     *
> @@ -2187,25 +2142,30 @@ public class IndexWriter implements Clos
> 
>    /**
>     * Delete all documents in the index.
> -   *
> -   * <p>This method will drop all buffered documents and will
> -   *    remove all segments from the index. This change will not be
> -   *    visible until a {@link #commit()} has been called. This method
> -   *    can be rolled back using {@link #rollback()}.</p>
> -   *
> -   * <p>NOTE: this method is much faster than using deleteDocuments( new
> MatchAllDocsQuery() ).
> -   *    Yet, this method also has different semantics compared to {@link
> #deleteDocuments(Query)}
> -   *    / {@link #deleteDocuments(Query...)} since internal data-structures
> are cleared as well
> -   *    as all segment information is forcefully dropped anti-viral semantics like
> omitting norms
> -   *    are reset or doc value types are cleared. Essentially a call to {@link
> #deleteAll()} is equivalent
> -   *    to creating a new {@link IndexWriter} with {@link OpenMode#CREATE}
> which a delete query only marks
> -   *    documents as deleted.</p>
> -   *
> -   * <p>NOTE: this method will forcefully abort all merges
> -   *    in progress.  If other threads are running {@link
> -   *    #forceMerge}, {@link #addIndexes(IndexReader[])} or
> -   *    {@link #forceMergeDeletes} methods, they may receive
> -   *    {@link MergePolicy.MergeAbortedException}s.
> +   *
> +   * <p>
> +   * This method will drop all buffered documents and will remove all
> segments
> +   * from the index. This change will not be visible until a {@link #commit()}
> +   * has been called. This method can be rolled back using {@link
> #rollback()}.
> +   * </p>
> +   *
> +   * <p>
> +   * NOTE: this method is much faster than using deleteDocuments( new
> +   * MatchAllDocsQuery() ). Yet, this method also has different semantics
> +   * compared to {@link #deleteDocuments(Query...)} since internal
> +   * data-structures are cleared as well as all segment information is
> +   * forcefully dropped anti-viral semantics like omitting norms are reset or
> +   * doc value types are cleared. Essentially a call to {@link #deleteAll()} is
> +   * equivalent to creating a new {@link IndexWriter} with
> +   * {@link OpenMode#CREATE} which a delete query only marks
> documents as
> +   * deleted.
> +   * </p>
> +   *
> +   * <p>
> +   * NOTE: this method will forcefully abort all merges in progress. If other
> +   * threads are running {@link #forceMerge}, {@link
> #addIndexes(IndexReader[])}
> +   * or {@link #forceMergeDeletes} methods, they may receive
> +   * {@link MergePolicy.MergeAbortedException}s.
>     */
>    public void deleteAll() throws IOException {
>      ensureOpen();



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org