Fix test bug in TestFeatureSort.testDuelFloat.

It could index out-of-range frequencies.
This commit is contained in:
Adrien Grand 2019-10-07 11:45:53 +02:00
parent 7d4751e8b8
commit f3c50f966a
2 changed files with 2 additions and 2 deletions

View File

@ -197,7 +197,7 @@ public final class FeatureField extends Field {
}
}
private static final int MAX_FREQ = Float.floatToIntBits(Float.MAX_VALUE) >>> 15;
static final int MAX_FREQ = Float.floatToIntBits(Float.MAX_VALUE) >>> 15;
static float decodeFeatureValue(float freq) {
if (freq > MAX_FREQ) {

View File

@ -230,7 +230,7 @@ public class TestFeatureSort extends LuceneTestCase {
if (random().nextBoolean()) {
float f;
do {
int freq = TestUtil.nextInt(random(), 1, (1 << 16) - 1);
int freq = TestUtil.nextInt(random(), 1, FeatureField.MAX_FREQ);
f = FeatureField.decodeFeatureValue(freq);
} while (f < Float.MIN_NORMAL);
doc.add(new NumericDocValuesField("float", Float.floatToIntBits(f)));