diff --git a/lucene/src/java/org/apache/lucene/index/IndexReader.java b/lucene/src/java/org/apache/lucene/index/IndexReader.java index 3f8859bf3f1..d1e37c576bd 100644 --- a/lucene/src/java/org/apache/lucene/index/IndexReader.java +++ b/lucene/src/java/org/apache/lucene/index/IndexReader.java @@ -996,7 +996,8 @@ public abstract class IndexReader implements Cloneable,Closeable { } /** Returns the byte-encoded normalization factor for the named field of - * every document. This is used by the search code to score documents. + * every document. This is used by the search code to score documents. + * Returns null if norms were not indexed for this field. * * @see org.apache.lucene.document.Field#setBoost(float) */ diff --git a/lucene/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/src/java/org/apache/lucene/index/IndexWriter.java index 3b2d7603ccc..2c2ad6181f4 100644 --- a/lucene/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/src/java/org/apache/lucene/index/IndexWriter.java @@ -3222,7 +3222,7 @@ public class IndexWriter implements Closeable { message("merge segmentCodecs=" + merger.getSegmentCodecs()); message("merge store matchedCount=" + merger.getMatchedSubReaderCount() + " vs " + merge.readers.size()); } - anyNonBulkMerges |= merger.getMatchedSubReaderCount() != merge.readers.size(); + anyNonBulkMerges |= merger.getAnyNonBulkMerges(); assert mergedDocCount == totDocCount: "mergedDocCount=" + mergedDocCount + " vs " + totDocCount; diff --git a/lucene/src/java/org/apache/lucene/index/SegmentMerger.java b/lucene/src/java/org/apache/lucene/index/SegmentMerger.java index a708c93ffcf..279e91e273e 100644 --- a/lucene/src/java/org/apache/lucene/index/SegmentMerger.java +++ b/lucene/src/java/org/apache/lucene/index/SegmentMerger.java @@ -571,6 +571,11 @@ final class SegmentMerger { return mergeState.delCounts; } + public boolean getAnyNonBulkMerges() { + assert matchedCount <= readers.size(); + return matchedCount != readers.size(); + } + private void mergeNorms() throws IOException { IndexOutput output = null; try { diff --git a/lucene/src/java/org/apache/lucene/index/SegmentReader.java b/lucene/src/java/org/apache/lucene/index/SegmentReader.java index ac36827bfc6..440e0e23e99 100644 --- a/lucene/src/java/org/apache/lucene/index/SegmentReader.java +++ b/lucene/src/java/org/apache/lucene/index/SegmentReader.java @@ -702,7 +702,7 @@ public class SegmentReader extends IndexReader implements Cloneable { } } - private void commitChanges(Map commitUserData) throws IOException { + private synchronized void commitChanges(Map commitUserData) throws IOException { if (deletedDocsDirty) { // re-write deleted si.advanceDelGen(); @@ -923,26 +923,21 @@ public class SegmentReader extends IndexReader implements Cloneable { return fieldSet; } - @Override - public synchronized boolean hasNorms(String field) { + public boolean hasNorms(String field) { ensureOpen(); return norms.containsKey(field); } - // can return null if norms aren't stored - protected synchronized byte[] getNorms(String field) throws IOException { - Norm norm = norms.get(field); - if (norm == null) return null; // not indexed, or norms not stored - return norm.bytes(); - } - - // returns fake norms if norms aren't available @Override - public synchronized byte[] norms(String field) throws IOException { + public byte[] norms(String field) throws IOException { ensureOpen(); - byte[] bytes = getNorms(field); - return bytes; + final Norm norm = norms.get(field); + if (norm == null) { + // not indexed, or norms not stored + return null; + } + return norm.bytes(); } @Override