mirror of https://github.com/apache/lucene.git
Documenting that IndexReaderContext#leaves() will never return a null value and remove the null checks from the method calls (#12034)
This commit is contained in:
parent
5fccaec166
commit
e14327288e
|
@ -197,6 +197,8 @@ Improvements
|
||||||
|
|
||||||
* GITHUB#12016: Upgrade lucene/expressions to use antlr 4.11.1 (Andriy Redko)
|
* GITHUB#12016: Upgrade lucene/expressions to use antlr 4.11.1 (Andriy Redko)
|
||||||
|
|
||||||
|
* GITHUB#12034: Remove null check in IndexReaderContext#leaves() usages (Erik Pellizzon)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
---------------------
|
---------------------
|
||||||
* GITHUB#11726: Indexing term vectors on large documents could fail due to
|
* GITHUB#11726: Indexing term vectors on large documents could fail due to
|
||||||
|
|
|
@ -64,7 +64,8 @@ public abstract class IndexReaderContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the context's leaves if this context is a top-level context. For convenience, if this
|
* Returns the context's leaves if this context is a top-level context. For convenience, if this
|
||||||
* is an {@link LeafReaderContext} this returns itself as the only leaf.
|
* is an {@link LeafReaderContext} this returns itself as the only leaf, and it will never return
|
||||||
|
* a null value.
|
||||||
*
|
*
|
||||||
* <p>Note: this is convenience method since leaves can always be obtained by walking the context
|
* <p>Note: this is convenience method since leaves can always be obtained by walking the context
|
||||||
* tree using {@link #children()}.
|
* tree using {@link #children()}.
|
||||||
|
|
|
@ -49,13 +49,7 @@ public final class TermStates {
|
||||||
topReaderContextIdentity = context.identity;
|
topReaderContextIdentity = context.identity;
|
||||||
docFreq = 0;
|
docFreq = 0;
|
||||||
totalTermFreq = 0;
|
totalTermFreq = 0;
|
||||||
final int len;
|
states = new TermState[context.leaves().size()];
|
||||||
if (context.leaves() == null) {
|
|
||||||
len = 1;
|
|
||||||
} else {
|
|
||||||
len = context.leaves().size();
|
|
||||||
}
|
|
||||||
states = new TermState[len];
|
|
||||||
this.term = term;
|
this.term = term;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -314,14 +314,8 @@ public final class BlendedTermQuery extends Query {
|
||||||
IndexReaderContext readerContext, TermStates ctx, int artificialDf, long artificialTtf)
|
IndexReaderContext readerContext, TermStates ctx, int artificialDf, long artificialTtf)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
List<LeafReaderContext> leaves = readerContext.leaves();
|
List<LeafReaderContext> leaves = readerContext.leaves();
|
||||||
final int len;
|
|
||||||
if (leaves == null) {
|
|
||||||
len = 1;
|
|
||||||
} else {
|
|
||||||
len = leaves.size();
|
|
||||||
}
|
|
||||||
TermStates newCtx = new TermStates(readerContext);
|
TermStates newCtx = new TermStates(readerContext);
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < leaves.size(); ++i) {
|
||||||
TermState termState = ctx.get(leaves.get(i));
|
TermState termState = ctx.get(leaves.get(i));
|
||||||
if (termState == null) {
|
if (termState == null) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue