You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/04/16 11:17:43 UTC

svn commit: r1674027 - /lucene/dev/branches/branch_5x/lucene/codecs/src/test/org/apache/lucene/codecs/autoprefix/TestAutoPrefixTerms.java

Author: mikemccand
Date: Thu Apr 16 09:17:43 2015
New Revision: 1674027

URL: http://svn.apache.org/r1674027
Log:
LUCENE-5879: fix test bug: we cannot enforce max term count for empty-string prefix query since we [intentionally] do not create an empty-string auto-prefix term at index time

Modified:
    lucene/dev/branches/branch_5x/lucene/codecs/src/test/org/apache/lucene/codecs/autoprefix/TestAutoPrefixTerms.java

Modified: lucene/dev/branches/branch_5x/lucene/codecs/src/test/org/apache/lucene/codecs/autoprefix/TestAutoPrefixTerms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/codecs/src/test/org/apache/lucene/codecs/autoprefix/TestAutoPrefixTerms.java?rev=1674027&r1=1674026&r2=1674027&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/codecs/src/test/org/apache/lucene/codecs/autoprefix/TestAutoPrefixTerms.java (original)
+++ lucene/dev/branches/branch_5x/lucene/codecs/src/test/org/apache/lucene/codecs/autoprefix/TestAutoPrefixTerms.java Thu Apr 16 09:17:43 2015
@@ -69,6 +69,13 @@ public class TestAutoPrefixTerms extends
   private int minTermsAutoPrefix = TestUtil.nextInt(random(), 2, 100);
   private int maxTermsAutoPrefix = random().nextBoolean() ? Math.max(2, (minTermsAutoPrefix-1)*2 + random().nextInt(100)) : Integer.MAX_VALUE;
 
+  public TestAutoPrefixTerms() {
+    if (LuceneTestCase.VERBOSE) {
+      System.out.println("TEST: using minItemsPerBlock=" + minItemsPerBlock + " maxItemsPerBlock=" + maxItemsPerBlock);
+      System.out.println("TEST: using minTermsAutoPrefix=" + minTermsAutoPrefix + " maxTermsAutoPrefix=" + maxTermsAutoPrefix);
+    }
+  }
+
   private final Codec codec = TestUtil.alwaysPostingsFormat(new AutoPrefixPostingsFormat(minItemsPerBlock, maxItemsPerBlock,
                                                                                          minTermsAutoPrefix, maxTermsAutoPrefix));
 
@@ -614,8 +621,12 @@ public class TestAutoPrefixTerms extends
         long allowedMaxTerms;
 
         if (bounds.length == 1) {
-          // Simple prefix query: we should never see more than maxPrefixCount terms:
-          allowedMaxTerms = maxPrefixCount;
+          // Simple prefix query: we should never see more than maxPrefixCount terms, except for the empty string:
+          if (bounds[0].length == 0) {
+            allowedMaxTerms = Integer.MAX_VALUE;
+          } else {
+            allowedMaxTerms = maxPrefixCount;
+          }
         } else {
           // Trickier: we need to allow for maxPrefixTerms for each different leading byte in the min and max:
           assert bounds.length == 2;