LUCENE-3619: check omitNorms on normswriter in case it changed while indexing

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1210469 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-12-05 14:15:58 +00:00
parent 961b820e53
commit e9d87fb1cf
2 changed files with 6 additions and 2 deletions

View File

@ -60,7 +60,9 @@ final class NormsWriter extends InvertedDocEndConsumer {
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 InvertedDocEndConsumer {
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 {

View File

@ -572,6 +572,7 @@ public class SegmentReader extends IndexReader implements Cloneable {
}
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 IndexReader implements Cloneable {
nextNormSeek += maxDoc; // increment also if some norms are separate
}
}
assert singleNormStream == null || !normsInitiallyEmpty || nextNormSeek == singleNormStream.length();
}
// for testing only