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/05/13 12:50:51 UTC

svn commit: r1102659 - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/backwards/ lucene/src/java/org/apache/lucene/index/IndexUpgrader.java lucene/src/java/org/apache/lucene/index/UpgradeIndexMergePolicy.java solr/

Author: uschindler
Date: Fri May 13 10:50:51 2011
New Revision: 1102659

URL: http://svn.apache.org/viewvc?rev=1102659&view=rev
Log:
LUCENE-3082: Fix javadocs and add Version parameter to ctor

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/lucene/backwards/   (props changed)
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexUpgrader.java
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/UpgradeIndexMergePolicy.java
    lucene/dev/branches/branch_3x/solr/   (props changed)

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexUpgrader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexUpgrader.java?rev=1102659&r1=1102658&r2=1102659&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexUpgrader.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexUpgrader.java Fri May 13 10:50:51 2011
@@ -40,7 +40,13 @@ import java.util.Collection;
   * refuses to run by default. Specify {@code -delete-prior-commits}
   * to override this, allowing the tool to delete all but the last commit.
   * From Java code this can be enabled by passing {@code true} to
-  * {@link #IndexUpgrader(Directory,PrintStream,boolean)}.
+  * {@link #IndexUpgrader(Directory,Version,PrintStream,boolean)}.
+  * <p><b>Warning:</b> This tool may reorder documents if the index was partially
+  * upgraded before execution (e.g., documents were added). If your application relies
+  * on &quot;monotonicity&quot; of doc IDs (which means that the order in which the documents
+  * were added to the index is preserved), do a full optimize instead.
+  * The {@link MergePolicy} set by {@link IndexWriterConfig} may also reorder
+  * documents.
   */
 public final class IndexUpgrader {
 
@@ -52,9 +58,11 @@ public final class IndexUpgrader {
     System.err.println("reason, if the incoming index has more than one commit, the tool");
     System.err.println("refuses to run by default. Specify -delete-prior-commits to override");
     System.err.println("this, allowing the tool to delete all but the last commit.");
+    System.err.println("WARNING: This tool may reorder document IDs!");
     System.exit(1);
   }
 
+  @SuppressWarnings("deprecation")
   public static void main(String[] args) throws IOException {
     String dir = null;
     boolean deletePriorCommits = false;
@@ -74,7 +82,7 @@ public final class IndexUpgrader {
       printUsage();
     }
     
-    new IndexUpgrader(FSDirectory.open(new File(dir)), out, deletePriorCommits).upgrade();
+    new IndexUpgrader(FSDirectory.open(new File(dir)), Version.LUCENE_CURRENT, out, deletePriorCommits).upgrade();
   }
   
   private final Directory dir;
@@ -82,16 +90,22 @@ public final class IndexUpgrader {
   private final IndexWriterConfig iwc;
   private final boolean deletePriorCommits;
   
-  @SuppressWarnings("deprecation")
-  public IndexUpgrader(Directory dir) {
-    this(dir, new IndexWriterConfig(Version.LUCENE_CURRENT, null), null, false);
-  }
-  
-  @SuppressWarnings("deprecation")
-  public IndexUpgrader(Directory dir, PrintStream infoStream, boolean deletePriorCommits) {
-    this(dir, new IndexWriterConfig(Version.LUCENE_CURRENT, null), infoStream, deletePriorCommits);
-  }
-  
+  /** Creates index upgrader on the given directory, using an {@link IndexWriter} using the given
+   * {@code matchVersion}. The tool refuses to upgrade indexes with multiple commit points. */
+  public IndexUpgrader(Directory dir, Version matchVersion) {
+    this(dir, new IndexWriterConfig(matchVersion, null), null, false);
+  }
+  
+  /** Creates index upgrader on the given directory, using an {@link IndexWriter} using the given
+   * {@code matchVersion}. You have the possibility to upgrade indexes with multiple commit points by removing
+   * all older ones. If {@code infoStream} is not {@code null}, all logging output will be sent to this stream. */
+  public IndexUpgrader(Directory dir, Version matchVersion, PrintStream infoStream, boolean deletePriorCommits) {
+    this(dir, new IndexWriterConfig(matchVersion, null), infoStream, deletePriorCommits);
+  }
+  
+  /** Creates index upgrader on the given directory, using an {@link IndexWriter} using the given
+   * config. You have the possibility to upgrade indexes with multiple commit points by removing
+   * all older ones. If {@code infoStream} is not {@code null}, all logging output will be sent to this stream. */
   public IndexUpgrader(Directory dir, IndexWriterConfig iwc, PrintStream infoStream, boolean deletePriorCommits) {
     this.dir = dir;
     this.iwc = iwc;

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/UpgradeIndexMergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/UpgradeIndexMergePolicy.java?rev=1102659&r1=1102658&r2=1102659&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/UpgradeIndexMergePolicy.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/UpgradeIndexMergePolicy.java Fri May 13 10:50:51 2011
@@ -40,6 +40,11 @@ import java.util.Set;
   *  w.optimize();
   *  w.close();
   * </pre>
+  * <p><b>Warning:</b> This merge policy may reorder documents if the index was partially
+  * upgraded before calling optimize (e.g., documents were added). If your application relies
+  * on &quot;monotonicity&quot; of doc IDs (which means that the order in which the documents
+  * were added to the index is preserved), do a full optimize instead. Please note, the
+  * delegate {@code MergePolicy} may also reorder documents.
   * @lucene.experimental
   * @see IndexUpgrader
   */