lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gol...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/index IndexWriter.java
Date Fri, 06 Aug 2004 12:21:24 GMT
goller      2004/08/06 05:21:24

  Modified:    src/java/org/apache/lucene/index IndexWriter.java
  Log:
  addIndexes(IndexReader[]): Delete segment of non-empty
  goal index an close its SegmentReader
  
  Revision  Changes    Path
  1.34      +13 -4     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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- IndexWriter.java	5 Aug 2004 18:00:13 -0000	1.33
  +++ IndexWriter.java	6 Aug 2004 12:21:24 -0000	1.34
  @@ -400,11 +400,16 @@
       optimize();					  // start with zero or 1 seg
   
       String mergedName = newSegmentName();
  -    SegmentMerger merger = new SegmentMerger(directory, mergedName, false);
  -
  -    if (segmentInfos.size() == 1)                 // add existing index, if any
  -      merger.add(new SegmentReader(segmentInfos.info(0)));
  +    SegmentMerger merger = new SegmentMerger(directory, mergedName, useCompoundFile);
   
  +    final Vector segmentsToDelete = new Vector();
  +    IndexReader sReader = null;
  +    if (segmentInfos.size() == 1){ // add existing index, if any
  +        sReader = new SegmentReader(segmentInfos.info(0));
  +        merger.add(sReader);
  +        segmentsToDelete.addElement(sReader);   // queue segment for deletion
  +    }
  +      
       for (int i = 0; i < readers.length; i++)      // add new indexes
         merger.add(readers[i]);
   
  @@ -412,11 +417,15 @@
   
       segmentInfos.setSize(0);                      // pop old infos & add new
       segmentInfos.addElement(new SegmentInfo(mergedName, docCount, directory));
  +    
  +    if(sReader != null)
  +        sReader.close();
   
       synchronized (directory) {			  // in- & inter-process sync
         new Lock.With(directory.makeLock("commit.lock"), COMMIT_LOCK_TIMEOUT) {
   	  public Object doBody() throws IOException {
   	    segmentInfos.write(directory);	  // commit changes
  +	    deleteSegments(segmentsToDelete);  // delete now-unused segments
   	    return null;
   	  }
   	}.run();
  
  
  

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


Mime
View raw message