You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2019/10/07 09:52:15 UTC

[lucene-solr] branch branch_8x updated: Fix test bug in TestFeatureSort.testDuelFloat.

This is an automated email from the ASF dual-hosted git repository.

jpountz pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new f3c50f9  Fix test bug in TestFeatureSort.testDuelFloat.
f3c50f9 is described below

commit f3c50f966a4a441f34fd518a669f9398c2d4ab0a
Author: Adrien Grand <jp...@gmail.com>
AuthorDate: Mon Oct 7 11:45:53 2019 +0200

    Fix test bug in TestFeatureSort.testDuelFloat.
    
    It could index out-of-range frequencies.
---
 lucene/core/src/java/org/apache/lucene/document/FeatureField.java    | 2 +-
 lucene/core/src/test/org/apache/lucene/document/TestFeatureSort.java | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/document/FeatureField.java b/lucene/core/src/java/org/apache/lucene/document/FeatureField.java
index 229e057..2ca048c 100644
--- a/lucene/core/src/java/org/apache/lucene/document/FeatureField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/FeatureField.java
@@ -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) {
diff --git a/lucene/core/src/test/org/apache/lucene/document/TestFeatureSort.java b/lucene/core/src/test/org/apache/lucene/document/TestFeatureSort.java
index 3c8fef1..1090e5a 100644
--- a/lucene/core/src/test/org/apache/lucene/document/TestFeatureSort.java
+++ b/lucene/core/src/test/org/apache/lucene/document/TestFeatureSort.java
@@ -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)));