You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2011/12/10 14:01:52 UTC

svn commit: r1212787 - in /lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index: MultiReader.java ParallelReader.java

Author: uschindler
Date: Sat Dec 10 13:01:51 2011
New Revision: 1212787

URL: http://svn.apache.org/viewvc?rev=1212787&view=rev
Log:
LUCENE-3630: Revert last commit and add better UOE/javadocs

Modified:
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/MultiReader.java
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/ParallelReader.java

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/MultiReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/MultiReader.java?rev=1212787&r1=1212786&r2=1212787&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/MultiReader.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/MultiReader.java Sat Dec 10 13:01:51 2011
@@ -88,54 +88,22 @@ public class MultiReader extends IndexRe
     readerFinishedListeners = new MapBackedSet<ReaderFinishedListener>(new ConcurrentHashMap<ReaderFinishedListener,Boolean>());
   }
   
-  /**
-   * Tries to reopen the subreaders.
-   * <br>
-   * If one or more subreaders could be re-opened (i. e. IndexReader.openIfChanged(subReader) 
-   * returned a new instance), then a new MultiReader instance 
-   * is returned, otherwise this instance is returned.
-   * <p>
-   * A re-opened instance might share one or more subreaders with the old 
-   * instance. Index modification operations result in undefined behavior
-   * when performed before the old instance is closed.
-   * (see {@link IndexReader#openIfChanged}).
-   * <p>
-   * If subreaders are shared, then the reference count of those
-   * readers is increased to ensure that the subreaders remain open
-   * until the last referring reader is closed.
-   * 
-   * @throws CorruptIndexException if the index is corrupt
-   * @throws IOException if there is a low-level IO error 
-   */
   @Override
   protected synchronized IndexReader doOpenIfChanged() throws CorruptIndexException, IOException {
     return doReopen(false);
   }
   
   /**
-   * If the index has changed since it was opened, open and return a new reader;
-   * else, return {@code null}.
-   * 
-   * @see #openIfChanged(IndexReader, boolean)
+   * @throws UnsupportedOperationException MultiReaders cannot support changing the readOnly flag
    * @deprecated Write support will be removed in Lucene 4.0.
-   * Use {@link #doOpenIfChanged()} instead
+   * Use {@link #doOpenIfChanged()} instead.
    */
   @Deprecated @Override
   protected IndexReader doOpenIfChanged(boolean openReadOnly) throws CorruptIndexException, IOException {
-    if (!openReadOnly)
-      throw new UnsupportedOperationException("MultiReader does not support reopening in read/write mode");
-    return doReopen(false);
+    throw new UnsupportedOperationException("MultiReader does not support reopening with changing readOnly flag. "+
+      "Use IndexReader.openIfChanged(IndexReader) instead.");
   }
 
-  /**
-   * Clones the subreaders.
-   * (see {@link IndexReader#clone()}).
-   * <br>
-   * <p>
-   * If subreaders are shared, then the reference count of those
-   * readers is increased to ensure that the subreaders remain open
-   * until the last referring reader is closed.
-   */
   @Override
   public synchronized Object clone() {
     try {
@@ -146,6 +114,17 @@ public class MultiReader extends IndexRe
   }
   
   /**
+   * @throws UnsupportedOperationException MultiReaders cannot support changing the readOnly flag
+   * @deprecated Write support will be removed in Lucene 4.0.
+   * Use {@link #clone()} instead.
+   */
+  @Override @Deprecated
+  public IndexReader clone(boolean openReadOnly) throws CorruptIndexException, IOException {
+    throw new UnsupportedOperationException("MultiReader does not support cloning with changing readOnly flag. "+
+      "Use IndexReader.clone() instead.");
+  }
+
+  /**
    * If clone is true then we clone each of the subreaders
    * @param doClone
    * @return New IndexReader, or null if open/clone is not necessary

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/ParallelReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/ParallelReader.java?rev=1212787&r1=1212786&r2=1212787&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/ParallelReader.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/ParallelReader.java Sat Dec 10 13:01:51 2011
@@ -140,8 +140,23 @@ public class ParallelReader extends Inde
   }
   
   @Override
+  protected synchronized IndexReader doOpenIfChanged() throws CorruptIndexException, IOException {
+    return doReopen(false);
+  }
+  
+  /**
+   * @throws UnsupportedOperationException ParallelReaders cannot support changing the readOnly flag
+   * @deprecated Write support will be removed in Lucene 4.0.
+   * Use {@link #doOpenIfChanged()} instead.
+   */
+  @Deprecated @Override
+  protected IndexReader doOpenIfChanged(boolean openReadOnly) throws CorruptIndexException, IOException {
+    throw new UnsupportedOperationException("ParallelReader does not support reopening with changing readOnly flag. "+
+      "Use IndexReader.openIfChanged(IndexReader) instead.");
+  }
+
+  @Override
   public synchronized Object clone() {
-    // doReopen calls ensureOpen
     try {
       return doReopen(true);
     } catch (Exception ex) {
@@ -150,43 +165,14 @@ public class ParallelReader extends Inde
   }
   
   /**
-   * Tries to reopen the subreaders.
-   * <br>
-   * If one or more subreaders could be re-opened (i. e. subReader.reopen() 
-   * returned a new instance != subReader), then a new ParallelReader instance 
-   * is returned, otherwise null is returned.
-   * <p>
-   * A re-opened instance might share one or more subreaders with the old 
-   * instance. Index modification operations result in undefined behavior
-   * when performed before the old instance is closed.
-   * (see {@link IndexReader#openIfChanged}).
-   * <p>
-   * If subreaders are shared, then the reference count of those
-   * readers is increased to ensure that the subreaders remain open
-   * until the last referring reader is closed.
-   * 
-   * @throws CorruptIndexException if the index is corrupt
-   * @throws IOException if there is a low-level IO error 
-   */
-  @Override
-  protected synchronized IndexReader doOpenIfChanged() throws CorruptIndexException, IOException {
-    // doReopen calls ensureOpen
-    return doReopen(false);
-  }
-  
-  /**
-   * If the index has changed since it was opened, open and return a new reader;
-   * else, return {@code null}.
-   * 
-   * @see #openIfChanged(IndexReader, boolean)
+   * @throws UnsupportedOperationException ParallelReaders cannot support changing the readOnly flag
    * @deprecated Write support will be removed in Lucene 4.0.
-   * Use {@link #doOpenIfChanged()} instead
+   * Use {@link #clone()} instead.
    */
-  @Deprecated @Override
-  protected IndexReader doOpenIfChanged(boolean openReadOnly) throws CorruptIndexException, IOException {
-    if (!openReadOnly)
-      throw new UnsupportedOperationException("ParallelReader does not support reopening in read/write mode");
-    return doReopen(false);
+  @Override @Deprecated
+  public IndexReader clone(boolean openReadOnly) throws CorruptIndexException, IOException {
+    throw new UnsupportedOperationException("ParallelReader does not support cloning with changing readOnly flag. "+
+      "Use IndexReader.clone() instead.");
   }
 
   private IndexReader doReopen(boolean doClone) throws CorruptIndexException, IOException {