lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject svn commit: r431153 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/index/IndexWriter.java
Date Sun, 13 Aug 2006 08:20:13 GMT
Author: otis
Date: Sun Aug 13 01:20:13 2006
New Revision: 431153

URL: http://svn.apache.org/viewvc?rev=431153&view=rev
Log:
- LUCENE-388: optimize maybeMergeSegments() to speed up indexing.

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=431153&r1=431152&r2=431153&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Sun Aug 13 01:20:13 2006
@@ -121,6 +121,9 @@
      during segment merges (e.g. during indexing or optimizing), thus improving
      performance . (Michael Busch via Otis Gospodnetic)
 
+  4. LUCENE-388: Changes to maybeMergeSegments() to improve indexing speed.
+     (Paul Smith via Otis Gospodnetic)
+
 Release 2.0.0 2006-05-26
 
 API Changes

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java?rev=431153&r1=431152&r2=431153&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java Sun Aug 13 01:20:13
2006
@@ -110,6 +110,7 @@
   private SegmentInfos segmentInfos = new SegmentInfos(); // the segments
   private final Directory ramDirectory = new RAMDirectory(); // for temp segs
 
+  private long bufferedDocCount = 0;
   private Lock writeLock;
 
   private int termIndexInterval = DEFAULT_TERM_INDEX_INTERVAL;
@@ -509,6 +510,7 @@
     dw.addDocument(segmentName, doc);
     synchronized (this) {
       segmentInfos.addElement(new SegmentInfo(segmentName, 1, ramDirectory));
+      bufferedDocCount++;
       maybeMergeSegments();
     }
   }
@@ -691,6 +693,15 @@
 
   /** Incremental segment merger.  */
   private final void maybeMergeSegments() throws IOException {
+    /**
+     *  do not bother checking the segment details to determine
+     *  if we should merge, but instead honour the maxBufferedDocs(minMergeDocs)
+     *  property to ensure we do not spend time checking for merge conditions
+     *  
+     */
+    if(bufferedDocCount<minMergeDocs) {
+        return;
+    }
     long targetMergeDocs = minMergeDocs;
     while (targetMergeDocs <= maxMergeDocs) {
       // find segments smaller than current target size
@@ -741,6 +752,8 @@
 
     int mergedDocCount = merger.merge();
 
+    bufferedDocCount -= mergedDocCount; // update bookkeeping about how many docs we have
buffered
+    
     if (infoStream != null) {
       infoStream.println(" into "+mergedName+" ("+mergedDocCount+" docs)");
     }



Mime
View raw message