mirror of https://github.com/apache/lucene.git
Add a missing check for inverse ranges in splitRange() and corresponding tests for inverse ranges and 0-length-ranges.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@764829 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
26be4aa353
commit
87e10db563
|
@ -336,6 +336,7 @@ public final class TrieUtils {
|
|||
final Object builder, final int valSize,
|
||||
final int precisionStep, long minBound, long maxBound
|
||||
) {
|
||||
if (minBound > maxBound) return;
|
||||
for (int shift=0; ; shift += precisionStep) {
|
||||
// calculate new bounds for inner precision
|
||||
final long diff = 1L << (shift+precisionStep),
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.lucene.util.LuceneTestCase;
|
|||
import org.apache.lucene.util.OpenBitSet;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class TestTrieUtils extends LuceneTestCase {
|
||||
|
@ -243,6 +244,14 @@ public class TestTrieUtils extends LuceneTestCase {
|
|||
assertLongRangeSplit(Long.MIN_VALUE, Long.MAX_VALUE, 1, false, Arrays.asList(new Long[]{
|
||||
new Long(0x0L),new Long(0x1L)
|
||||
}).iterator());
|
||||
|
||||
// a inverse range should produce no sub-ranges
|
||||
assertLongRangeSplit(9500L, -5000L, 4, false, Collections.EMPTY_LIST.iterator());
|
||||
|
||||
// a 0-length range should reproduce the range itsself
|
||||
assertLongRangeSplit(9500L, 9500L, 4, false, Arrays.asList(new Long[]{
|
||||
new Long(0x800000000000251cL),new Long(0x800000000000251cL)
|
||||
}).iterator());
|
||||
}
|
||||
|
||||
/** Note: The neededBounds iterator must be unsigned (easier understanding what's happening) */
|
||||
|
@ -317,6 +326,14 @@ public class TestTrieUtils extends LuceneTestCase {
|
|||
assertIntRangeSplit(Integer.MIN_VALUE, Integer.MAX_VALUE, 1, false, Arrays.asList(new Integer[]{
|
||||
new Integer(0x0),new Integer(0x1)
|
||||
}).iterator());
|
||||
|
||||
// a inverse range should produce no sub-ranges
|
||||
assertIntRangeSplit(9500, -5000, 4, false, Collections.EMPTY_LIST.iterator());
|
||||
|
||||
// a 0-length range should reproduce the range itsself
|
||||
assertIntRangeSplit(9500, 9500, 4, false, Arrays.asList(new Integer[]{
|
||||
new Integer(0x8000251c),new Integer(0x8000251c)
|
||||
}).iterator());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue