lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1210469 - in /lucene/dev/trunk/lucene/src/java/org/apache/lucene/index: NormsWriter.java SegmentReader.java
Date Mon, 05 Dec 2011 14:15:59 GMT
Author: rmuir
Date: Mon Dec  5 14:15:58 2011
New Revision: 1210469

URL: http://svn.apache.org/viewvc?rev=1210469&view=rev
Log:
LUCENE-3619: check omitNorms on normswriter in case it changed while indexing

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/NormsWriter.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentReader.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/NormsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/NormsWriter.java?rev=1210469&r1=1210468&r2=1210469&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/NormsWriter.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/NormsWriter.java Mon Dec  5 14:15:58
2011
@@ -60,7 +60,9 @@ final class NormsWriter extends Inverted
       for (FieldInfo fi : state.fieldInfos) {
         final NormsWriterPerField toWrite = (NormsWriterPerField) fieldsToFlush.get(fi);
         int upto = 0;
-        if (toWrite != null && toWrite.upto > 0) {
+        // we must check the final value of omitNorms for the fieldinfo, it could have 
+        // changed for this field since the first time we added it.
+        if (!fi.omitNorms && toWrite != null && toWrite.upto > 0) {
           normCount++;
 
           int docID = 0;
@@ -84,7 +86,7 @@ final class NormsWriter extends Inverted
             normsOut.writeByte((byte) 0);
         }
 
-        assert 4+normCount*state.numDocs == normsOut.getFilePointer() : ".nrm file size mismatch:
expected=" + (4+normCount*state.numDocs) + " actual=" + normsOut.getFilePointer();
+        assert 4+normCount*(long)state.numDocs == normsOut.getFilePointer() : ".nrm file
size mismatch: expected=" + (4+normCount*(long)state.numDocs) + " actual=" + normsOut.getFilePointer();
       }
       success = true;
     } finally {

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentReader.java?rev=1210469&r1=1210468&r2=1210469&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentReader.java Mon Dec  5
14:15:58 2011
@@ -572,6 +572,7 @@ public class SegmentReader extends Index
   }
 
   private void openNorms(Directory cfsDir, IOContext context) throws IOException {
+    boolean normsInitiallyEmpty = norms.isEmpty(); // only used for assert
     long nextNormSeek = SegmentNorms.NORMS_HEADER.length; //skip header (header unused for
now)
     int maxDoc = maxDoc();
     for (FieldInfo fi : core.fieldInfos) {
@@ -625,6 +626,7 @@ public class SegmentReader extends Index
         nextNormSeek += maxDoc; // increment also if some norms are separate
       }
     }
+    assert singleNormStream == null || !normsInitiallyEmpty || nextNormSeek == singleNormStream.length();
   }
 
   // for testing only



Mime
View raw message