lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/index IndexWriter.java
Date Tue, 29 Jan 2002 16:30:16 GMT
cutting     02/01/29 08:30:16

  Modified:    src/java/org/apache/lucene/index IndexWriter.java
  Log:
  Fixed to never delete added indexes.
  
  Revision  Changes    Path
  1.5       +4 -17     jakarta-lucene/src/java/org/apache/lucene/index/IndexWriter.java
  
  Index: IndexWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/IndexWriter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IndexWriter.java	28 Jan 2002 11:39:02 -0000	1.4
  +++ IndexWriter.java	29 Jan 2002 16:30:16 -0000	1.5
  @@ -225,19 +225,11 @@
     public final synchronized void addIndexes(Directory[] dirs)
         throws IOException {
       optimize();					  // start with zero or 1 seg
  -    int minSegment = segmentInfos.size();
  -    int segmentsAddedSinceMerge = 0;
       for (int i = 0; i < dirs.length; i++) {
         SegmentInfos sis = new SegmentInfos();	  // read infos from dir
         sis.read(dirs[i]);
         for (int j = 0; j < sis.size(); j++) {
   	segmentInfos.addElement(sis.info(j));	  // add each info
  -
  -	// merge whenever mergeFactor segments have been added
  -	if (++segmentsAddedSinceMerge == mergeFactor) {
  -	  mergeSegments(minSegment++, false);
  -	  segmentsAddedSinceMerge = 0;
  -	}
         }
       }
       optimize();					  // final cleanup
  @@ -286,13 +278,7 @@
   
     /** Pops segments off of segmentInfos stack down to minSegment, merges them,
       and pushes the merged index onto the top of the segmentInfos stack. */
  -  private final void mergeSegments(int minSegment) throws IOException {
  -    mergeSegments(minSegment, true);
  -  }
  -
  -  /** Pops segments off of segmentInfos stack down to minSegment, merges them,
  -    and pushes the merged index onto the top of the segmentInfos stack. */
  -  private final void mergeSegments(int minSegment, boolean delete)
  +  private final void mergeSegments(int minSegment)
         throws IOException {
       String mergedName = newSegmentName();
       int mergedDocCount = 0;
  @@ -305,8 +291,9 @@
   	infoStream.print(" " + si.name + " (" + si.docCount + " docs)");
         SegmentReader reader = new SegmentReader(si);
         merger.add(reader);
  -      if (delete)
  -	segmentsToDelete.addElement(reader);	  // queue for deletion
  +      if ((reader.directory == this.directory) || // if we own the directory
  +          (reader.directory == this.ramDirectory))
  +	segmentsToDelete.addElement(reader);	  // queue segment for deletion
         mergedDocCount += si.docCount;
       }
       if (infoStream != null) {
  
  
  

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


Mime
View raw message