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 2012/11/05 18:37:31 UTC

svn commit: r1405892 - in /lucene/dev/trunk: ./ lucene/ lucene/sandbox/ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java

Author: mikemccand
Date: Mon Nov  5 17:37:31 2012
New Revision: 1405892

URL: http://svn.apache.org/viewvc?rev=1405892&view=rev
Log:
use smaller index for TestSlowCollationMethods.testQuery

Modified:
    lucene/dev/trunk/   (props changed)
    lucene/dev/trunk/lucene/   (props changed)
    lucene/dev/trunk/lucene/sandbox/   (props changed)
    lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java

Modified: lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java?rev=1405892&r1=1405891&r2=1405892&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java (original)
+++ lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java Mon Nov  5 17:37:31 2012
@@ -147,10 +147,40 @@ public class TestSlowCollationMethods ex
     }
   }
   
-  public void testQuery() {
+  public void testQuery() throws Exception {
+
+    // Copied from beforeClass, but scaled down to few docs:
+    // since otherwise this test can run for a very long
+    // time (1-2 hours or more; see Lucene-Solr-4.x-Linux Build #2204):
+    final Locale locale = LuceneTestCase.randomLocale(random());
+    Collator collator = Collator.getInstance(locale);
+    collator.setStrength(Collator.IDENTICAL);
+    collator.setDecomposition(Collator.NO_DECOMPOSITION);
+
+    int numDocs = 20 * RANDOM_MULTIPLIER;
+    Directory dir = newDirectory();
+    RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
+    for (int i = 0; i < numDocs; i++) {
+      Document doc = new Document();
+      String value = _TestUtil.randomUnicodeString(random());
+      Field field = newStringField("field", value, Field.Store.YES);
+      doc.add(field);
+      iw.addDocument(doc);
+    }
+    IndexReader reader = iw.getReader();
+    iw.close();
+
+    IndexSearcher searcher = newSearcher(reader);
+
     String startPoint = _TestUtil.randomUnicodeString(random());
     String endPoint = _TestUtil.randomUnicodeString(random());
     Query query = new SlowCollatedTermRangeQuery("field", startPoint, endPoint, true, true, collator);
     QueryUtils.check(random(), query, searcher);
+    reader.close();
+    dir.close();
+    collator = null;
+    searcher = null;
+    reader = null;
+    dir = null;
   }
 }



Re: svn commit: r1405892 - in /lucene/dev/trunk: ./ lucene/ lucene/sandbox/ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java

Posted by Robert Muir <rc...@gmail.com>.
Thanks!

On Mon, Nov 5, 2012 at 12:37 PM,  <mi...@apache.org> wrote:
> Author: mikemccand
> Date: Mon Nov  5 17:37:31 2012
> New Revision: 1405892
>
> URL: http://svn.apache.org/viewvc?rev=1405892&view=rev
> Log:
> use smaller index for TestSlowCollationMethods.testQuery
>
> Modified:
>     lucene/dev/trunk/   (props changed)
>     lucene/dev/trunk/lucene/   (props changed)
>     lucene/dev/trunk/lucene/sandbox/   (props changed)
>     lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java
>
> Modified: lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java
> URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java?rev=1405892&r1=1405891&r2=1405892&view=diff
> ==============================================================================
> --- lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java (original)
> +++ lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java Mon Nov  5 17:37:31 2012
> @@ -147,10 +147,40 @@ public class TestSlowCollationMethods ex
>      }
>    }
>
> -  public void testQuery() {
> +  public void testQuery() throws Exception {
> +
> +    // Copied from beforeClass, but scaled down to few docs:
> +    // since otherwise this test can run for a very long
> +    // time (1-2 hours or more; see Lucene-Solr-4.x-Linux Build #2204):
> +    final Locale locale = LuceneTestCase.randomLocale(random());
> +    Collator collator = Collator.getInstance(locale);
> +    collator.setStrength(Collator.IDENTICAL);
> +    collator.setDecomposition(Collator.NO_DECOMPOSITION);
> +
> +    int numDocs = 20 * RANDOM_MULTIPLIER;
> +    Directory dir = newDirectory();
> +    RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
> +    for (int i = 0; i < numDocs; i++) {
> +      Document doc = new Document();
> +      String value = _TestUtil.randomUnicodeString(random());
> +      Field field = newStringField("field", value, Field.Store.YES);
> +      doc.add(field);
> +      iw.addDocument(doc);
> +    }
> +    IndexReader reader = iw.getReader();
> +    iw.close();
> +
> +    IndexSearcher searcher = newSearcher(reader);
> +
>      String startPoint = _TestUtil.randomUnicodeString(random());
>      String endPoint = _TestUtil.randomUnicodeString(random());
>      Query query = new SlowCollatedTermRangeQuery("field", startPoint, endPoint, true, true, collator);
>      QueryUtils.check(random(), query, searcher);
> +    reader.close();
> +    dir.close();
> +    collator = null;
> +    searcher = null;
> +    reader = null;
> +    dir = null;
>    }
>  }
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org