mirror of https://github.com/apache/lucene.git
fix minor concurrency issue on SegmentReader; fix false test failure
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1081017 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bba16619f5
commit
d6ec69f7d8
|
@ -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)
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -702,7 +702,7 @@ public class SegmentReader extends IndexReader implements Cloneable {
|
|||
}
|
||||
}
|
||||
|
||||
private void commitChanges(Map<String,String> commitUserData) throws IOException {
|
||||
private synchronized void commitChanges(Map<String,String> 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
|
||||
|
|
Loading…
Reference in New Issue