mirror of https://github.com/apache/lucene.git
LUCENE-8586: Fix infinite loop in Intervals.or()
This commit is contained in:
parent
75a053dd69
commit
c78429a554
|
@ -305,6 +305,9 @@ Bug fixes
|
|||
* LUCENE-8556: Use latitude and longitude instead of encoding values to check if triangle is ear
|
||||
when using morton optimisation. (Ignacio Vera)
|
||||
|
||||
* LUCENE-8586: Intervals.or() could get stuck in an infinite loop on certain indexes
|
||||
(Alan Woodward)
|
||||
|
||||
New Features
|
||||
|
||||
* LUCENE-8496: Selective indexing - modify BKDReader/BKDWriter to allow users
|
||||
|
|
|
@ -146,7 +146,7 @@ class DisjunctionIntervalsSource extends IntervalsSource {
|
|||
|
||||
@Override
|
||||
public int nextInterval() throws IOException {
|
||||
if (current == EMPTY) {
|
||||
if (current == EMPTY || current == EXHAUSTED) {
|
||||
if (intervalQueue.size() > 0) {
|
||||
current = intervalQueue.top();
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ class DisjunctionIntervalsSource extends IntervalsSource {
|
|||
}
|
||||
}
|
||||
if (intervalQueue.size() == 0) {
|
||||
current = EMPTY;
|
||||
current = EXHAUSTED;
|
||||
return NO_MORE_INTERVALS;
|
||||
}
|
||||
current = intervalQueue.top();
|
||||
|
@ -239,4 +239,47 @@ class DisjunctionIntervalsSource extends IntervalsSource {
|
|||
}
|
||||
};
|
||||
|
||||
private static final IntervalIterator EXHAUSTED = new IntervalIterator() {
|
||||
|
||||
@Override
|
||||
public int docID() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextDoc() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int advance(int target) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long cost() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int start() {
|
||||
return NO_MORE_INTERVALS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int end() {
|
||||
return NO_MORE_INTERVALS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInterval() {
|
||||
return NO_MORE_INTERVALS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float matchCost() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ public class TestIntervals extends LuceneTestCase {
|
|||
"Porridge is great"
|
||||
};
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
// 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
|
||||
private static String field2_docs[] = {
|
||||
"In Xanadu did Kubla Khan a stately pleasure dome decree",
|
||||
"Where Alph the sacred river ran through caverns measureless to man",
|
||||
|
@ -260,6 +262,18 @@ public class TestIntervals extends LuceneTestCase {
|
|||
assertFalse(mi.next());
|
||||
}
|
||||
|
||||
public void testCombinationDisjunction() throws IOException {
|
||||
IntervalsSource source = Intervals.ordered(
|
||||
Intervals.or(Intervals.term("alph"), Intervals.term("sacred")),
|
||||
Intervals.term("measureless")
|
||||
);
|
||||
checkIntervals(source, "field2", 1, new int[][]{
|
||||
{},
|
||||
{ 3, 8 },
|
||||
{}, {}, {}, {}
|
||||
});
|
||||
}
|
||||
|
||||
public void testNesting() throws IOException {
|
||||
IntervalsSource source = Intervals.unordered(
|
||||
Intervals.term("pease"),
|
||||
|
|
Loading…
Reference in New Issue