lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1210277 - in /lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index: SegmentInfo.java SegmentReader.java codecs/lucene40/Lucene40NormsReader.java
Date Sun, 04 Dec 2011 23:31:32 GMT
Author: rmuir
Date: Sun Dec  4 23:31:32 2011
New Revision: 1210277

URL: http://svn.apache.org/viewvc?rev=1210277&view=rev
Log:
LUCENE-3606: clean up more cruft

Modified:
    lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
    lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentInfo.java?rev=1210277&r1=1210276&r2=1210277&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
(original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
Sun Dec  4 23:31:32 2011
@@ -48,7 +48,7 @@ public final class SegmentInfo implement
   // TODO: remove these from this class, for now this is the representation
   public static final int NO = -1;          // e.g. no norms; no deletes;
   public static final int YES = 1;          // e.g. have norms; have deletes;
-  static final int WITHOUT_GEN = 0;  // a file name that has no GEN in it.
+  public static final int WITHOUT_GEN = 0;  // a file name that has no GEN in it.
 
   public String name;				  // unique name in dir
   public int docCount;				  // number of docs in seg
@@ -339,18 +339,6 @@ public final class SegmentInfo implement
   /**
    * @deprecated separate norms are not supported in >= 4.0
    */
-  public boolean hasSeparateNorms(int fieldNumber) {
-    if (normGen == null) {
-      return false;
-    }
-
-    Long gen = normGen.get(fieldNumber);
-    return gen != null && gen.longValue() != NO;
-  }
-
-  /**
-   * @deprecated separate norms are not supported in >= 4.0
-   */
   boolean hasSeparateNorms() {
     if (normGen == null) {
       return false;
@@ -365,42 +353,6 @@ public final class SegmentInfo implement
     return false;
   }
 
-  void initNormGen() {
-    if (normGen == null) { // normGen is null if this segments file hasn't had any norms
set against it yet
-      normGen = new HashMap<Integer, Long>();
-    }
-  }
-
-  /**
-   * Increment the generation count for the norms file for
-   * this field.
-   *
-   * @param fieldIndex field whose norm file will be rewritten
-   */
-  void advanceNormGen(int fieldIndex) {
-    Long gen = normGen.get(fieldIndex);
-    if (gen == null || gen.longValue() == NO) {
-      normGen.put(fieldIndex, new Long(YES));
-    } else {
-      normGen.put(fieldIndex, gen+1);
-    }
-    clearFilesCache();
-  }
-
-  /**
-   * Get the file name for the norms file for this field.
-   *
-   * @param number field index
-   */
-  public String getNormFileName(int number) {
-    if (hasSeparateNorms(number)) {
-      return IndexFileNames.fileNameFromGeneration(name, IndexFileNames.SEPARATE_NORMS_EXTENSION
+ number, normGen.get(number));
-    } else {
-      // single file for all norms
-      return IndexFileNames.fileNameFromGeneration(name, IndexFileNames.NORMS_EXTENSION,
WITHOUT_GEN);
-    }
-  }
-
   /**
    * Mark whether this segment is stored as a compound file.
    *

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentReader.java?rev=1210277&r1=1210276&r2=1210277&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentReader.java
(original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentReader.java
Sun Dec  4 23:31:32 2011
@@ -208,26 +208,16 @@ public class SegmentReader extends Index
     ensureOpen();
     boolean deletionsUpToDate = (this.si.hasDeletions() == si.hasDeletions()) 
                                   && (!si.hasDeletions() || this.si.getDelFileName().equals(si.getDelFileName()));
-    boolean normsUpToDate = true;
-    
-    Set<Integer> fieldNormsChanged = new HashSet<Integer>();
-    for (FieldInfo fi : core.fieldInfos) {
-      int fieldNumber = fi.number;
-      if (!this.si.getNormFileName(fieldNumber).equals(si.getNormFileName(fieldNumber)))
{
-        normsUpToDate = false;
-        fieldNormsChanged.add(fieldNumber);
-      }
-    }
 
     // if we're cloning we need to run through the reopenSegment logic
     // also if both old and new readers aren't readonly, we clone to avoid sharing modifications
-    if (normsUpToDate && deletionsUpToDate && !doClone && openReadOnly
&& readOnly) {
+    if (deletionsUpToDate && !doClone && openReadOnly && readOnly)
{
       return null;
     }    
 
     // When cloning, the incoming SegmentInfos should not
     // have any changes in it:
-    assert !doClone || (normsUpToDate && deletionsUpToDate);
+    assert !doClone || (deletionsUpToDate);
 
     // clone reader
     SegmentReader clone = new SegmentReader();

Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java?rev=1210277&r1=1210276&r2=1210277&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java
(original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/codecs/lucene40/Lucene40NormsReader.java
Sun Dec  4 23:31:32 2011
@@ -48,13 +48,15 @@ public class Lucene40NormsReader extends
   // but we just don't do any seeks or reading yet.
   public Lucene40NormsReader(Directory dir, SegmentInfo info, FieldInfos fields, IOContext
context, Directory separateNormsDir) throws IOException {
     maxdoc = info.docCount;
+    String segmentName = info.name;
+    Map<Integer,Long> normGen = info.getNormGen();
     boolean success = false;
     try {
       long nextNormSeek = Lucene40NormsWriter.NORMS_HEADER.length; //skip header (header
unused for now)
       for (FieldInfo fi : fields) {
         if (fi.isIndexed && !fi.omitNorms) {
-          String fileName = info.getNormFileName(fi.number);
-          Directory d = info.hasSeparateNorms(fi.number) ? separateNormsDir : dir;
+          String fileName = getNormFilename(segmentName, normGen, fi.number);
+          Directory d = hasSeparateNorms(normGen, fi.number) ? separateNormsDir : dir;
         
           // singleNormFile means multiple norms share this file
           boolean singleNormFile = IndexFileNames.matchesExtension(fileName, IndexFileNames.NORMS_EXTENSION);
@@ -127,6 +129,24 @@ public class Lucene40NormsReader extends
     }
   }
   
+  private static String getNormFilename(String segmentName, Map<Integer,Long> normGen,
int number) {
+    if (hasSeparateNorms(normGen, number)) {
+      return IndexFileNames.fileNameFromGeneration(segmentName, IndexFileNames.SEPARATE_NORMS_EXTENSION
+ number, normGen.get(number));
+    } else {
+      // single file for all norms
+      return IndexFileNames.fileNameFromGeneration(segmentName, IndexFileNames.NORMS_EXTENSION,
SegmentInfo.WITHOUT_GEN);
+    }
+  }
+  
+  private static boolean hasSeparateNorms(Map<Integer,Long> normGen, int number) {
+    if (normGen == null) {
+      return false;
+    }
+
+    Long gen = normGen.get(number);
+    return gen != null && gen.longValue() != SegmentInfo.NO;
+  }
+  
   class Norm {
     IndexInput file;
     long offset;



Mime
View raw message