mirror of https://github.com/apache/lucene.git
fix NPE and deletion bugs in ParallelReader: LUCENE-561
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@407851 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0c9ec9edf7
commit
1e700534cc
|
@ -58,9 +58,14 @@ Bug fixes
|
||||||
NullPointerException when "exclude" query was not a SpanTermQuery.
|
NullPointerException when "exclude" query was not a SpanTermQuery.
|
||||||
(Chris Hostetter)
|
(Chris Hostetter)
|
||||||
|
|
||||||
12. LUCENE-572: Fixed bug in hashCode, was ignoring exclude clause
|
12. LUCENE-572: Fixed bug in SpanNotQuery hashCode, was ignoring exclude clause
|
||||||
(Chris Hostetter)
|
(Chris Hostetter)
|
||||||
|
|
||||||
|
13. LUCENE-561: Fixed some ParallelReader bugs. NullPointerException if the reader
|
||||||
|
didn't know about the field yet, reader didn't keep track if it had deletions,
|
||||||
|
and deleteDocument calls could circumvent synchronization on the subreaders.
|
||||||
|
(Chuck Williams via Yonik Seeley)
|
||||||
|
|
||||||
1.9.1
|
1.9.1
|
||||||
|
|
||||||
Bug fixes
|
Bug fixes
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class ParallelReader extends IndexReader {
|
||||||
// delete in all readers
|
// delete in all readers
|
||||||
protected void doDelete(int n) throws IOException {
|
protected void doDelete(int n) throws IOException {
|
||||||
for (int i = 0; i < readers.size(); i++) {
|
for (int i = 0; i < readers.size(); i++) {
|
||||||
((IndexReader)readers.get(i)).doDelete(n);
|
((IndexReader)readers.get(i)).deleteDocument(n);
|
||||||
}
|
}
|
||||||
hasDeletions = true;
|
hasDeletions = true;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ public class ParallelReader extends IndexReader {
|
||||||
// undeleteAll in all readers
|
// undeleteAll in all readers
|
||||||
protected void doUndeleteAll() throws IOException {
|
protected void doUndeleteAll() throws IOException {
|
||||||
for (int i = 0; i < readers.size(); i++) {
|
for (int i = 0; i < readers.size(); i++) {
|
||||||
((IndexReader)readers.get(i)).doUndeleteAll();
|
((IndexReader)readers.get(i)).undeleteAll();
|
||||||
}
|
}
|
||||||
hasDeletions = false;
|
hasDeletions = false;
|
||||||
}
|
}
|
||||||
|
@ -162,25 +162,32 @@ public class ParallelReader extends IndexReader {
|
||||||
|
|
||||||
public TermFreqVector getTermFreqVector(int n, String field)
|
public TermFreqVector getTermFreqVector(int n, String field)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return ((IndexReader)fieldToReader.get(field)).getTermFreqVector(n, field);
|
IndexReader reader = ((IndexReader)fieldToReader.get(field));
|
||||||
|
return reader==null ? null : reader.getTermFreqVector(n, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNorms(String field) throws IOException {
|
public boolean hasNorms(String field) throws IOException {
|
||||||
return ((IndexReader)fieldToReader.get(field)).hasNorms(field);
|
IndexReader reader = ((IndexReader)fieldToReader.get(field));
|
||||||
|
return reader==null ? false : reader.hasNorms(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] norms(String field) throws IOException {
|
public byte[] norms(String field) throws IOException {
|
||||||
return ((IndexReader)fieldToReader.get(field)).norms(field);
|
IndexReader reader = ((IndexReader)fieldToReader.get(field));
|
||||||
|
return reader==null ? null : reader.norms(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void norms(String field, byte[] result, int offset)
|
public void norms(String field, byte[] result, int offset)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
((IndexReader)fieldToReader.get(field)).norms(field, result, offset);
|
IndexReader reader = ((IndexReader)fieldToReader.get(field));
|
||||||
|
if (reader!=null)
|
||||||
|
reader.norms(field, result, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doSetNorm(int n, String field, byte value)
|
protected void doSetNorm(int n, String field, byte value)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
((IndexReader)fieldToReader.get(field)).doSetNorm(n, field, value);
|
IndexReader reader = ((IndexReader)fieldToReader.get(field));
|
||||||
|
if (reader!=null)
|
||||||
|
reader.doSetNorm(n, field, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TermEnum terms() throws IOException {
|
public TermEnum terms() throws IOException {
|
||||||
|
@ -192,7 +199,8 @@ public class ParallelReader extends IndexReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int docFreq(Term term) throws IOException {
|
public int docFreq(Term term) throws IOException {
|
||||||
return ((IndexReader)fieldToReader.get(term.field())).docFreq(term);
|
IndexReader reader = ((IndexReader)fieldToReader.get(term.field()));
|
||||||
|
return reader==null ? 0 : reader.docFreq(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TermDocs termDocs(Term term) throws IOException {
|
public TermDocs termDocs(Term term) throws IOException {
|
||||||
|
@ -244,11 +252,13 @@ public class ParallelReader extends IndexReader {
|
||||||
|
|
||||||
public ParallelTermEnum(Term term) throws IOException {
|
public ParallelTermEnum(Term term) throws IOException {
|
||||||
field = term.field();
|
field = term.field();
|
||||||
termEnum = ((IndexReader)fieldToReader.get(field)).terms(term);
|
IndexReader reader = ((IndexReader)fieldToReader.get(field));
|
||||||
|
if (reader!=null)
|
||||||
|
termEnum = reader.terms(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean next() throws IOException {
|
public boolean next() throws IOException {
|
||||||
if (field == null)
|
if (termEnum == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
boolean next = termEnum.next();
|
boolean next = termEnum.next();
|
||||||
|
@ -270,9 +280,24 @@ public class ParallelReader extends IndexReader {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Term term() { return termEnum.term(); }
|
public Term term() {
|
||||||
public int docFreq() { return termEnum.docFreq(); }
|
if (termEnum==null)
|
||||||
public void close() throws IOException { termEnum.close(); }
|
return null;
|
||||||
|
|
||||||
|
return termEnum.term();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int docFreq() {
|
||||||
|
if (termEnum==null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return termEnum.docFreq();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() throws IOException {
|
||||||
|
if (termEnum!=null)
|
||||||
|
termEnum.close();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,24 +312,39 @@ public class ParallelReader extends IndexReader {
|
||||||
public int freq() { return termDocs.freq(); }
|
public int freq() { return termDocs.freq(); }
|
||||||
|
|
||||||
public void seek(Term term) throws IOException {
|
public void seek(Term term) throws IOException {
|
||||||
termDocs = ((IndexReader)fieldToReader.get(term.field())).termDocs(term);
|
IndexReader reader = ((IndexReader)fieldToReader.get(term.field()));
|
||||||
|
termDocs = reader!=null ? reader.termDocs(term) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void seek(TermEnum termEnum) throws IOException {
|
public void seek(TermEnum termEnum) throws IOException {
|
||||||
seek(termEnum.term());
|
seek(termEnum.term());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean next() throws IOException { return termDocs.next(); }
|
public boolean next() throws IOException {
|
||||||
|
if (termDocs==null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return termDocs.next();
|
||||||
|
}
|
||||||
|
|
||||||
public int read(final int[] docs, final int[] freqs) throws IOException {
|
public int read(final int[] docs, final int[] freqs) throws IOException {
|
||||||
|
if (termDocs==null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return termDocs.read(docs, freqs);
|
return termDocs.read(docs, freqs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean skipTo(int target) throws IOException {
|
public boolean skipTo(int target) throws IOException {
|
||||||
|
if (termDocs==null)
|
||||||
|
return false;
|
||||||
|
|
||||||
return termDocs.skipTo(target);
|
return termDocs.skipTo(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() throws IOException { termDocs.close(); }
|
public void close() throws IOException {
|
||||||
|
if (termDocs!=null)
|
||||||
|
termDocs.close();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,11 +355,12 @@ public class ParallelReader extends IndexReader {
|
||||||
public ParallelTermPositions(Term term) throws IOException { seek(term); }
|
public ParallelTermPositions(Term term) throws IOException { seek(term); }
|
||||||
|
|
||||||
public void seek(Term term) throws IOException {
|
public void seek(Term term) throws IOException {
|
||||||
termDocs = ((IndexReader)fieldToReader.get(term.field()))
|
IndexReader reader = ((IndexReader)fieldToReader.get(term.field()));
|
||||||
.termPositions(term);
|
termDocs = reader!=null ? reader.termPositions(term) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextPosition() throws IOException {
|
public int nextPosition() throws IOException {
|
||||||
|
// It is an error to call this if there is no next position, e.g. if termDocs==null
|
||||||
return ((TermPositions)termDocs).nextPosition();
|
return ((TermPositions)termDocs).nextPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue