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 SegmentMerger.java
Date Fri, 31 Oct 2003 09:28:44 GMT
goller      2003/10/31 01:28:44

  Modified:    src/java/org/apache/lucene/index SegmentMerger.java
  Log:
  docCount was computed incorrectly by merge causing
  problems during indexing together with my last change in
  IndexWriter.
  
  Revision  Changes    Path
  1.6       +10 -10    jakarta-lucene/src/java/org/apache/lucene/index/SegmentMerger.java
  
  Index: SegmentMerger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/SegmentMerger.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SegmentMerger.java	21 Oct 2003 17:59:16 -0000	1.5
  +++ SegmentMerger.java	31 Oct 2003 09:28:44 -0000	1.6
  @@ -94,10 +94,9 @@
     final int merge() throws IOException {
       int value;
       try {
  -      mergeFields();
  +      value = mergeFields();
         mergeTerms();
  -      value = mergeNorms();
  -      
  +      mergeNorms();
       } finally {
         for (int i = 0; i < readers.size(); i++) {  // close readers
   	IndexReader reader = (IndexReader)readers.elementAt(i);
  @@ -149,8 +148,9 @@
     }
     
     
  -  private final void mergeFields() throws IOException {
  +  private final int mergeFields() throws IOException {
       fieldInfos = new FieldInfos();		  // merge field names
  +    int docCount = 0;
       for (int i = 0; i < readers.size(); i++) {
         IndexReader reader = (IndexReader)readers.elementAt(i);
         fieldInfos.add(reader.getFieldNames(true), true);
  @@ -165,12 +165,15 @@
   	IndexReader reader = (IndexReader)readers.elementAt(i);
   	int maxDoc = reader.maxDoc();
   	for (int j = 0; j < maxDoc; j++)
  -	  if (!reader.isDeleted(j))               // skip deleted docs
  -	    fieldsWriter.addDocument(reader.document(j));
  +	  if (!reader.isDeleted(j)){               // skip deleted docs
  +            fieldsWriter.addDocument(reader.document(j));
  +            docCount++;
  +	  }
         }
       } finally {
         fieldsWriter.close();
       }
  +    return docCount;
     }
   
     private OutputStream freqOutput = null;
  @@ -292,8 +295,7 @@
       }
       return df;
     }
  -  private final int mergeNorms() throws IOException {
  -    int docCount = 0;
  +  private final void mergeNorms() throws IOException {
       for (int i = 0; i < fieldInfos.size(); i++) {
         FieldInfo fi = fieldInfos.fieldInfo(i);
         if (fi.isIndexed) {
  @@ -307,7 +309,6 @@
                 byte norm = input != null ? input[k] : (byte)0;
                 if (!reader.isDeleted(k)) {
                   output.writeByte(norm);
  -                docCount++;
                 }
   	    }
   	  }
  @@ -316,7 +317,6 @@
   	}
         }
       }
  -    return docCount;
     }
   
   }
  
  
  

---------------------------------------------------------------------
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