lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r799816 - in /lucene/java/branches/lucene_2_4_back_compat_tests/src: java/org/apache/lucene/index/ test/org/apache/lucene/index/
Date Sat, 01 Aug 2009 09:20:15 GMT
Author: mikemccand
Date: Sat Aug  1 09:20:12 2009
New Revision: 799816

URL: http://svn.apache.org/viewvc?rev=799816&view=rev
Log:
LUCENE-1763: require IndexWriter be passed up front to the MergePolicy

Modified:
    lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogByteSizeMergePolicy.java
    lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogDocMergePolicy.java
    lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogMergePolicy.java
    lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/MergePolicy.java
    lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java
    lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
    lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
    lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriter.java
    lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/IndexWriter.java?rev=799816&r1=799815&r2=799816&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/IndexWriter.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/IndexWriter.java
Sat Aug  1 09:20:12 2009
@@ -351,7 +351,7 @@
   // merges
   private HashSet mergingSegments = new HashSet();
 
-  private MergePolicy mergePolicy = new LogByteSizeMergePolicy();
+  private MergePolicy mergePolicy = new LogByteSizeMergePolicy(this);
   private MergeScheduler mergeScheduler = new ConcurrentMergeScheduler();
   private LinkedList pendingMerges = new LinkedList();
   private Set runningMerges = new HashSet();
@@ -2504,7 +2504,7 @@
     MergePolicy.MergeSpecification spec;
 
     synchronized(this) {
-      spec = mergePolicy.findMergesToExpungeDeletes(segmentInfos, this);
+      spec = mergePolicy.findMergesToExpungeDeletes(segmentInfos);
       if (spec != null) {
         final int numMerges = spec.merges.size();
         for(int i=0;i<numMerges;i++)
@@ -2610,7 +2610,7 @@
 
     final MergePolicy.MergeSpecification spec;
     if (optimize) {
-      spec = mergePolicy.findMergesForOptimize(segmentInfos, this, maxNumSegmentsOptimize,
segmentsToOptimize);
+      spec = mergePolicy.findMergesForOptimize(segmentInfos, maxNumSegmentsOptimize, segmentsToOptimize);
 
       if (spec != null) {
         final int numMerges = spec.merges.size();
@@ -2622,7 +2622,7 @@
       }
 
     } else
-      spec = mergePolicy.findMerges(segmentInfos, this);
+      spec = mergePolicy.findMerges(segmentInfos);
 
     if (spec != null) {
       final int numMerges = spec.merges.size();

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogByteSizeMergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogByteSizeMergePolicy.java?rev=799816&r1=799815&r2=799816&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogByteSizeMergePolicy.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogByteSizeMergePolicy.java
Sat Aug  1 09:20:12 2009
@@ -30,8 +30,8 @@
    *  or larger will never be merged.  @see setMaxMergeMB */
   public static final double DEFAULT_MAX_MERGE_MB = (double) Long.MAX_VALUE;
 
-  public LogByteSizeMergePolicy() {
-    super();
+  public LogByteSizeMergePolicy(IndexWriter writer) {
+    super(writer);
     minMergeSize = (long) (DEFAULT_MIN_MERGE_MB*1024*1024);
     maxMergeSize = (long) (DEFAULT_MAX_MERGE_MB*1024*1024);
   }

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogDocMergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogDocMergePolicy.java?rev=799816&r1=799815&r2=799816&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogDocMergePolicy.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogDocMergePolicy.java
Sat Aug  1 09:20:12 2009
@@ -26,8 +26,8 @@
   /** Default minimum segment size.  @see setMinMergeDocs */
   public static final int DEFAULT_MIN_MERGE_DOCS = 1000;
 
-  public LogDocMergePolicy() {
-    super();
+  public LogDocMergePolicy(IndexWriter writer) {
+    super(writer);
     minMergeSize = DEFAULT_MIN_MERGE_DOCS;
 
     // maxMergeSize is never used by LogDocMergePolicy; set

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogMergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogMergePolicy.java?rev=799816&r1=799815&r2=799816&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogMergePolicy.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/LogMergePolicy.java
Sat Aug  1 09:20:12 2009
@@ -61,8 +61,11 @@
 
   private boolean useCompoundFile = true;
   private boolean useCompoundDocStore = true;
-  private IndexWriter writer;
 
+  public LogMergePolicy(IndexWriter writer) {
+    super(writer);
+  }
+  
   private void message(String message) {
     if (writer != null)
       writer.message("LMP: " + message);
@@ -132,7 +135,7 @@
 
   abstract protected long size(SegmentInfo info) throws IOException;
 
-  private boolean isOptimized(SegmentInfos infos, IndexWriter writer, int maxNumSegments,
Set segmentsToOptimize) throws IOException {
+  private boolean isOptimized(SegmentInfos infos, int maxNumSegments, Set segmentsToOptimize)
throws IOException {
     final int numSegments = infos.size();
     int numToOptimize = 0;
     SegmentInfo optimizeInfo = null;
@@ -145,13 +148,13 @@
     }
 
     return numToOptimize <= maxNumSegments &&
-      (numToOptimize != 1 || isOptimized(writer, optimizeInfo));
+      (numToOptimize != 1 || isOptimized(optimizeInfo));
   }
 
   /** Returns true if this single nfo is optimized (has no
    *  pending norms or deletes, is in the same dir as the
    *  writer, and matches the current compound file setting */
-  private boolean isOptimized(IndexWriter writer, SegmentInfo info)
+  private boolean isOptimized(SegmentInfo info)
     throws IOException {
     return !info.hasDeletions() &&
       !info.hasSeparateNorms() &&
@@ -167,12 +170,12 @@
    *  setting is true.  This method returns multiple merges
    *  (mergeFactor at a time) so the {@link MergeScheduler}
    *  in use may make use of concurrency. */
-  public MergeSpecification findMergesForOptimize(SegmentInfos infos, IndexWriter writer,
int maxNumSegments, Set segmentsToOptimize) throws IOException {
+  public MergeSpecification findMergesForOptimize(SegmentInfos infos, int maxNumSegments,
Set segmentsToOptimize) throws IOException {
     MergeSpecification spec;
 
     assert maxNumSegments > 0;
 
-    if (!isOptimized(infos, writer, maxNumSegments, segmentsToOptimize)) {
+    if (!isOptimized(infos, maxNumSegments, segmentsToOptimize)) {
 
       // Find the newest (rightmost) segment that needs to
       // be optimized (other segments may have been flushed
@@ -204,7 +207,7 @@
 
             // Since we must optimize down to 1 segment, the
             // choice is simple:
-            if (last > 1 || !isOptimized(writer, infos.info(0)))
+            if (last > 1 || !isOptimized(infos.info(0)))
               spec.add(new OneMerge(infos.range(0, last), useCompoundFile));
           } else if (last > maxNumSegments) {
 
@@ -250,11 +253,8 @@
    * index.  We simply merge adjacent segments that have
    * deletes, up to mergeFactor at a time.
    */ 
-  public MergeSpecification findMergesToExpungeDeletes(SegmentInfos segmentInfos,
-                                                       IndexWriter writer)
-    throws CorruptIndexException, IOException
-  {
-    this.writer = writer;
+  public MergeSpecification findMergesToExpungeDeletes(SegmentInfos segmentInfos)
+    throws CorruptIndexException, IOException {
 
     final int numSegments = segmentInfos.size();
 
@@ -300,11 +300,9 @@
    *  multiple levels have too many segments, this method
    *  will return multiple merges, allowing the {@link
    *  MergeScheduler} to use concurrency. */
-  public MergeSpecification findMerges(SegmentInfos infos, IndexWriter writer) throws IOException
{
+  public MergeSpecification findMerges(SegmentInfos infos) throws IOException {
 
     final int numSegments = infos.size();
-    this.writer = writer;
-    message("findMerges: " + numSegments + " segments");
 
     // Compute levels, which is just log (base mergeFactor)
     // of the size of each segment

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/MergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/MergePolicy.java?rev=799816&r1=799815&r2=799816&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/MergePolicy.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/MergePolicy.java
Sat Aug  1 09:20:12 2009
@@ -196,6 +196,12 @@
     }
   }
 
+  protected IndexWriter writer;
+  
+  public MergePolicy(IndexWriter writer) {
+    this.writer = writer;
+  }
+  
   /**
    * Determine what set of merge operations are now
    * necessary on the index.  The IndexWriter calls this
@@ -204,10 +210,8 @@
    * only one thread at a time will call this method.
    *
    * @param segmentInfos the total set of segments in the index
-   * @param writer IndexWriter instance
    */
-  abstract MergeSpecification findMerges(SegmentInfos segmentInfos,
-                                         IndexWriter writer)
+  public abstract MergeSpecification findMerges(SegmentInfos segmentInfos)
     throws CorruptIndexException, IOException;
 
   /**
@@ -218,15 +222,13 @@
    * only one thread at a time will call this method.
    *
    * @param segmentInfos the total set of segments in the index
-   * @param writer IndexWriter instance
    * @param maxSegmentCount requested maximum number of
    *   segments in the index (currently this is always 1)
    * @param segmentsToOptimize contains the specific
    *   SegmentInfo instances that must be merged away.  This
    *   may be a subset of all SegmentInfos.
    */
-  abstract MergeSpecification findMergesForOptimize(SegmentInfos segmentInfos,
-                                                    IndexWriter writer,
+  public abstract MergeSpecification findMergesForOptimize(SegmentInfos segmentInfos,
                                                     int maxSegmentCount,
                                                     Set segmentsToOptimize)
     throws CorruptIndexException, IOException;
@@ -235,29 +237,24 @@
    * Determine what set of merge operations is necessary in
    * order to expunge all deletes from the index.
    * @param segmentInfos the total set of segments in the index
-   * @param writer IndexWriter instance
    */
-  MergeSpecification findMergesToExpungeDeletes(SegmentInfos segmentInfos,
-                                                 IndexWriter writer)
-    throws CorruptIndexException, IOException
-  {
-    throw new RuntimeException("not implemented");
-  }
+  public abstract MergeSpecification findMergesToExpungeDeletes(SegmentInfos segmentInfos)
+    throws CorruptIndexException, IOException;
 
   /**
    * Release all resources for the policy.
    */
-  abstract void close();
+  public abstract void close();
 
   /**
    * Returns true if a newly flushed (not from merge)
    * segment should use the compound file format.
    */
-  abstract boolean useCompoundFile(SegmentInfos segments, SegmentInfo newSegment);
+  public abstract boolean useCompoundFile(SegmentInfos segments, SegmentInfo newSegment);
 
   /**
    * Returns true if the doc store files should use the
    * compound file format.
    */
-  abstract boolean useCompoundDocStore(SegmentInfos segments);
+  public abstract boolean useCompoundDocStore(SegmentInfos segments);
 }

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java?rev=799816&r1=799815&r2=799816&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java
Sat Aug  1 09:20:12 2009
@@ -426,7 +426,7 @@
   private IndexWriter newWriter(Directory dir, boolean create)
       throws IOException {
     final IndexWriter writer = new IndexWriter(dir, true, new WhitespaceAnalyzer(), create);
-    writer.setMergePolicy(new LogDocMergePolicy());
+    writer.setMergePolicy(new LogDocMergePolicy(writer));
     return writer;
   }
 
@@ -500,7 +500,7 @@
 
     Directory dir = new MockRAMDirectory();
     IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
-    writer.setMergePolicy(new LogByteSizeMergePolicy());
+    writer.setMergePolicy(new LogByteSizeMergePolicy(writer));
     writer.setMaxBufferedDocs(5);
     writer.setUseCompoundFile(false);
     writer.setMergeFactor(100);
@@ -526,7 +526,7 @@
 
     Directory dir2 = new MockRAMDirectory();
     writer = new IndexWriter(dir2, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
-    LogByteSizeMergePolicy lmp = new LogByteSizeMergePolicy();
+    LogByteSizeMergePolicy lmp = new LogByteSizeMergePolicy(writer);
     lmp.setMinMergeMB(0.0001);
     writer.setMergePolicy(lmp);
     writer.setMergeFactor(4);

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java?rev=799816&r1=799815&r2=799816&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
Sat Aug  1 09:20:12 2009
@@ -104,7 +104,7 @@
     ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();
     writer.setMergeScheduler(cms);
 
-    LogDocMergePolicy mp = new LogDocMergePolicy();
+    LogDocMergePolicy mp = new LogDocMergePolicy(writer);
     writer.setMergePolicy(mp);
 
     // Force degenerate merging so we can get a mix of

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=799816&r1=799815&r2=799816&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
Sat Aug  1 09:20:12 2009
@@ -859,7 +859,7 @@
   private static void createIndex(Directory dir, boolean multiSegment) throws IOException
{
     IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
     
-    w.setMergePolicy(new LogDocMergePolicy());
+    w.setMergePolicy(new LogDocMergePolicy(w));
     
     for (int i = 0; i < 100; i++) {
       w.addDocument(createDocument(i, 4));

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=799816&r1=799815&r2=799816&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriter.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriter.java
Sat Aug  1 09:20:12 2009
@@ -623,7 +623,7 @@
 
       for(int numDocs=38;numDocs<500;numDocs += 38) {
         IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
-        LogDocMergePolicy ldmp = new LogDocMergePolicy();
+        LogDocMergePolicy ldmp = new LogDocMergePolicy(writer);
         ldmp.setMinMergeDocs(1);
         writer.setMergePolicy(ldmp);
         writer.setMergeFactor(5);
@@ -660,7 +660,7 @@
       doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED));
 
       IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
-      LogDocMergePolicy ldmp = new LogDocMergePolicy();
+      LogDocMergePolicy ldmp = new LogDocMergePolicy(writer);
       ldmp.setMinMergeDocs(1);
       writer.setMergePolicy(ldmp);
       writer.setMergeFactor(4);
@@ -2864,7 +2864,7 @@
       writer.setMaxBufferedDocs(2);
       writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
       writer.setMergeScheduler(new SerialMergeScheduler());
-      writer.setMergePolicy(new LogDocMergePolicy());
+      writer.setMergePolicy(new LogDocMergePolicy(writer));
 
       Document document = new Document();
 
@@ -2897,7 +2897,7 @@
       writer.setMaxBufferedDocs(2);
       writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
       writer.setMergeScheduler(new SerialMergeScheduler());
-      writer.setMergePolicy(new LogDocMergePolicy());
+      writer.setMergePolicy(new LogDocMergePolicy(writer));
 
       Directory[] indexDirs = {new MockRAMDirectory(dir)};
       writer.addIndexes(indexDirs);
@@ -2916,7 +2916,7 @@
       writer.setMaxBufferedDocs(2);
       writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
       writer.setMergeScheduler(new SerialMergeScheduler());
-      writer.setMergePolicy(new LogDocMergePolicy());
+      writer.setMergePolicy(new LogDocMergePolicy(writer));
 
       Document document = new Document();
 
@@ -2954,7 +2954,7 @@
     writer.setMaxBufferedDocs(2);
     writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
     writer.setMergeScheduler(new SerialMergeScheduler());
-    writer.setMergePolicy(new LogDocMergePolicy());
+    writer.setMergePolicy(new LogDocMergePolicy(writer));
 
     Document document = new Document();
 
@@ -2976,7 +2976,7 @@
     writer.setMaxBufferedDocs(2);
     writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
     writer.setMergeScheduler(new SerialMergeScheduler());
-    writer.setMergePolicy(new LogDocMergePolicy());
+    writer.setMergePolicy(new LogDocMergePolicy(writer));
     for(int i=0;i<6;i++)
       writer.addDocument(document);
 

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java?rev=799816&r1=799815&r2=799816&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
Sat Aug  1 09:20:12 2009
@@ -37,7 +37,7 @@
     IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
     writer.setMaxBufferedDocs(10);
     writer.setMergeFactor(10);
-    writer.setMergePolicy(new LogDocMergePolicy());
+    writer.setMergePolicy(new LogDocMergePolicy(writer));
 
     for (int i = 0; i < 100; i++) {
       addDoc(writer);
@@ -54,7 +54,7 @@
     IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
     writer.setMaxBufferedDocs(10);
     writer.setMergeFactor(10);
-    writer.setMergePolicy(new LogDocMergePolicy());
+    writer.setMergePolicy(new LogDocMergePolicy(writer));
 
     boolean noOverMerge = false;
     for (int i = 0; i < 100; i++) {
@@ -76,7 +76,7 @@
     IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
     writer.setMaxBufferedDocs(10);
     writer.setMergeFactor(10);
-    LogDocMergePolicy mp = new LogDocMergePolicy();
+    LogDocMergePolicy mp = new LogDocMergePolicy(writer);
     mp.setMinMergeDocs(100);
     writer.setMergePolicy(mp);
 
@@ -102,7 +102,7 @@
     IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
     writer.setMaxBufferedDocs(10);
     writer.setMergeFactor(100);
-    writer.setMergePolicy(new LogDocMergePolicy());
+    writer.setMergePolicy(new LogDocMergePolicy(writer));
 
     for (int i = 0; i < 250; i++) {
       addDoc(writer);
@@ -128,7 +128,7 @@
     IndexWriter writer = new IndexWriter(dir, true, new WhitespaceAnalyzer(), true);
     writer.setMaxBufferedDocs(101);
     writer.setMergeFactor(101);
-    writer.setMergePolicy(new LogDocMergePolicy());
+    writer.setMergePolicy(new LogDocMergePolicy(writer));
 
     // leftmost* segment has 1 doc
     // rightmost* segment has 100 docs
@@ -142,7 +142,7 @@
       writer = new IndexWriter(dir, true, new WhitespaceAnalyzer(), false);
       writer.setMaxBufferedDocs(101);
       writer.setMergeFactor(101);
-      writer.setMergePolicy(new LogDocMergePolicy());
+      writer.setMergePolicy(new LogDocMergePolicy(writer));
     }
 
     writer.setMaxBufferedDocs(10);
@@ -168,7 +168,7 @@
     Directory dir = new RAMDirectory();
 
     IndexWriter writer = new IndexWriter(dir, true, new WhitespaceAnalyzer(), true);
-    writer.setMergePolicy(new LogDocMergePolicy());
+    writer.setMergePolicy(new LogDocMergePolicy(writer));
     writer.setMaxBufferedDocs(10);
     writer.setMergeFactor(100);
 
@@ -183,7 +183,7 @@
     reader.close();
 
     writer = new IndexWriter(dir, true, new WhitespaceAnalyzer(), false);
-    writer.setMergePolicy(new LogDocMergePolicy());
+    writer.setMergePolicy(new LogDocMergePolicy(writer));
     writer.setMaxBufferedDocs(10);
     writer.setMergeFactor(5);
 



Mime
View raw message