mirror of https://github.com/apache/lucene.git
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:
parent
961b820e53
commit
e9d87fb1cf
|
@ -60,7 +60,9 @@ final class NormsWriter extends InvertedDocEndConsumer {
|
||||||
for (FieldInfo fi : state.fieldInfos) {
|
for (FieldInfo fi : state.fieldInfos) {
|
||||||
final NormsWriterPerField toWrite = (NormsWriterPerField) fieldsToFlush.get(fi);
|
final NormsWriterPerField toWrite = (NormsWriterPerField) fieldsToFlush.get(fi);
|
||||||
int upto = 0;
|
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++;
|
normCount++;
|
||||||
|
|
||||||
int docID = 0;
|
int docID = 0;
|
||||||
|
@ -84,7 +86,7 @@ final class NormsWriter extends InvertedDocEndConsumer {
|
||||||
normsOut.writeByte((byte) 0);
|
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;
|
success = true;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -572,6 +572,7 @@ public class SegmentReader extends IndexReader implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openNorms(Directory cfsDir, IOContext context) throws IOException {
|
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)
|
long nextNormSeek = SegmentNorms.NORMS_HEADER.length; //skip header (header unused for now)
|
||||||
int maxDoc = maxDoc();
|
int maxDoc = maxDoc();
|
||||||
for (FieldInfo fi : core.fieldInfos) {
|
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
|
nextNormSeek += maxDoc; // increment also if some norms are separate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert singleNormStream == null || !normsInitiallyEmpty || nextNormSeek == singleNormStream.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
// for testing only
|
// for testing only
|
||||||
|
|
Loading…
Reference in New Issue