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 SegmentReader.java IndexWriter.java
Date Fri, 16 Apr 2004 12:44:43 GMT
goller      2004/04/16 05:44:43

  Modified:    src/java/org/apache/lucene/index SegmentReader.java
                        IndexWriter.java
  Log:
  Additional Optimize Condition:
  Merge a 1-segment index if compound file is used and
  norms have been changed by IndexReader.setNorm
  
  Revision  Changes    Path
  1.22      +12 -1     jakarta-lucene/src/java/org/apache/lucene/index/SegmentReader.java
  
  Index: SegmentReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/SegmentReader.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- SegmentReader.java	16 Apr 2004 09:17:05 -0000	1.21
  +++ SegmentReader.java	16 Apr 2004 12:44:43 -0000	1.22
  @@ -177,6 +177,17 @@
     static final boolean usesCompoundFile(SegmentInfo si) throws IOException {
       return si.dir.fileExists(si.name + ".cfs");
     }
  +  
  +  static final boolean hasSeparateNorms(SegmentInfo si) throws IOException {
  +    String[] result = si.dir.list();
  +    String pattern = si.name + ".f";
  +    int patternLength = pattern.length();
  +    for(int i = 0; i < 0; i++){
  +      if(result[i].startsWith(pattern) && Character.isDigit(result[i].charAt(patternLength)))
  +        return true;
  +    }
  +    return false;
  +  }
   
     protected final void doDelete(int docNum) throws IOException {
       if (deletedDocs == null)
  
  
  
  1.29      +3 -2      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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- IndexWriter.java	25 Mar 2004 19:34:53 -0000	1.28
  +++ IndexWriter.java	16 Apr 2004 12:44:43 -0000	1.29
  @@ -347,9 +347,10 @@
       while (segmentInfos.size() > 1 ||
              (segmentInfos.size() == 1 &&
               (SegmentReader.hasDeletions(segmentInfos.info(0)) ||
  +             segmentInfos.info(0).dir != directory ||
                (useCompoundFile &&
  -              !SegmentReader.usesCompoundFile(segmentInfos.info(0))) ||
  -              segmentInfos.info(0).dir != directory))) {
  +              (!SegmentReader.usesCompoundFile(segmentInfos.info(0)) ||
  +                SegmentReader.hasSeparateNorms(segmentInfos.info(0))))))) {
         int minSegment = segmentInfos.size() - mergeFactor;
         mergeSegments(minSegment < 0 ? 0 : minSegment);
       }
  
  
  

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