<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>java-commits@lucene.apache.org Archives</title>
<link rel="self" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/?format=atom"/>
<link href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/"/>
<id>http://mail-archives.apache.org/mod_mbox/lucene-java-commits/</id>
<updated>2009-12-06T20:27:17Z</updated>
<entry>
<title>svn commit: r887743 - /lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091206184600.BB5C32388882@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206184600-BB5C32388882@eris-apache-org%3e</id>
<updated>2009-12-06T18:46:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Sun Dec  6 18:46:00 2009
New Revision: 887743

URL: http://svn.apache.org/viewvc?rev=887743&amp;view=rev
Log:
LUCENE-2111 (on flex branch): cleanup: remove silly wrapper class in MultiPhraseQuery

Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=887743&amp;r1=887742&amp;r2=887743&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java
Sun Dec  6 18:46:00 2009
@@ -382,37 +382,30 @@
  * Takes the logical union of multiple DocsEnum iterators.
  */
 
+// nocommit -- this must carefully take union of attr source
+// as well -- this is tricky
 class UnionDocsEnum extends DocsEnum {
 
-  private final static class DocsEnumWrapper {
-    int doc;
-    final DocsEnum docsEnum;
-    public DocsEnumWrapper(DocsEnum docsEnum) {
-      this.docsEnum = docsEnum;
-    }
-  }
-
-  private static final class DocsQueue extends PriorityQueue {
-    DocsQueue(List docsEnums) throws IOException {
+  private static final class DocsQueue extends PriorityQueue&lt;DocsEnum&gt; {
+    DocsQueue(List&lt;DocsEnum&gt; docsEnums) throws IOException {
       initialize(docsEnums.size());
 
-      Iterator i = docsEnums.iterator();
+      Iterator&lt;DocsEnum&gt; i = docsEnums.iterator();
       while (i.hasNext()) {
-        DocsEnumWrapper docs = (DocsEnumWrapper) i.next();
-        docs.doc = docs.docsEnum.nextDoc();
-        if (docs.doc != DocsEnum.NO_MORE_DOCS) {
+        DocsEnum docs = (DocsEnum) i.next();
+        if (docs.nextDoc() != DocsEnum.NO_MORE_DOCS) {
           add(docs);
         }
       }
     }
 
-    final public DocsEnumWrapper peek() {
-      return (DocsEnumWrapper) top();
+    final public DocsEnum peek() {
+      return top();
     }
 
     @Override
-    public final boolean lessThan(Object a, Object b) {
-      return ((DocsEnumWrapper) a).doc &lt; ((DocsEnumWrapper) b).doc;
+    public final boolean lessThan(DocsEnum a, DocsEnum b) {
+      return a.docID() &lt; b.docID();
     }
   }
 
@@ -421,7 +414,7 @@
     private int _index = 0;
     private int _lastIndex = 0;
     private int[] _array = new int[_arraySize];
-
+    
     final void add(int i) {
       if (_lastIndex == _arraySize)
         growArray();
@@ -470,7 +463,7 @@
                                                terms[i].field(),
                                                new TermRef(terms[i].text()));
       if (docs != null) {
-        docsEnums.add(new DocsEnumWrapper(docs));
+        docsEnums.add(docs);
       }
     }
 
@@ -494,27 +487,25 @@
     // doesn't need the positions for this doc then don't
     // waste CPU merging them:
     _posList.clear();
-    _doc = _queue.peek().doc;
+    _doc = _queue.top().docID();
 
     // merge sort all positions together
-    DocsEnumWrapper docs;
+    DocsEnum docs;
     do {
-      docs = _queue.peek();
-      final PositionsEnum positions = docs.docsEnum.positions();
+      docs = _queue.top();
+      final PositionsEnum positions = docs.positions();
 
-      final int freq = docs.docsEnum.freq();
+      final int freq = docs.freq();
       for (int i = 0; i &lt; freq; i++) {
         _posList.add(positions.next());
       }
 
-      docs.doc = docs.docsEnum.nextDoc();
-
-      if (docs.doc != NO_MORE_DOCS) {
+      if (docs.nextDoc() != NO_MORE_DOCS) {
         _queue.updateTop();
       } else {
         _queue.pop();
       }
-    } while (_queue.size() &gt; 0 &amp;&amp; _queue.peek().doc == _doc);
+    } while (_queue.size() &gt; 0 &amp;&amp; _queue.top().docID() == _doc);
 
     _posList.sort();
     _freq = _posList.size();
@@ -547,10 +538,9 @@
 
   @Override
   public final int advance(int target) throws IOException {
-    while (_queue.peek() != null &amp;&amp; target &gt; _queue.peek().doc) {
-      DocsEnumWrapper docs = (DocsEnumWrapper) _queue.pop();
-      docs.doc = docs.docsEnum.advance(target);
-      if (docs.doc != NO_MORE_DOCS) {
+    while (_queue.top() != null &amp;&amp; target &gt; _queue.top().docID()) {
+      DocsEnum docs = _queue.pop();
+      if (docs.advance(target) != NO_MORE_DOCS) {
         _queue.add(docs);
       }
     }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887708 - /lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestUnicodeUtil.java</title>
<author><name>rmuir@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091206164708.CA60923888D1@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206164708-CA60923888D1@eris-apache-org%3e</id>
<updated>2009-12-06T16:47:08Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: rmuir
Date: Sun Dec  6 16:47:08 2009
New Revision: 887708

URL: http://svn.apache.org/viewvc?rev=887708&amp;view=rev
Log:
LUCENE-2121: I forgot to svn add my testcase, sorry

Added:
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestUnicodeUtil.java  
(with props)

Added: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestUnicodeUtil.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestUnicodeUtil.java?rev=887708&amp;view=auto
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestUnicodeUtil.java (added)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestUnicodeUtil.java Sun
Dec  6 16:47:08 2009
@@ -0,0 +1,80 @@
+package org.apache.lucene.util;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/*
+ * Some of this code came from the excellent Unicode
+ * conversion examples from:
+ *
+ *   http://www.unicode.org/Public/PROGRAMS/CVTUTF
+ *
+ * Full Copyright for that code follows:
+*/
+
+/*
+ * Copyright 2001-2004 Unicode, Inc.
+ * 
+ * Disclaimer
+ * 
+ * This source code is provided as is by Unicode, Inc. No claims are
+ * made as to fitness for any particular purpose. No warranties of any
+ * kind are expressed or implied. The recipient agrees to determine
+ * applicability of information provided. If this file has been
+ * purchased on magnetic or optical media from Unicode, Inc., the
+ * sole remedy for any claim will be exchange of defective media
+ * within 90 days of receipt.
+ * 
+ * Limitations on Rights to Redistribute This Code
+ * 
+ * Unicode, Inc. hereby grants the right to freely use the information
+ * supplied in this file in the creation of products supporting the
+ * Unicode Standard, and to make copies of this file in any form
+ * for internal or external distribution as long as this notice
+ * remains attached.
+ */
+
+public class TestUnicodeUtil extends LuceneTestCase {
+  public void testNextValidUTF16String() {
+    // valid UTF-16
+    assertEquals("dogs", UnicodeUtil.nextValidUTF16String("dogs"));
+    assertEquals("dogs\uD802\uDC02", UnicodeUtil
+        .nextValidUTF16String("dogs\uD802\uDC02"));
+    
+    // an illegal combination, where we have not yet enumerated into the supp
+    // plane so we increment to H + \uDC00 (the lowest possible trail surrogate)
+    assertEquals("dogs\uD801\uDC00", UnicodeUtil
+        .nextValidUTF16String("dogs\uD801"));
+    assertEquals("dogs\uD801\uDC00", UnicodeUtil
+        .nextValidUTF16String("dogs\uD801b"));
+    assertEquals("dogs\uD801\uDC00", UnicodeUtil
+        .nextValidUTF16String("dogs\uD801\uD800"));
+    
+    // an illegal combination where we have already enumerated the supp plane
+    // we must replace both H and Z with \uE000 (the lowest possible
+    // "upper BMP")
+    assertEquals("dogs\uE000", UnicodeUtil
+        .nextValidUTF16String("dogs\uD801\uE001"));
+    
+    // an unpaired trail surrogate. this is invalid when not preceded by a lead
+    // surrogate. in this case we have to bump to \uE000 (the lowest possible
+    // "upper BMP")
+    assertEquals("dogs\uE000", UnicodeUtil.nextValidUTF16String("dogs\uDC00"));
+    assertEquals("\uE000", UnicodeUtil.nextValidUTF16String("\uDC00dogs"));
+  }
+}

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestUnicodeUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887706 - in /lucene/java/branches/flex_1458/src/java/org/apache/lucene: index/SegmentReader.java util/UnicodeUtil.java</title>
<author><name>rmuir@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091206162014.8412023888C2@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206162014-8412023888C2@eris-apache-org%3e</id>
<updated>2009-12-06T16:20:14Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: rmuir
Date: Sun Dec  6 16:20:13 2009
New Revision: 887706

URL: http://svn.apache.org/viewvc?rev=887706&amp;view=rev
Log:
LUCENE-2121: add UnicodeUtil.nextValidUTF16String

Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/UnicodeUtil.java

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java?rev=887706&amp;r1=887705&amp;r2=887706&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java Sun
Dec  6 16:20:13 2009
@@ -38,6 +38,7 @@
 import org.apache.lucene.util.BitVector;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.CloseableThreadLocal;
+import org.apache.lucene.util.UnicodeUtil;
 import org.apache.lucene.index.codecs.Codecs;
 import org.apache.lucene.index.codecs.Codec;
 import org.apache.lucene.index.codecs.preflex.PreFlexFields;
@@ -1356,19 +1357,12 @@
             // We found exactly the requested field; now
             // seek the term text:
             String text = t.text();
-            TermRef tr;
-
-            // this is a hack only for backwards compatibility.
-            // previously you could supply a term ending with a lead surrogate,
+            // this is only for backwards compatibility.
+            // previously you could supply a term with unpaired surrogates,
             // and it would return the next Term.
             // if someone does this, tack on the lowest possible trail surrogate.
             // this emulates the old behavior, and forms "valid UTF-8" unicode.
-            if (text.length() &gt; 0 
-                &amp;&amp; Character.isHighSurrogate(text.charAt(text.length() - 1))) {
-              tr = new TermRef(t.text() + "\uDC00");
-            } else {
-              tr = new TermRef(t.text());
-            }
+            TermRef tr = new TermRef(UnicodeUtil.nextValidUTF16String(text));
             TermsEnum.SeekStatus status = terms.seek(tr);
             if (status == TermsEnum.SeekStatus.END) {
               // Rollover to the next field

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/UnicodeUtil.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/UnicodeUtil.java?rev=887706&amp;r1=887705&amp;r2=887706&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/UnicodeUtil.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/UnicodeUtil.java Sun Dec
 6 16:20:13 2009
@@ -364,6 +364,48 @@
     result.length = outUpto;
   }
 
+  /**
+   * Get the next valid UTF-16 String in UTF-16 order.
+   * &lt;p&gt;
+   * If the input String is already valid, it is returned.
+   * Otherwise the next String in code unit order is returned.
+   * &lt;/p&gt;
+   * @param s input String (possibly with unpaired surrogates)
+   * @return next valid UTF-16 String in UTF-16 order
+   */
+  public static String nextValidUTF16String(String s) {
+    final int size = s.length();
+    for (int i = 0; i &lt; size; i++) {
+      char ch = s.charAt(i);
+      if (ch &gt;= UnicodeUtil.UNI_SUR_HIGH_START
+          &amp;&amp; ch &lt;= UnicodeUtil.UNI_SUR_HIGH_END) {
+        if (i &lt; size - 1) {
+          i++;
+          char nextCH = s.charAt(i);
+          if (nextCH &gt;= UnicodeUtil.UNI_SUR_LOW_START
+              &amp;&amp; nextCH &lt;= UnicodeUtil.UNI_SUR_LOW_END) {
+            // Valid surrogate pair
+          } else
+          // Unmatched high surrogate
+            if (nextCH &lt; UnicodeUtil.UNI_SUR_LOW_START) // SMP not enumerated 
+              return s.substring(0, i) + 
+                (char) UnicodeUtil.UNI_SUR_LOW_START;
+            else // SMP already enumerated
+              return s.substring(0, i - 1) + 
+                (char) (UnicodeUtil.UNI_SUR_LOW_END + 1);
+        } else
+        // Unmatched high surrogate in final position, SMP not yet enumerated
+        return s + (char) UnicodeUtil.UNI_SUR_LOW_START;
+      } else if (ch &gt;= UnicodeUtil.UNI_SUR_LOW_START
+          &amp;&amp; ch &lt;= UnicodeUtil.UNI_SUR_LOW_END)
+      // Unmatched low surrogate, SMP already enumerated
+      return s.substring(0, i) + 
+        (char) (UnicodeUtil.UNI_SUR_LOW_END + 1);
+    }
+    
+    return s;
+  }
+  
   // Only called from assert
   /*
   private static boolean matches(char[] source, int offset, int length, byte[] result, int
upto) {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887701 - in /lucene/java/site: docs/ docs/skin/ src/documentation/content/xdocs/</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091206153205.25F6F23889D0@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206153205-25F6F23889D0@eris-apache-org%3e</id>
<updated>2009-12-06T15:32:04Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Sun Dec  6 15:32:03 2009
New Revision: 887701

URL: http://svn.apache.org/viewvc?rev=887701&amp;view=rev
Log:
LUCENE-2116: list #lucene IRC channel on web site

Modified:
    lucene/java/site/docs/developer-resources.html
    lucene/java/site/docs/features.html
    lucene/java/site/docs/index.html
    lucene/java/site/docs/linkmap.html
    lucene/java/site/docs/linkmap.pdf
    lucene/java/site/docs/mailinglists.html
    lucene/java/site/docs/releases.html
    lucene/java/site/docs/skin/basic.css
    lucene/java/site/docs/skin/print.css
    lucene/java/site/docs/skin/profile.css
    lucene/java/site/docs/skin/screen.css
    lucene/java/site/docs/systemrequirements.html
    lucene/java/site/docs/whoweare.html
    lucene/java/site/src/documentation/content/xdocs/site.xml

Modified: lucene/java/site/docs/developer-resources.html
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/developer-resources.html?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/developer-resources.html (original)
+++ lucene/java/site/docs/developer-resources.html Sun Dec  6 15:32:03 2009
@@ -185,6 +185,9 @@
 &lt;div class="menuitem"&gt;
 &lt;a href="http://svn.apache.org/viewcvs.cgi/lucene/java/"&gt;Version Control&lt;/a&gt;
 &lt;/div&gt;
+&lt;div class="menuitem"&gt;
+&lt;a href="irc.html"&gt;IRC Channel&lt;/a&gt;
+&lt;/div&gt;
 &lt;/div&gt;
 &lt;div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle"&gt;Related
Projects&lt;/div&gt;
 &lt;div id="menu_1.4" class="menuitemgroup"&gt;

Modified: lucene/java/site/docs/features.html
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/features.html?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/features.html (original)
+++ lucene/java/site/docs/features.html Sun Dec  6 15:32:03 2009
@@ -185,6 +185,9 @@
 &lt;div class="menuitem"&gt;
 &lt;a href="http://svn.apache.org/viewcvs.cgi/lucene/java/"&gt;Version Control&lt;/a&gt;
 &lt;/div&gt;
+&lt;div class="menuitem"&gt;
+&lt;a href="irc.html"&gt;IRC Channel&lt;/a&gt;
+&lt;/div&gt;
 &lt;/div&gt;
 &lt;div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle"&gt;Related
Projects&lt;/div&gt;
 &lt;div id="menu_1.4" class="menuitemgroup"&gt;

Modified: lucene/java/site/docs/index.html
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/index.html?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/index.html (original)
+++ lucene/java/site/docs/index.html Sun Dec  6 15:32:03 2009
@@ -187,6 +187,9 @@
 &lt;div class="menuitem"&gt;
 &lt;a href="http://svn.apache.org/viewcvs.cgi/lucene/java/"&gt;Version Control&lt;/a&gt;
 &lt;/div&gt;
+&lt;div class="menuitem"&gt;
+&lt;a href="irc.html"&gt;IRC Channel&lt;/a&gt;
+&lt;/div&gt;
 &lt;/div&gt;
 &lt;div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle"&gt;Related
Projects&lt;/div&gt;
 &lt;div id="menu_1.4" class="menuitemgroup"&gt;

Modified: lucene/java/site/docs/linkmap.html
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/linkmap.html?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/linkmap.html (original)
+++ lucene/java/site/docs/linkmap.html Sun Dec  6 15:32:03 2009
@@ -185,6 +185,9 @@
 &lt;div class="menuitem"&gt;
 &lt;a href="http://svn.apache.org/viewcvs.cgi/lucene/java/"&gt;Version Control&lt;/a&gt;
 &lt;/div&gt;
+&lt;div class="menuitem"&gt;
+&lt;a href="irc.html"&gt;IRC Channel&lt;/a&gt;
+&lt;/div&gt;
 &lt;/div&gt;
 &lt;div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle"&gt;Related
Projects&lt;/div&gt;
 &lt;div id="menu_1.4" class="menuitemgroup"&gt;
@@ -408,6 +411,12 @@
 &lt;a href="http://svn.apache.org/viewcvs.cgi/lucene/java/"&gt;Version Control&lt;/a&gt;&amp;nbsp;&amp;nbsp;___________________&amp;nbsp;&amp;nbsp;&lt;em&gt;svn&lt;/em&gt;
 &lt;/li&gt;
 &lt;/ul&gt;
+      
+&lt;ul&gt;
+&lt;li&gt;
+&lt;a href="irc.html"&gt;IRC Channel&lt;/a&gt;&amp;nbsp;&amp;nbsp;___________________&amp;nbsp;&amp;nbsp;&lt;em&gt;irc&lt;/em&gt;
+&lt;/li&gt;
+&lt;/ul&gt;
   
 &lt;/ul&gt;
 &lt;/ul&gt;

Modified: lucene/java/site/docs/linkmap.pdf
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/linkmap.pdf?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/linkmap.pdf (original)
+++ lucene/java/site/docs/linkmap.pdf Sun Dec  6 15:32:03 2009
@@ -20,10 +20,10 @@
 &gt;&gt;
 endobj
 7 0 obj
-&lt;&lt; /Length 782 /Filter [ /ASCII85Decode /FlateDecode ]
+&lt;&lt; /Length 806 /Filter [ /ASCII85Decode /FlateDecode ]
  &gt;&gt;
 stream
-GatUrbAu;j'Sc@2$8#Zu&lt;Hm3@-IYZCTkOk*DG$h%)?F`7m9#)QD]ecfClqS'&gt;Z`"tcN!-"s,h1Dn(g,3Qp:eK[&gt;2Q;_Z6)X#$BB-JdWt&lt;"47VVQn/R&amp;;fI@D8*6_k-a!-c`2!j;;T;L([P9!H2']lmI\u$NLcubTE&gt;![7UqV@f?n3S3KK`,iD^KUke;)76q*cWE9@\%-&amp;mablO9eb(CrJB[.N)&lt;S0l[2M"*:VC-++X%`dC^u^t'pgU_gjl(dd9`&gt;9%d^G('2Kl?T"dC8\B-&lt;Fcr=X6NIB&amp;ucti^d7g&amp;Prd$n*qdhF9:;]Q9,^VT"LBuY+o&lt;'$&amp;N-@L:=CbWC&gt;bKiH2OgD"t:k,io--o&amp;gtRlgR.R\/%+Y&gt;+3XSCMZ:RS/:`s=&gt;I6@9]sR6]33&gt;!ka!r#BFZG&lt;Lib#%t.U&gt;e&gt;+&amp;PF6-u@_H'=u,&gt;W7+H_jXST7nMR*r%#M**,o&amp;56g#X2P_;k;8BTA[gdpJ"YR+!GMVSWR&lt;N&lt;U%5$Ic",Q#"JYG&lt;4bm?cCdie`+RPJLtgmPVK;`",j@hq046-j8-^&gt;J&amp;XlA!1DpZ@uPq7i+!*K$/8%Tc-81kOY97Rf4If?=]f0rr12RAb1BZr\*`m4BuE5(hK/9D$1#!-j?oOAegqb+_Ek0:gAC$gek[02Nl_a%l/Nms0^q0H8%Gnta^CMRF\a0e3hPs$K8=Tt&amp;NC&amp;`=YO_lh;uV\9K(Y*aVQeiLN)$="&lt;l/_d8oqVqa/&lt;?G`f21^Tni&lt;gunQN,qIHfiF#iXp-GIU#I2^W4K'"]C\ImXB2t8~&gt;
+GatUr?'Etb'Sc)J/%Ah;Q3%)M&gt;]u\+ZlQd7C8Nqte"I@2h3b\qg@='eI&amp;mYBY]6UJ*L-.Z*-gGt`SS4R"u(T6`+om7NJ@P_?OSWl#&lt;Ch+,7&lt;ENpi3VcKMB66`XM+(DE]LlO?+_*(mcFl9(S#`@Ak(&gt;p%gHF5=,3MMt44&lt;MkD/2(knhr&gt;"bgc,kbtN8*L8?=t%.A1i''Oc&lt;7.sjUR-?:T:=\'R;!fC)dnBOB=4"16Y$rG;'s!l@l*)fd7^C@o3Ak"`/0VQ/)&amp;oS'0t^&gt;0&lt;D[h5a($^/S+'bSY%*_9bOF?'ZrlnfDqRpSBDrkE:Q`jID[-lBmW"Eb%,RHo_8_MEI6nJ3:DB9?ZBJ4MpCj'O0D!8?7&lt;&lt;]8F0A8tSH--`5nnS90^ROLOR#._4hA+3WZ)9`Dr^1k\&amp;dVWe#LFDT![D`,o.ON;fGeE'D0lu-P-.'r$Rfg1G0LmttY-T&amp;\4os(r.kbD5p`SS:_5)^[p.U5WcWRWf9Jg^:;W85;7o[b9aB(\a-WUN2SmcMKMl^,Od\X#qd_rco56^;KDX2VFR6;ufG-kt;UOfu+%4-OOf!b1&lt;,?m6_HeF87%ECbHg?lrhj[?FoL[m30C!@N"?O?`-NhAD0in'(]2Yr9Jq&lt;G&lt;Pi7f5X?4ZA@!&lt;3HaHaFF&lt;F//pml5UjP'qrZ_bSJJrXA/\6.1E`DG$p)O$Yqbpn@$qjSSXNkj5hWAK@nbbc%"qS5(q6KA`Vri6Rr-^:$_,n+0\f/$+l5`Z&lt;qaB,]h!nJU0(KH76)3q0+ReM&lt;;J5&amp;K5"K&gt;#E?/1`)=_J-s*XVh*5s'H0k~&gt;
 endstream
 endobj
 8 0 obj
@@ -87,19 +87,19 @@
 xref
 0 14
 0000000000 65535 f 
-0000002855 00000 n 
-0000002919 00000 n 
-0000002969 00000 n 
+0000002879 00000 n 
+0000002943 00000 n 
+0000002993 00000 n 
 0000000015 00000 n 
 0000000071 00000 n 
 0000001213 00000 n 
 0000001319 00000 n 
-0000002192 00000 n 
-0000002298 00000 n 
-0000002410 00000 n 
-0000002520 00000 n 
-0000002631 00000 n 
-0000002739 00000 n 
+0000002216 00000 n 
+0000002322 00000 n 
+0000002434 00000 n 
+0000002544 00000 n 
+0000002655 00000 n 
+0000002763 00000 n 
 trailer
 &lt;&lt;
 /Size 14
@@ -107,5 +107,5 @@
 /Info 4 0 R
 &gt;&gt;
 startxref
-3091
+3115
 %%EOF

Modified: lucene/java/site/docs/mailinglists.html
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/mailinglists.html?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/mailinglists.html (original)
+++ lucene/java/site/docs/mailinglists.html Sun Dec  6 15:32:03 2009
@@ -187,6 +187,9 @@
 &lt;div class="menuitem"&gt;
 &lt;a href="http://svn.apache.org/viewcvs.cgi/lucene/java/"&gt;Version Control&lt;/a&gt;
 &lt;/div&gt;
+&lt;div class="menuitem"&gt;
+&lt;a href="irc.html"&gt;IRC Channel&lt;/a&gt;
+&lt;/div&gt;
 &lt;/div&gt;
 &lt;div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle"&gt;Related
Projects&lt;/div&gt;
 &lt;div id="menu_1.4" class="menuitemgroup"&gt;

Modified: lucene/java/site/docs/releases.html
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/releases.html?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/releases.html (original)
+++ lucene/java/site/docs/releases.html Sun Dec  6 15:32:03 2009
@@ -185,6 +185,9 @@
 &lt;div class="menuitem"&gt;
 &lt;a href="http://svn.apache.org/viewcvs.cgi/lucene/java/"&gt;Version Control&lt;/a&gt;
 &lt;/div&gt;
+&lt;div class="menuitem"&gt;
+&lt;a href="irc.html"&gt;IRC Channel&lt;/a&gt;
+&lt;/div&gt;
 &lt;/div&gt;
 &lt;div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle"&gt;Related
Projects&lt;/div&gt;
 &lt;div id="menu_1.4" class="menuitemgroup"&gt;

Modified: lucene/java/site/docs/skin/basic.css
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/skin/basic.css?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/skin/basic.css (original)
+++ lucene/java/site/docs/skin/basic.css Sun Dec  6 15:32:03 2009
@@ -163,4 +163,4 @@
 .codefrag {
   font-family: "Courier New", Courier, monospace;
   font-size: 110%;
-}
+}
\ No newline at end of file

Modified: lucene/java/site/docs/skin/print.css
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/skin/print.css?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/skin/print.css (original)
+++ lucene/java/site/docs/skin/print.css Sun Dec  6 15:32:03 2009
@@ -51,4 +51,4 @@
 
 acronym {
   border: 0;
-}
+}
\ No newline at end of file

Modified: lucene/java/site/docs/skin/profile.css
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/skin/profile.css?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/skin/profile.css (original)
+++ lucene/java/site/docs/skin/profile.css Sun Dec  6 15:32:03 2009
@@ -172,4 +172,4 @@
     }
       
     
-  
+  
\ No newline at end of file

Modified: lucene/java/site/docs/skin/screen.css
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/skin/screen.css?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/skin/screen.css (original)
+++ lucene/java/site/docs/skin/screen.css Sun Dec  6 15:32:03 2009
@@ -584,4 +584,4 @@
   list-style-image: url('../images/instruction_arrow.png');
   list-style-position: outside;
   margin-left: 2em;
-} 
+} 
\ No newline at end of file

Modified: lucene/java/site/docs/systemrequirements.html
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/systemrequirements.html?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/systemrequirements.html (original)
+++ lucene/java/site/docs/systemrequirements.html Sun Dec  6 15:32:03 2009
@@ -185,6 +185,9 @@
 &lt;div class="menuitem"&gt;
 &lt;a href="http://svn.apache.org/viewcvs.cgi/lucene/java/"&gt;Version Control&lt;/a&gt;
 &lt;/div&gt;
+&lt;div class="menuitem"&gt;
+&lt;a href="irc.html"&gt;IRC Channel&lt;/a&gt;
+&lt;/div&gt;
 &lt;/div&gt;
 &lt;div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle"&gt;Related
Projects&lt;/div&gt;
 &lt;div id="menu_1.4" class="menuitemgroup"&gt;

Modified: lucene/java/site/docs/whoweare.html
URL: http://svn.apache.org/viewvc/lucene/java/site/docs/whoweare.html?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/docs/whoweare.html (original)
+++ lucene/java/site/docs/whoweare.html Sun Dec  6 15:32:03 2009
@@ -185,6 +185,9 @@
 &lt;div class="menuitem"&gt;
 &lt;a href="http://svn.apache.org/viewcvs.cgi/lucene/java/"&gt;Version Control&lt;/a&gt;
 &lt;/div&gt;
+&lt;div class="menuitem"&gt;
+&lt;a href="irc.html"&gt;IRC Channel&lt;/a&gt;
+&lt;/div&gt;
 &lt;/div&gt;
 &lt;div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle"&gt;Related
Projects&lt;/div&gt;
 &lt;div id="menu_1.4" class="menuitemgroup"&gt;

Modified: lucene/java/site/src/documentation/content/xdocs/site.xml
URL: http://svn.apache.org/viewvc/lucene/java/site/src/documentation/content/xdocs/site.xml?rev=887701&amp;r1=887700&amp;r2=887701&amp;view=diff
==============================================================================
--- lucene/java/site/src/documentation/content/xdocs/site.xml (original)
+++ lucene/java/site/src/documentation/content/xdocs/site.xml Sun Dec  6 15:32:03 2009
@@ -71,6 +71,7 @@
       &lt;release label="Releases" href="releases.html"/&gt;
       &lt;system label="System Requirements" href="systemrequirements.html"/&gt;
       &lt;svn label="Version Control" href="ext:source" /&gt;
+      &lt;irc label="IRC Channel" href="irc.html" /&gt;
   &lt;/resources&gt;
   &lt;versions label="Site Versions"&gt;
 &lt;!-- Needs to be filled in --&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887693 - in /lucene/java/branches/lucene_2_9: ./ contrib/ contrib/highlighter/src/test/ contrib/spellchecker/src/java/org/apache/lucene/search/spell/ contrib/spellchecker/src/test/org/apache/lucene/search/spell/ src/java/org/apache/lucene/...</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091206152449.47B87238899B@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206152449-47B87238899B@eris-apache-org%3e</id>
<updated>2009-12-06T15:24:48Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Sun Dec  6 15:24:48 2009
New Revision: 887693

URL: http://svn.apache.org/viewvc?rev=887693&amp;view=rev
Log:
LUCENE-2108: backport to 2.9 thread safety of spellchecker

Modified:
    lucene/java/branches/lucene_2_9/   (props changed)
    lucene/java/branches/lucene_2_9/CHANGES.txt   (props changed)
    lucene/java/branches/lucene_2_9/contrib/   (props changed)
    lucene/java/branches/lucene_2_9/contrib/CHANGES.txt   (contents, props changed)
    lucene/java/branches/lucene_2_9/contrib/highlighter/src/test/   (props changed)
    lucene/java/branches/lucene_2_9/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
    lucene/java/branches/lucene_2_9/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
    lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
  (props changed)
    lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
  (props changed)
    lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
  (props changed)
    lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java
  (props changed)
    lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java
  (props changed)
    lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
  (props changed)
    lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/util/TestAttributeSource.java
  (props changed)

Propchange: lucene/java/branches/lucene_2_9/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 15:24:48 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4:748824
 /lucene/java/branches/lucene_3_0:886275
-/lucene/java/trunk:824125,826029,826385,830871,833095,833297,833886,882672,883554,884870,886257
+/lucene/java/trunk:824125,826029,826385,830871,833095,833297,833886,882672,883554,884870,886257,887532

Propchange: lucene/java/branches/lucene_2_9/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 15:24:48 2009
@@ -1 +1 @@
-/lucene/java/trunk/CHANGES.txt:886257
+/lucene/java/trunk/CHANGES.txt:886257,887532

Propchange: lucene/java/branches/lucene_2_9/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 15:24:48 2009
@@ -1 +1 @@
-/lucene/java/trunk/contrib:886257
+/lucene/java/trunk/contrib:886257,887532

Modified: lucene/java/branches/lucene_2_9/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/contrib/CHANGES.txt?rev=887693&amp;r1=887692&amp;r2=887693&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9/contrib/CHANGES.txt (original)
+++ lucene/java/branches/lucene_2_9/contrib/CHANGES.txt Sun Dec  6 15:24:48 2009
@@ -2,6 +2,19 @@
 
 ======================= 2.9 branch (not yet released) =======================
 
+API Changes
+
+ * LUCENE-2108: Add SpellChecker.close, to close the underlying
+   reader.  (Eirik BjÃ¸rsnÃ¸s via Mike McCandless)
+
+New features
+
+ * LUCENE-2108: Spellchecker now safely supports concurrent modifications to
+   the spell-index. Threads can safely obtain term suggestions while the spell-
+   index is rebuild, cleared or reset. Internal IndexSearcher instances remain
+   open until the last thread accessing them releases the reference.
+   (Simon Willnauer)
+
 ======================= Release 2.9.1 2009-11-06 =======================
 
 Changes in backwards compatibility policy

Propchange: lucene/java/branches/lucene_2_9/contrib/CHANGES.txt
            ('svn:mergeinfo' removed)

Propchange: lucene/java/branches/lucene_2_9/contrib/highlighter/src/test/
            ('svn:mergeinfo' removed)

Modified: lucene/java/branches/lucene_2_9/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java?rev=887693&amp;r1=887692&amp;r2=887693&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
(original)
+++ lucene/java/branches/lucene_2_9/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
Sun Dec  6 15:24:48 2009
@@ -17,6 +17,9 @@
  * limitations under the License.
  */
 
+import java.io.IOException;
+import java.util.Iterator;
+
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -25,15 +28,13 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
 
-import java.io.IOException;
-import java.util.Iterator;
-
 /**
  * &lt;p&gt;
  *   Spell Checker class  (Main class) &lt;br/&gt;
@@ -60,10 +61,14 @@
    * Field name for each word in the ngram index.
    */
   public static final String F_WORD = "word";
+  
+  private static final Term F_WORD_TERM = new Term(F_WORD);
 
   /**
    * the spell index
    */
+  // don't modify the directory directly - see #swapSearcher()
+  // TODO: why is this package private?
   Directory spellIndex;
 
   /**
@@ -72,7 +77,22 @@
   private float bStart = 2.0f;
   private float bEnd = 1.0f;
 
+  // don't use this searcher directly - see #swapSearcher()
   private IndexSearcher searcher;
+  
+  /*
+   * this locks all modifications to the current searcher. 
+   */
+  private final Object searcherLock = new Object();
+  
+  /*
+   * this lock synchronizes all possible modifications to the 
+   * current index directory. It should not be possible to try modifying
+   * the same index concurrently. Note: Do not acquire the searcher lock
+   * before acquiring this lock! 
+   */
+  private final Object modifyCurrentIndexLock = new Object();
+  private volatile boolean closed = false;
 
   // minimum score for hits generated by the spell checker query
   private float minScore = 0.5f;
@@ -82,15 +102,24 @@
   /**
    * Use the given directory as a spell checker index. The directory
    * is created if it doesn't exist yet.
+   * @param spellIndex the spell index directory
+   * @param sd the {@link StringDistance} measurement to use 
+   * @throws IOException if Spellchecker can not open the directory
+   */
+  public SpellChecker(Directory spellIndex, StringDistance sd) throws IOException {
+    setSpellIndex(spellIndex);
+    setStringDistance(sd);
+  }
+  /**
+   * Use the given directory as a spell checker index with a
+   * {@link LevensteinDistance} as the default {@link StringDistance}. The
+   * directory is created if it doesn't exist yet.
    * 
    * @param spellIndex
+   *          the spell index directory
    * @throws IOException
+   *           if spellchecker can not open the directory
    */
-  public SpellChecker(Directory spellIndex,StringDistance sd) throws IOException {
-    this.setSpellIndex(spellIndex);
-    this.setStringDistance(sd);
-  }
-
   public SpellChecker(Directory spellIndex) throws IOException {
     this(spellIndex, new LevensteinDistance());
   }
@@ -99,27 +128,41 @@
    * Use a different index as the spell checker index or re-open
    * the existing index if &lt;code&gt;spellIndex&lt;/code&gt; is the same value
    * as given in the constructor.
-   * 
-   * @param spellIndex
-   * @throws IOException
-   */
-  public void setSpellIndex(Directory spellIndex) throws IOException {
-    this.spellIndex = spellIndex;
-    if (!IndexReader.indexExists(spellIndex)) {
-        IndexWriter writer = new IndexWriter(spellIndex, null, true);
-        writer.close();
-    }
-    // close the old searcher, if there was one
-    if (searcher != null) {
-      searcher.close();
+   * @param spellIndexDir the spell directory to use
+   * @throws AlreadyClosedException if the Spellchecker is already closed
+   * @throws  IOException if spellchecker can not open the directory
+   */
+  // TODO: we should make this final as it is called in the constructor
+  public void setSpellIndex(Directory spellIndexDir) throws IOException {
+    // this could be the same directory as the current spellIndex
+    // modifications to the directory should be synchronized 
+    synchronized (modifyCurrentIndexLock) {
+      ensureOpen();
+      if (!IndexReader.indexExists(spellIndexDir)) {
+          IndexWriter writer = new IndexWriter(spellIndexDir, null, true,
+              IndexWriter.MaxFieldLength.UNLIMITED);
+          writer.close();
+      }
+      swapSearcher(spellIndexDir);
     }
-    searcher = new IndexSearcher(this.spellIndex);
   }
-  
+  /**
+   * Sets the {@link StringDistance} implementation for this
+   * {@link SpellChecker} instance.
+   * 
+   * @param sd the {@link StringDistance} implementation for this
+   * {@link SpellChecker} instance
+   */
   public void setStringDistance(StringDistance sd) {
     this.sd = sd;
   }
-
+  /**
+   * Returns the {@link StringDistance} instance used by this
+   * {@link SpellChecker} instance.
+   * 
+   * @return the {@link StringDistance} instance used by this
+   *         {@link SpellChecker} instance.
+   */
   public StringDistance getStringDistance() {
     return sd;
   }
@@ -144,7 +187,8 @@
    *
    * @param word the word you want a spell check done on
    * @param numSug the number of suggested words
-   * @throws IOException
+   * @throws IOException if the underlying index throws an {@link IOException}
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @return String[]
    */
   public String[] suggestSimilar(String word, int numSug) throws IOException {
@@ -169,96 +213,104 @@
    * words are restricted to the words present in this field.
    * @param morePopular return only the suggest words that are as frequent or more frequent
than the searched word
    * (only if restricted mode = (indexReader!=null and field!=null)
-   * @throws IOException
+   * @throws IOException if the underlying index throws an {@link IOException}
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @return String[] the sorted list of the suggest words with these 2 criteria:
    * first criteria: the edit distance, second criteria (only if restricted mode): the popularity
    * of the suggest words in the field of the user index
    */
   public String[] suggestSimilar(String word, int numSug, IndexReader ir,
       String field, boolean morePopular) throws IOException {
-
-    float min = this.minScore;
-    final int lengthWord = word.length();
-
-    final int freq = (ir != null &amp;&amp; field != null) ? ir.docFreq(new Term(field, word))
: 0;
-    final int goalFreq = (morePopular &amp;&amp; ir != null &amp;&amp; field != null) ? freq
: 0;
-    // if the word exists in the real index and we don't care for word frequency, return
the word itself
-    if (!morePopular &amp;&amp; freq &gt; 0) {
-      return new String[] { word };
-    }
-
-    BooleanQuery query = new BooleanQuery();
-    String[] grams;
-    String key;
-
-    for (int ng = getMin(lengthWord); ng &lt;= getMax(lengthWord); ng++) {
-
-      key = "gram" + ng; // form key
-
-      grams = formGrams(word, ng); // form word into ngrams (allow dups too)
-
-      if (grams.length == 0) {
-        continue; // hmm
-      }
-
-      if (bStart &gt; 0) { // should we boost prefixes?
-        add(query, "start" + ng, grams[0], bStart); // matches start of word
-
-      }
-      if (bEnd &gt; 0) { // should we boost suffixes
-        add(query, "end" + ng, grams[grams.length - 1], bEnd); // matches end of word
-
-      }
-      for (int i = 0; i &lt; grams.length; i++) {
-        add(query, key, grams[i]);
-      }
-    }
-
-//    System.out.println("Q: " + query);
-    Hits hits = searcher.search(query);
-//    System.out.println("HITS: " + hits.length());
-    SuggestWordQueue sugQueue = new SuggestWordQueue(numSug);
-
-    // go thru more than 'maxr' matches in case the distance filter triggers
-    int stop = Math.min(hits.length(), 10 * numSug);
-    SuggestWord sugWord = new SuggestWord();
-    for (int i = 0; i &lt; stop; i++) {
-
-      sugWord.string = hits.doc(i).get(F_WORD); // get orig word
-
-      // don't suggest a word for itself, that would be silly
-      if (sugWord.string.equals(word)) {
-        continue;
+    // obtainSearcher calls ensureOpen
+    final IndexSearcher indexSearcher = obtainSearcher();
+    try{
+      float min = this.minScore;
+      final int lengthWord = word.length();
+  
+      final int freq = (ir != null &amp;&amp; field != null) ? ir.docFreq(new Term(field,
word)) : 0;
+      final int goalFreq = (morePopular &amp;&amp; ir != null &amp;&amp; field != null) ?
freq : 0;
+      // if the word exists in the real index and we don't care for word frequency, return
the word itself
+      if (!morePopular &amp;&amp; freq &gt; 0) {
+        return new String[] { word };
       }
-
-      // edit distance
-      sugWord.score = sd.getDistance(word,sugWord.string);
-      if (sugWord.score &lt; min) {
-        continue;
+  
+      BooleanQuery query = new BooleanQuery();
+      String[] grams;
+      String key;
+  
+      for (int ng = getMin(lengthWord); ng &lt;= getMax(lengthWord); ng++) {
+  
+        key = "gram" + ng; // form key
+  
+        grams = formGrams(word, ng); // form word into ngrams (allow dups too)
+  
+        if (grams.length == 0) {
+          continue; // hmm
+        }
+  
+        if (bStart &gt; 0) { // should we boost prefixes?
+          add(query, "start" + ng, grams[0], bStart); // matches start of word
+  
+        }
+        if (bEnd &gt; 0) { // should we boost suffixes
+          add(query, "end" + ng, grams[grams.length - 1], bEnd); // matches end of word
+  
+        }
+        for (int i = 0; i &lt; grams.length; i++) {
+          add(query, key, grams[i]);
+        }
       }
-
-      if (ir != null &amp;&amp; field != null) { // use the user index
-        sugWord.freq = ir.docFreq(new Term(field, sugWord.string)); // freq in the index
-        // don't suggest a word that is not present in the field
-        if ((morePopular &amp;&amp; goalFreq &gt; sugWord.freq) || sugWord.freq &lt; 1) {
+  
+      int maxHits = 10 * numSug;
+      
+  //    System.out.println("Q: " + query);
+      ScoreDoc[] hits = indexSearcher.search(query, null, maxHits).scoreDocs;
+  //    System.out.println("HITS: " + hits.length());
+      SuggestWordQueue sugQueue = new SuggestWordQueue(numSug);
+  
+      // go thru more than 'maxr' matches in case the distance filter triggers
+      int stop = Math.min(hits.length, maxHits);
+      SuggestWord sugWord = new SuggestWord();
+      for (int i = 0; i &lt; stop; i++) {
+  
+        sugWord.string = indexSearcher.doc(hits[i].doc).get(F_WORD); // get orig word
+  
+        // don't suggest a word for itself, that would be silly
+        if (sugWord.string.equals(word)) {
           continue;
         }
+  
+        // edit distance
+        sugWord.score = sd.getDistance(word,sugWord.string);
+        if (sugWord.score &lt; min) {
+          continue;
+        }
+  
+        if (ir != null &amp;&amp; field != null) { // use the user index
+          sugWord.freq = ir.docFreq(new Term(field, sugWord.string)); // freq in the index
+          // don't suggest a word that is not present in the field
+          if ((morePopular &amp;&amp; goalFreq &gt; sugWord.freq) || sugWord.freq &lt; 1)
{
+            continue;
+          }
+        }
+        sugQueue.insertWithOverflow(sugWord);
+        if (sugQueue.size() == numSug) {
+          // if queue full, maintain the minScore score
+          min = ((SuggestWord)sugQueue.top()).score;
+        }
+        sugWord = new SuggestWord();
       }
-      sugQueue.insert(sugWord);
-      if (sugQueue.size() == numSug) {
-        // if queue full, maintain the minScore score
-        min = ((SuggestWord) sugQueue.top()).score;
+  
+      // convert to array string
+      String[] list = new String[sugQueue.size()];
+      for (int i = sugQueue.size() - 1; i &gt;= 0; i--) {
+        list[i] = ((SuggestWord)sugQueue.pop()).string;
       }
-      sugWord = new SuggestWord();
-    }
-
-    // convert to array string
-    String[] list = new String[sugQueue.size()];
-    for (int i = sugQueue.size() - 1; i &gt;= 0; i--) {
-      list[i] = ((SuggestWord) sugQueue.pop()).string;
+  
+      return list;
+    } finally {
+      releaseSearcher(indexSearcher);
     }
-
-    return list;
   }
 
   /**
@@ -295,24 +347,33 @@
   /**
    * Removes all terms from the spell check index.
    * @throws IOException
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    */
   public void clearIndex() throws IOException {
-    IndexWriter writer = new IndexWriter(spellIndex, null, true);
-    writer.close();
-    
-    //close the old searcher
-    searcher.close();
-    searcher = new IndexSearcher(this.spellIndex);
+    synchronized (modifyCurrentIndexLock) {
+      ensureOpen();
+      final Directory dir = this.spellIndex;
+      final IndexWriter writer = new IndexWriter(dir, null, true, IndexWriter.MaxFieldLength.UNLIMITED);
+      writer.close();
+      swapSearcher(dir);
+    }
   }
 
   /**
    * Check whether the word exists in the index.
    * @param word
    * @throws IOException
-   * @return true iff the word exists in the index
+   * @throws AlreadyClosedException if the Spellchecker is already closed
+   * @return true if the word exists in the index
    */
   public boolean exist(String word) throws IOException {
-    return searcher.docFreq(new Term(F_WORD, word)) &gt; 0;
+    // obtainSearcher calls ensureOpen
+    final IndexSearcher indexSearcher = obtainSearcher();
+    try{
+      return indexSearcher.docFreq(F_WORD_TERM.createTerm(word)) &gt; 0;
+    } finally {
+      releaseSearcher(indexSearcher);
+    }
   }
 
   /**
@@ -320,37 +381,42 @@
    * @param dict Dictionary to index
    * @param mergeFactor mergeFactor to use when indexing
    * @param ramMB the max amount or memory in MB to use
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @throws IOException
    */
   public void indexDictionary(Dictionary dict, int mergeFactor, int ramMB) throws IOException
{
-    IndexWriter writer = new IndexWriter(spellIndex, true, new WhitespaceAnalyzer());
-    writer.setMergeFactor(mergeFactor);
-    writer.setRAMBufferSizeMB(ramMB);
-
-    Iterator iter = dict.getWordsIterator();
-    while (iter.hasNext()) {
-      String word = (String) iter.next();
-
-      int len = word.length();
-      if (len &lt; 3) {
-        continue; // too short we bail but "too long" is fine...
-      }
-
-      if (this.exist(word)) { // if the word already exist in the gramindex
-        continue;
-      }
-
-      // ok index the word
-      Document doc = createDocument(word, getMin(len), getMax(len));
-      writer.addDocument(doc);
-    }
-    // close writer
-    writer.optimize();
-    writer.close();
-    // also re-open the spell index to see our own changes when the next suggestion
-    // is fetched:
-    searcher.close();
-    searcher = new IndexSearcher(this.spellIndex);
+    synchronized (modifyCurrentIndexLock) {
+      ensureOpen();
+      final Directory dir = this.spellIndex;
+      final IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(),
+          IndexWriter.MaxFieldLength.UNLIMITED);
+      writer.setMergeFactor(mergeFactor);
+      writer.setRAMBufferSizeMB(ramMB);
+  
+      Iterator iter = dict.getWordsIterator();
+      while (iter.hasNext()) {
+        String word = (String)iter.next();
+  
+        int len = word.length();
+        if (len &lt; 3) {
+          continue; // too short we bail but "too long" is fine...
+        }
+  
+        if (this.exist(word)) { // if the word already exist in the gramindex
+          continue;
+        }
+  
+        // ok index the word
+        Document doc = createDocument(word, getMin(len), getMax(len));
+        writer.addDocument(doc);
+      }
+      // close writer
+      writer.optimize();
+      writer.close();
+      // also re-open the spell index to see our own changes when the next suggestion
+      // is fetched:
+      swapSearcher(dir);
+    }
   }
 
   /**
@@ -362,7 +428,7 @@
     indexDictionary(dict, 300, 10);
   }
 
-  private int getMin(int l) {
+  private static int getMin(int l) {
     if (l &gt; 5) {
       return 3;
     }
@@ -372,7 +438,7 @@
     return 1;
   }
 
-  private int getMax(int l) {
+  private static int getMax(int l) {
     if (l &gt; 5) {
       return 4;
     }
@@ -407,4 +473,84 @@
       }
     }
   }
+  
+  private IndexSearcher obtainSearcher() {
+    synchronized (searcherLock) {
+      ensureOpen();
+      searcher.getIndexReader().incRef();
+      return searcher;
+    }
+  }
+  
+  private void releaseSearcher(final IndexSearcher aSearcher) throws IOException{
+      // don't check if open - always decRef 
+      // don't decrement the private searcher - could have been swapped
+      aSearcher.getIndexReader().decRef();      
+  }
+  
+  private void ensureOpen() {
+    if (closed) {
+      throw new AlreadyClosedException("Spellchecker has been closed");
+    }
+  }
+  
+  /**
+   * Close the IndexSearcher used by this SpellChecker
+   * @throws IOException if the close operation causes an {@link IOException}
+   * @throws AlreadyClosedException if the {@link SpellChecker} is already closed
+   */
+  public void close() throws IOException {
+    synchronized (searcherLock) {
+      ensureOpen();
+      closed = true;
+      if (searcher != null) {
+        searcher.close();
+      }
+      searcher = null;
+    }
+  }
+  
+  private void swapSearcher(final Directory dir) throws IOException {
+    /*
+     * opening a searcher is possibly very expensive.
+     * We rather close it again if the Spellchecker was closed during
+     * this operation than block access to the current searcher while opening.
+     */
+    final IndexSearcher indexSearcher = createSearcher(dir);
+    synchronized (searcherLock) {
+      if(closed){
+        indexSearcher.close();
+        throw new AlreadyClosedException("Spellchecker has been closed");
+      }
+      if (searcher != null) {
+        searcher.close();
+      }
+      // set the spellindex in the sync block - ensure consistency.
+      searcher = indexSearcher;
+      this.spellIndex = dir;
+    }
+  }
+  
+  /**
+   * Creates a new read-only IndexSearcher 
+   * @param dir the directory used to open the searcher
+   * @return a new read-only IndexSearcher
+   * @throws IOException f there is a low-level IO error
+   */
+  // for testing purposes
+  IndexSearcher createSearcher(final Directory dir) throws IOException{
+    return new IndexSearcher(dir, true);
+  }
+  
+  /**
+   * Returns &lt;code&gt;true&lt;/code&gt; if and only if the {@link SpellChecker} is
+   * closed, otherwise &lt;code&gt;false&lt;/code&gt;.
+   * 
+   * @return &lt;code&gt;true&lt;/code&gt; if and only if the {@link SpellChecker} is
+   *         closed, otherwise &lt;code&gt;false&lt;/code&gt;.
+   */
+  boolean isClosed(){
+    return closed;
+  }
+  
 }

Modified: lucene/java/branches/lucene_2_9/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java?rev=887693&amp;r1=887692&amp;r2=887693&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
(original)
+++ lucene/java/branches/lucene_2_9/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
Sun Dec  6 15:24:48 2009
@@ -18,8 +18,10 @@
  */
 
 import java.io.IOException;
-
-import junit.framework.TestCase;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
 
 import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.apache.lucene.document.Document;
@@ -27,9 +29,12 @@
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.English;
+import org.apache.lucene.util.LuceneTestCase;
 
 
 /**
@@ -37,16 +42,18 @@
  *
  *
  */
-public class TestSpellChecker extends TestCase {
-  private SpellChecker spellChecker;
+public class TestSpellChecker extends LuceneTestCase {
+  private SpellCheckerMock spellChecker;
   private Directory userindex, spellindex;
+  private final Random random = newRandom();
+  private List searchers;
 
   protected void setUp() throws Exception {
     super.setUp();
     
     //create a user index
     userindex = new RAMDirectory();
-    IndexWriter writer = new IndexWriter(userindex, new SimpleAnalyzer(), true);
+    IndexWriter writer = new IndexWriter(userindex, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
 
     for (int i = 0; i &lt; 1000; i++) {
       Document doc = new Document();
@@ -55,15 +62,15 @@
       writer.addDocument(doc);
     }
     writer.close();
-
+    searchers = Collections.synchronizedList(new ArrayList());
     // create the spellChecker
     spellindex = new RAMDirectory();
-    spellChecker = new SpellChecker(spellindex);
+    spellChecker = new SpellCheckerMock(spellindex);
   }
 
 
   public void testBuild() throws CorruptIndexException, IOException {
-    IndexReader r = IndexReader.open(userindex);
+    IndexReader r = IndexReader.open(userindex, true);
 
     spellChecker.clearIndex();
 
@@ -74,7 +81,9 @@
     int num_field2 = this.numdoc();
 
     assertEquals(num_field2, num_field1 + 1);
-
+    
+    assertLastSearcherOpen(4);
+    
     checkCommonSuggestions(r);
     checkLevenshteinSuggestions(r);
     
@@ -192,7 +201,7 @@
   }
 
   private int numdoc() throws IOException {
-    IndexReader rs = IndexReader.open(spellindex);
+    IndexReader rs = IndexReader.open(spellindex, true);
     int num = rs.numDocs();
     assertTrue(num != 0);
     //System.out.println("num docs: " + num);
@@ -200,4 +209,198 @@
     return num;
   }
   
+  public void testClose() throws IOException {
+    IndexReader r = IndexReader.open(userindex, true);
+    spellChecker.clearIndex();
+    String field = "field1";
+    addwords(r, "field1");
+    int num_field1 = this.numdoc();
+    addwords(r, "field2");
+    int num_field2 = this.numdoc();
+    assertEquals(num_field2, num_field1 + 1);
+    checkCommonSuggestions(r);
+    assertLastSearcherOpen(4);
+    spellChecker.close();
+    assertSearchersClosed();
+    try {
+      spellChecker.close();
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    try {
+      checkCommonSuggestions(r);
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.clearIndex();
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.indexDictionary(new LuceneDictionary(r, field));
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.setSpellIndex(spellindex);
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    assertEquals(4, searchers.size());
+    assertSearchersClosed();
+  }
+  
+  /*
+   * tests if the internally shared indexsearcher is correctly closed 
+   * when the spellchecker is concurrently accessed and closed.
+   */
+  public void testConcurrentAccess() throws IOException, InterruptedException {
+    assertEquals(1, searchers.size());
+    final IndexReader r = IndexReader.open(userindex, true);
+    spellChecker.clearIndex();
+    assertEquals(2, searchers.size());
+    addwords(r, "field1");
+    assertEquals(3, searchers.size());
+    int num_field1 = this.numdoc();
+    addwords(r, "field2");
+    assertEquals(4, searchers.size());
+    int num_field2 = this.numdoc();
+    assertEquals(num_field2, num_field1 + 1);
+    int numThreads = 5 + this.random.nextInt(5);
+    SpellCheckWorker[] workers = new SpellCheckWorker[numThreads];
+    for (int i = 0; i &lt; numThreads; i++) {
+      SpellCheckWorker spellCheckWorker = new SpellCheckWorker(r);
+      spellCheckWorker.start();
+      workers[i] = spellCheckWorker;
+      
+    }
+    int iterations = 5 + random.nextInt(5);
+    for (int i = 0; i &lt; iterations; i++) {
+      Thread.sleep(100);
+      // concurrently reset the spell index
+      spellChecker.setSpellIndex(this.spellindex);
+      // for debug - prints the internal open searchers 
+      // showSearchersOpen();
+    }
+    
+    spellChecker.close();
+    joinAll(workers, 5000);
+    
+    for (int i = 0; i &lt; workers.length; i++) {
+      assertFalse(workers[i].failed);
+      assertTrue(workers[i].terminated);
+    }
+    // 4 searchers more than iterations
+    // 1. at creation
+    // 2. clearIndex()
+    // 2. and 3. during addwords
+    assertEquals(iterations + 4, searchers.size());
+    assertSearchersClosed();
+    
+  }
+  private void joinAll(SpellCheckWorker[] workers, long timeout)
+      throws InterruptedException {
+    for (int j = 0; j &lt; workers.length; j++) {
+      final long time = System.currentTimeMillis();
+      if (timeout &lt; 0) {
+        // this could be helpful if it fails one day
+        System.err.println("Warning: " + (workers.length - j)
+            + " threads have not joined but joinall timed out");
+        break;
+      }
+      workers[j].join(timeout);
+      timeout -= System.currentTimeMillis() - time;
+    }
+  }
+  
+  private void assertLastSearcherOpen(int numSearchers) {
+    assertEquals(numSearchers, searchers.size());
+    Object[] searcherArray = searchers.toArray();
+    for (int i = 0; i &lt; searcherArray.length; i++) {
+      if (i == searcherArray.length - 1) {
+        assertTrue("expected last searcher open but was closed",
+            ((IndexSearcher)searcherArray[i]).getIndexReader().getRefCount() &gt; 0);
+      } else {
+        assertFalse("expected closed searcher but was open - Index: " + i,
+            ((IndexSearcher)searcherArray[i]).getIndexReader().getRefCount() &gt; 0);
+      }
+    }
+  }
+  
+  private void assertSearchersClosed() {
+    Object[] searcherArray =  searchers.toArray();
+    for (int i = 0; i &lt; searcherArray.length; i++) {
+      assertEquals(0, ((IndexSearcher)searcherArray[i]).getIndexReader().getRefCount());

+    }
+  }
+  
+  private void showSearchersOpen() {
+    int count = 0;
+    Object[] searcherArray = searchers.toArray();
+    for (int i = 0; i &lt; searcherArray.length; i++) {
+      if(((IndexSearcher)searcherArray[i]).getIndexReader().getRefCount() &gt; 0)
+        ++count;
+    } 
+    System.out.println(count);
+  }
+
+  
+  private class SpellCheckWorker extends Thread {
+    private final IndexReader reader;
+    boolean terminated = false;
+    boolean failed = false;
+    
+    SpellCheckWorker(IndexReader reader) {
+      super();
+      this.reader = reader;
+    }
+    
+    public void run() {
+      try {
+        while (true) {
+          try {
+            checkCommonSuggestions(reader);
+          } catch (AlreadyClosedException e) {
+            
+            return;
+          } catch (Throwable e) {
+            
+            e.printStackTrace();
+            failed = true;
+            return;
+          }
+        }
+      } finally {
+        terminated = true;
+      }
+    }
+    
+  }
+  
+  class SpellCheckerMock extends SpellChecker {
+    public SpellCheckerMock(Directory spellIndex) throws IOException {
+      super(spellIndex);
+    }
+
+    public SpellCheckerMock(Directory spellIndex, StringDistance sd)
+        throws IOException {
+      super(spellIndex, sd);
+    }
+
+    IndexSearcher createSearcher(Directory dir) throws IOException {
+      IndexSearcher searcher = super.createSearcher(dir);
+      TestSpellChecker.this.searchers.add(searcher);
+      return searcher;
+    }
+  }
+  
 }

Propchange: lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 15:24:48 2009
@@ -1 +1 @@
-/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:886257
+/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:886257,887532

Propchange: lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 15:24:48 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java:748824
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java:886275
-/lucene/java/trunk/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java:818920,824125,826029,826385,830871,833095,833297,833886,882672,883554,884870
+/lucene/java/trunk/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java:818920,824125,826029,826385,830871,833095,833297,833886,882672,883554,884870,887532

Propchange: lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 15:24:48 2009
@@ -1 +1 @@
-/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:886257
+/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:886257,887532

Propchange: lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 15:24:48 2009
@@ -1 +1 @@
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:886257
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:886257,887532

Propchange: lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 15:24:48 2009
@@ -1 +1 @@
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:886257
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:886257,887532

Propchange: lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 15:24:48 2009
@@ -1 +1 @@
-/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:886257
+/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:886257,887532

Propchange: lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/util/TestAttributeSource.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 15:24:48 2009
@@ -1 +1 @@
-/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:886257
+/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:886257,887532




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887672 - in /lucene/java/branches/flex_1458/src: java/org/apache/lucene/index/ java/org/apache/lucene/index/codecs/preflex/ test/org/apache/lucene/index/</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091206115613.A3BFC23888DD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206115613-A3BFC23888DD@eris-apache-org%3e</id>
<updated>2009-12-06T11:56:13Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Sun Dec  6 11:56:12 2009
New Revision: 887672

URL: http://svn.apache.org/viewvc?rev=887672&amp;view=rev
Log:
LUCENE-2112 (on flex branch): fix bugs in 'flex on non-flex external reader' emulation

Added:
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java   (with
props)
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlexExternalReader.java
  (with props)
Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFields.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyTerms.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFields.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFields.java?rev=887672&amp;r1=887671&amp;r2=887672&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFields.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFields.java Sun
Dec  6 11:56:12 2009
@@ -24,7 +24,6 @@
  *  core. */
 class LegacyFields extends Fields {
   private final IndexReader r;
-  private TermEnum terms;
 
   public LegacyFields(IndexReader r) throws IOException {
     this.r = r;
@@ -37,7 +36,6 @@
 
   @Override
   public Terms terms(String field) throws IOException {
-    // nocommit
     return new LegacyTerms(r, field);
   }
 }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java?rev=887672&amp;r1=887671&amp;r2=887672&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
Sun Dec  6 11:56:12 2009
@@ -65,6 +65,7 @@
     private final String field;
     private TermEnum terms;
     private TermRef current;
+    private final TermRef tr = new TermRef();
 
     LegacyTermsEnum(IndexReader r, String field) throws IOException {
       this.r = r;
@@ -80,24 +81,27 @@
 
     @Override
     public SeekStatus seek(TermRef text) throws IOException {
-
-      // nocommit: too slow?
+      
+      // nocommit -- should we optimize for "silly seek"
+      // cases, here?  ie seek to term you're already on, to
+      // very next term , etc.
       terms.close();
       terms = r.terms(new Term(field, text.toString()));
+
       final Term t = terms.term();
       if (t == null) {
         current = null;
         return SeekStatus.END;
-      } else {
-        final TermRef tr = new TermRef(t.text());
+      } else if (t.field() == field) {
+        tr.copy(t.text());
+        current = tr;
         if (text.termEquals(tr)) {
-          current = tr;
           return SeekStatus.FOUND;
         } else {
-          // nocommit reuse TermRef instance
-          current = tr;
           return SeekStatus.NOT_FOUND;
         }
+      } else {
+        return SeekStatus.END;
       }
     }
 
@@ -114,8 +118,12 @@
     @Override
     public TermRef next() throws IOException {
       if (terms.next()) {
-        // nocommit -- reuse TermRef instance
-        current = new TermRef(terms.term().text());
+        if (terms.term().field == field) {
+          tr.copy(terms.term().text());
+          current = tr;
+        } else {
+          current = null;
+        }
         return current;
       } else {
         current = null;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyTerms.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyTerms.java?rev=887672&amp;r1=887671&amp;r2=887672&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyTerms.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyTerms.java Sun Dec
 6 11:56:12 2009
@@ -17,9 +17,10 @@
  * limitations under the License.
  */
 
-
 import java.io.IOException;
 
+import org.apache.lucene.util.StringHelper;
+
 /** Implements flex API (FieldsEnum/TermsEnum) on top of
  *  pre-flex API.  Used only for IndexReader impls outside
  *  Lucene's core. */
@@ -30,7 +31,7 @@
 
   LegacyTerms(IndexReader r, String field) {
     this.r = r;
-    this.field = field;
+    this.field = StringHelper.intern(field);
   }
 
   @Override

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java?rev=887672&amp;r1=887671&amp;r2=887672&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java Sun
Dec  6 11:56:12 2009
@@ -38,8 +38,6 @@
 import org.apache.lucene.util.BitVector;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.CloseableThreadLocal;
-import org.apache.lucene.util.cache.Cache;
-import org.apache.lucene.util.cache.SimpleLRUCache;
 import org.apache.lucene.index.codecs.Codecs;
 import org.apache.lucene.index.codecs.Codec;
 import org.apache.lucene.index.codecs.preflex.PreFlexFields;
@@ -923,31 +921,6 @@
       return new LegacyTermPositions();
   }
 
-  private final CloseableThreadLocal perThread = new CloseableThreadLocal();
-
-  // nocommit -- move term vectors under here
-  private static final class PerThread {
-    LegacyTermEnum terms;
-    
-    // Used for caching the least recently looked-up Terms
-    Cache termsCache;
-  }
-
-  private final static int DEFAULT_TERMS_CACHE_SIZE = 1024;
-
-  private PerThread getPerThread() throws IOException {
-    PerThread resources = (PerThread) perThread.get();
-    if (resources == null) {
-      resources = new PerThread();
-      resources.terms = new LegacyTermEnum(null);
-      // Cache does not have to be thread-safe, it is only used by one thread at the same
time
-      resources.termsCache = new SimpleLRUCache(DEFAULT_TERMS_CACHE_SIZE);
-      perThread.set(resources);
-    }
-    return resources;
-  }
-
-  
   @Override
   public int docFreq(Term t) throws IOException {
     ensureOpen();
@@ -1354,13 +1327,14 @@
     TermRef currentTerm;
 
     public LegacyTermEnum(Term t) throws IOException {
-      //System.out.println("sr.lte.init: term=" + t);
+      // System.out.println("sr.lte.init: term=" + t);
       fields = core.fields.iterator();
       currentField = fields.next();
       if (currentField == null) {
+        // no fields
         done = true;
       } else if (t != null) {
-        // Pre-seek
+        // Pre-seek to this term
 
         // nocommit -- inefficient; do we need
         // FieldsEnum.seek? (but this is slow only for
@@ -1375,29 +1349,43 @@
         }
 
         if (!done) {
-          if (currentField == t.field) {
-            // Field matches -- get terms
-            terms = fields.terms();
+          // We found some field -- get its terms:
+          terms = fields.terms();
+
+          if (currentField.equals(t.field)) {
+            // We found exactly the requested field; now
+            // seek the term text:
             String text = t.text();
             TermRef tr;
+
             // this is a hack only for backwards compatibility.
             // previously you could supply a term ending with a lead surrogate,
             // and it would return the next Term.
             // if someone does this, tack on the lowest possible trail surrogate.
             // this emulates the old behavior, and forms "valid UTF-8" unicode.
             if (text.length() &gt; 0 
-                &amp;&amp; Character.isHighSurrogate(text.charAt(text.length() - 1)))
+                &amp;&amp; Character.isHighSurrogate(text.charAt(text.length() - 1))) {
               tr = new TermRef(t.text() + "\uDC00");
-            else
+            } else {
               tr = new TermRef(t.text());
+            }
             TermsEnum.SeekStatus status = terms.seek(tr);
             if (status == TermsEnum.SeekStatus.END) {
-              // leave currentTerm null
+              // Rollover to the next field
+              terms = null;
+              next();
             } else if (status == TermsEnum.SeekStatus.FOUND) {
+              // Found exactly the term
               currentTerm = tr;
             } else {
+              // Found another term, in this same field
               currentTerm = terms.term();
             }
+          } else {
+            // We didn't find exact field (we found the
+            // following field); advance to first term in
+            // this field
+            next();
           }
         }
       } else {
@@ -1433,7 +1421,8 @@
           // This field still has terms
           return true;
         } else {
-          // Done producing terms from this field
+          // Done producing terms from this field; advance
+          // to next field
           terms = null;
         }
       }
@@ -1441,10 +1430,8 @@
 
     @Override
     public Term term() {
-      if (terms != null &amp;&amp; !done) {
-        if (currentTerm != null) {
-          return new Term(currentField, currentTerm.toString());
-        }
+      if (!done &amp;&amp; terms != null &amp;&amp; currentTerm != null) {
+        return new Term(currentField, currentTerm.toString());
       }
       return null;
     }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java?rev=887672&amp;r1=887671&amp;r2=887672&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
Sun Dec  6 11:56:12 2009
@@ -58,6 +58,7 @@
   private final int readBufferSize;
   private Directory cfsReader;
 
+  // nocommit -- we need the legacy terms cache back in here
   PreFlexFields(Directory dir, FieldInfos fieldInfos, SegmentInfo info, int readBufferSize,
int indexDivisor)
     throws IOException {
 
@@ -364,6 +365,7 @@
 
     @Override
     public DocsEnum docs(Bits skipDocs) throws IOException {
+      // nocommit -- reuse?
       return new PreDocsEnum(skipDocs, terms);
     }
   }

Added: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java?rev=887672&amp;view=auto
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java (added)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java Sun Dec
 6 11:56:12 2009
@@ -0,0 +1,60 @@
+package org.apache.lucene.index;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.*;
+import java.util.*;
+import org.apache.lucene.store.*;
+import org.apache.lucene.search.*;
+import org.apache.lucene.analysis.*;
+import org.apache.lucene.document.*;
+import org.apache.lucene.util.*;
+
+public class TestFlex extends LuceneTestCase {
+
+  // Test non-flex API emulated on flex index
+  public void testNonFlex() throws Exception {
+    Directory d = new MockRAMDirectory();
+
+    final int DOC_COUNT = 177;
+
+    IndexWriter w = new IndexWriter(d, new WhitespaceAnalyzer(),
+                                    IndexWriter.MaxFieldLength.UNLIMITED);
+    w.setMaxBufferedDocs(7);
+    Document doc = new Document();
+    doc.add(new Field("field1", "this is field1", Field.Store.NO, Field.Index.ANALYZED));
+    doc.add(new Field("field2", "this is field2", Field.Store.NO, Field.Index.ANALYZED));
+    doc.add(new Field("field3", "aaa", Field.Store.NO, Field.Index.ANALYZED));
+    doc.add(new Field("field4", "bbb", Field.Store.NO, Field.Index.ANALYZED));
+    for(int i=0;i&lt;DOC_COUNT;i++) {
+      w.addDocument(doc);
+    }
+
+    IndexReader r = w.getReader();
+
+    TermEnum terms = r.terms(new Term("field3", "bbb"));
+    // pre-flex API should seek to the next field
+    assertNotNull(terms.term());
+    assertEquals("field4", terms.term().field());
+
+    r.close();
+    w.close();
+    d.close();
+  }
+}
+

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlexExternalReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlexExternalReader.java?rev=887672&amp;view=auto
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlexExternalReader.java
(added)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlexExternalReader.java
Sun Dec  6 11:56:12 2009
@@ -0,0 +1,182 @@
+package org.apache.lucene.index;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.*;
+import java.util.*;
+import org.apache.lucene.store.*;
+import org.apache.lucene.search.*;
+import org.apache.lucene.analysis.*;
+import org.apache.lucene.document.*;
+import org.apache.lucene.util.*;
+
+public class TestFlexExternalReader extends LuceneTestCase {
+
+  // Delegates to a "normal" IndexReader, making it look
+  // "external", to force testing of the "flex API on
+  // external reader" layer
+  private final static class ExternalReader extends IndexReader {
+    private final IndexReader r;
+    public ExternalReader(IndexReader r) {
+      this.r = r;
+    }
+
+    public TermFreqVector[] getTermFreqVectors(int docNumber) throws IOException {
+      return r.getTermFreqVectors(docNumber);
+    }
+
+    public TermFreqVector getTermFreqVector(int docNumber, String field) throws IOException
{
+      return r.getTermFreqVector(docNumber, field);
+    }
+
+    public void getTermFreqVector(int docNumber, String field, TermVectorMapper mapper) throws
IOException {
+      r.getTermFreqVector(docNumber, field, mapper);
+    }
+
+    public void getTermFreqVector(int docNumber, TermVectorMapper mapper) throws IOException
{
+      r.getTermFreqVector(docNumber, mapper);
+    }
+
+    public int numDocs() {
+      return r.numDocs();
+    }
+
+    public int maxDoc() {
+      return r.maxDoc();
+    }
+
+    public Document document(int n, FieldSelector fieldSelector) throws CorruptIndexException,
IOException {
+      return r.document(n, fieldSelector);
+    }
+
+    public boolean isDeleted(int n) {
+      return r.isDeleted(n);
+    }
+
+    public boolean hasDeletions() {
+      return r.hasDeletions();
+    }
+
+    public byte[] norms(String field) throws IOException {
+      return r.norms(field);
+    }
+
+    public void norms(String field, byte[] bytes, int offset) 
+      throws IOException {
+      r.norms(field, bytes, offset);
+    }
+    
+    protected  void doSetNorm(int doc, String field, byte value)
+      throws CorruptIndexException, IOException {
+      r.doSetNorm(doc, field, value);
+    }
+
+    public TermEnum terms() throws IOException {
+      return r.terms();
+    }
+
+    public TermEnum terms(Term t) throws IOException {
+      return r.terms(t);
+    }
+
+    public int docFreq(Term t) throws IOException {
+      return r.docFreq(t);
+    }
+
+    public TermDocs termDocs() throws IOException {
+      return r.termDocs();
+    }
+
+    public TermPositions termPositions() throws IOException {
+      return r.termPositions();
+    }
+
+    public void doDelete(int docID) throws IOException {
+      r.doDelete(docID);
+    }
+
+    public void doUndeleteAll() throws IOException {
+      r.doUndeleteAll();
+    }
+
+    protected void doCommit(Map&lt;String, String&gt; commitUserData) throws IOException
{
+      r.doCommit(commitUserData);
+    }
+
+    protected void doClose() throws IOException {
+      r.doClose();
+    }
+
+    public Collection&lt;String&gt; getFieldNames(FieldOption fldOption) {
+      return r.getFieldNames(fldOption);
+    }
+  }
+
+  public void testExternalReader() throws Exception {
+    Directory d = new MockRAMDirectory();
+
+    final int DOC_COUNT = 177;
+
+    IndexWriter w = new IndexWriter(d, new WhitespaceAnalyzer(),
+                                    IndexWriter.MaxFieldLength.UNLIMITED);
+    w.setMaxBufferedDocs(7);
+    Document doc = new Document();
+    doc.add(new Field("field1", "this is field1", Field.Store.NO, Field.Index.ANALYZED));
+    doc.add(new Field("field2", "this is field2", Field.Store.NO, Field.Index.ANALYZED));
+    doc.add(new Field("field3", "aaa", Field.Store.NO, Field.Index.ANALYZED));
+    doc.add(new Field("field4", "bbb", Field.Store.NO, Field.Index.ANALYZED));
+    for(int i=0;i&lt;DOC_COUNT;i++) {
+      w.addDocument(doc);
+    }
+
+    IndexReader r = new ExternalReader(w.getReader());
+
+    TermRef field1Term = new TermRef("field1");
+    TermRef field2Term = new TermRef("field2");
+
+    assertEquals(DOC_COUNT, r.maxDoc());
+    assertEquals(DOC_COUNT, r.numDocs());
+    assertEquals(DOC_COUNT, r.docFreq(new Term("field1", "field1")));
+    assertEquals(DOC_COUNT, r.docFreq("field1", field1Term));
+
+    Fields fields = r.fields();
+    Terms terms = fields.terms("field1");
+    TermsEnum termsEnum = terms.iterator();
+    assertEquals(TermsEnum.SeekStatus.FOUND, termsEnum.seek(field1Term));
+
+    assertEquals(TermsEnum.SeekStatus.NOT_FOUND, termsEnum.seek(field2Term));
+    assertTrue(new TermRef("is").termEquals(termsEnum.term()));
+
+    terms = fields.terms("field2");
+    termsEnum = terms.iterator();
+    assertEquals(TermsEnum.SeekStatus.NOT_FOUND, termsEnum.seek(field1Term));
+    assertTrue(termsEnum.term().termEquals(field2Term));
+
+    assertEquals(TermsEnum.SeekStatus.FOUND, termsEnum.seek(field2Term));
+
+    termsEnum = fields.terms("field3").iterator();
+    assertEquals(TermsEnum.SeekStatus.END, termsEnum.seek(new TermRef("bbb")));
+
+    assertEquals(TermsEnum.SeekStatus.FOUND, termsEnum.seek(new TermRef("aaa")));
+    assertNull(termsEnum.next());
+
+    r.close();
+    w.close();
+    d.close();
+  }
+}

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlexExternalReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java?rev=887672&amp;r1=887671&amp;r2=887672&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java
(original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java
Sun Dec  6 11:56:12 2009
@@ -28,6 +28,8 @@
 
 import junit.framework.TestCase;
 
+// nocommit -- cut test over to flex API, but not too soon
+// (it catches bugs in emulation)
 public class TestStressIndexing2 extends LuceneTestCase {
   static int maxFields=4;
   static int bigFieldSize=10;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887670 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/search/IndexSearcher.java src/java/org/apache/lucene/util/PriorityQueue.java</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091206114126.C6E7423888DD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206114126-C6E7423888DD@eris-apache-org%3e</id>
<updated>2009-12-06T11:41:26Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Sun Dec  6 11:41:26 2009
New Revision: 887670

URL: http://svn.apache.org/viewvc?rev=887670&amp;view=rev
Log:
LUCENE-2119: behave better if you pass Integer.MAX_VALUE as nDcos to search methods

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java
    lucene/java/trunk/src/java/org/apache/lucene/util/PriorityQueue.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=887670&amp;r1=887669&amp;r2=887670&amp;view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Sun Dec  6 11:41:26 2009
@@ -32,6 +32,10 @@
   one of the threads before all changes are actually committed.
   (Sanne Grinovero via Mike McCandless)
 
+* LUCENE-2119: Don't throw NegativeArraySizeException if you pass
+  Integer.MAX_VALUE as nDocs to IndexSearcher search methods.  (Paul
+  Taylor via Mike McCandless)
+
 New features
 
 * LUCENE-2069: Added Unicode 4 support to CharArraySet. Due to the switch

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java?rev=887670&amp;r1=887669&amp;r2=887670&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java Sun Dec  6 11:41:26
2009
@@ -158,12 +158,14 @@
 
   // inherit javadoc
   @Override
-  public TopDocs search(Weight weight, Filter filter, final int nDocs) throws IOException
{
+  public TopDocs search(Weight weight, Filter filter, int nDocs) throws IOException {
 
     if (nDocs &lt;= 0) {
       throw new IllegalArgumentException("nDocs must be &gt; 0");
     }
 
+    nDocs = Math.min(nDocs, reader.maxDoc());
+
     TopScoreDocCollector collector = TopScoreDocCollector.create(nDocs, !weight.scoresDocsOutOfOrder());
     search(weight, filter, collector);
     return collector.topDocs();
@@ -186,9 +188,12 @@
    * then pass that to {@link #search(Weight, Filter,
    * Collector)}.&lt;/p&gt;
    */
-  public TopFieldDocs search(Weight weight, Filter filter, final int nDocs,
+  public TopFieldDocs search(Weight weight, Filter filter, int nDocs,
                              Sort sort, boolean fillFields)
       throws IOException {
+
+    nDocs = Math.min(nDocs, reader.maxDoc());
+
     TopFieldCollector collector = TopFieldCollector.create(sort, nDocs,
         fillFields, fieldSortDoTrackScores, fieldSortDoMaxScore, !weight.scoresDocsOutOfOrder());
     search(weight, filter, collector);

Modified: lucene/java/trunk/src/java/org/apache/lucene/util/PriorityQueue.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/util/PriorityQueue.java?rev=887670&amp;r1=887669&amp;r2=887670&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/util/PriorityQueue.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/util/PriorityQueue.java Sun Dec  6 11:41:26
2009
@@ -85,8 +85,18 @@
     if (0 == maxSize)
       // We allocate 1 extra to avoid if statement in top()
       heapSize = 2;
-    else
-      heapSize = maxSize + 1;
+    else {
+      if (maxSize == Integer.MAX_VALUE) {
+        // Don't wrap heapSize to -1, in this case, which
+        // causes a confusing NegativeArraySizeException.
+        // Note that very likely this will simply then hit
+        // an OOME, but at least that's more indicative to
+        // caller that this values is too big:
+        heapSize = Integer.MAX_VALUE;
+      } else {
+        heapSize = maxSize + 1;
+      }
+    }
     heap = (T[]) new Object[heapSize]; // T is unbounded type, so this unchecked cast works
always
     this.maxSize = maxSize;
     




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887655 - in /lucene/java/branches/lucene_3_0: ./ contrib/ contrib/highlighter/src/test/ contrib/spellchecker/src/java/org/apache/lucene/search/spell/ contrib/spellchecker/src/test/org/apache/lucene/search/spell/ src/java/org/apache/lucene/...</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091206101728.6E64723888FD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206101728-6E64723888FD@eris-apache-org%3e</id>
<updated>2009-12-06T10:17:27Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Sun Dec  6 10:17:26 2009
New Revision: 887655

URL: http://svn.apache.org/viewvc?rev=887655&amp;view=rev
Log:
LUCENE-2108 (on 3.0 branch): throw ACE if you use spellchecker after closing; make contrib/spellchecker
thread safe

Modified:
    lucene/java/branches/lucene_3_0/   (props changed)
    lucene/java/branches/lucene_3_0/CHANGES.txt   (props changed)
    lucene/java/branches/lucene_3_0/build.xml   (props changed)
    lucene/java/branches/lucene_3_0/contrib/   (props changed)
    lucene/java/branches/lucene_3_0/contrib/CHANGES.txt   (contents, props changed)
    lucene/java/branches/lucene_3_0/contrib/highlighter/src/test/   (props changed)
    lucene/java/branches/lucene_3_0/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
    lucene/java/branches/lucene_3_0/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java
  (props changed)

Propchange: lucene/java/branches/lucene_3_0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4:748824
 /lucene/java/branches/lucene_2_9:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests:818601-821336
-/lucene/java/trunk:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602
+/lucene/java/trunk:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887532,887602

Propchange: lucene/java/branches/lucene_3_0/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/CHANGES.txt:748824
 /lucene/java/branches/lucene_2_9/CHANGES.txt:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/CHANGES.txt:818601-821336
-/lucene/java/trunk/CHANGES.txt:881213,881315,881466,882374,882464,882672,882807,882888,882977,883074-883075,883554,883654,883661,884870,886257,886911,887602
+/lucene/java/trunk/CHANGES.txt:881213,881315,881466,882374,882464,882672,882807,882888,882977,883074-883075,883554,883654,883661,884870,886257,886911,887532,887602

Propchange: lucene/java/branches/lucene_3_0/build.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/build.xml:748824
 /lucene/java/branches/lucene_2_9/build.xml:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/build.xml:818601-821336
-/lucene/java/trunk/build.xml:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887617
+/lucene/java/trunk/build.xml:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887532,887617

Propchange: lucene/java/branches/lucene_3_0/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib:748824
 /lucene/java/branches/lucene_2_9/contrib:817269-818600,825998,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib:818601-821336
-/lucene/java/trunk/contrib:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602
+/lucene/java/trunk/contrib:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887532,887602

Modified: lucene/java/branches/lucene_3_0/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/contrib/CHANGES.txt?rev=887655&amp;r1=887654&amp;r2=887655&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/contrib/CHANGES.txt (original)
+++ lucene/java/branches/lucene_3_0/contrib/CHANGES.txt Sun Dec  6 10:17:26 2009
@@ -7,6 +7,14 @@
  * LUCENE-2108: Add SpellChecker.close, to close the underlying
    reader.  (Eirik BjÃ¸rsnÃ¸s via Mike McCandless)
 
+New features
+
+ * LUCENE-2108: Spellchecker now safely supports concurrent modifications to
+   the spell-index. Threads can safely obtain term suggestions while the spell-
+   index is rebuild, cleared or reset. Internal IndexSearcher instances remain
+   open until the last thread accessing them releases the reference.
+   (Simon Willnauer)
+
 ======================= Release 3.0.0 2009-11-25 =======================
 
 Changes in backwards compatibility policy

Propchange: lucene/java/branches/lucene_3_0/contrib/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib/CHANGES.txt:748824
 /lucene/java/branches/lucene_2_9/contrib/CHANGES.txt:817269-818600,825998,826775,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/CHANGES.txt:818601-821336
-/lucene/java/trunk/contrib/CHANGES.txt:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602
+/lucene/java/trunk/contrib/CHANGES.txt:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887532,887602

Propchange: lucene/java/branches/lucene_3_0/contrib/highlighter/src/test/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib/highlighter/src/test:748824
 /lucene/java/branches/lucene_2_9/contrib/highlighter/src/test:817269-818600,825998,826775,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/highlighter/src/test:818601-821336
-/lucene/java/trunk/contrib/highlighter/src/test:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602
+/lucene/java/trunk/contrib/highlighter/src/test:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887532,887602

Modified: lucene/java/branches/lucene_3_0/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java?rev=887655&amp;r1=887654&amp;r2=887655&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
(original)
+++ lucene/java/branches/lucene_3_0/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
Sun Dec  6 10:17:26 2009
@@ -32,6 +32,7 @@
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
 
 /**
@@ -60,10 +61,14 @@
    * Field name for each word in the ngram index.
    */
   public static final String F_WORD = "word";
+  
+  private static final Term F_WORD_TERM = new Term(F_WORD);
 
   /**
    * the spell index
    */
+  // don't modify the directory directly - see #swapSearcher()
+  // TODO: why is this package private?
   Directory spellIndex;
 
   /**
@@ -72,7 +77,22 @@
   private float bStart = 2.0f;
   private float bEnd = 1.0f;
 
+  // don't use this searcher directly - see #swapSearcher()
   private IndexSearcher searcher;
+  
+  /*
+   * this locks all modifications to the current searcher. 
+   */
+  private final Object searcherLock = new Object();
+  
+  /*
+   * this lock synchronizes all possible modifications to the 
+   * current index directory. It should not be possible to try modifying
+   * the same index concurrently. Note: Do not acquire the searcher lock
+   * before acquiring this lock! 
+   */
+  private final Object modifyCurrentIndexLock = new Object();
+  private volatile boolean closed = false;
 
   // minimum score for hits generated by the spell checker query
   private float minScore = 0.5f;
@@ -82,15 +102,24 @@
   /**
    * Use the given directory as a spell checker index. The directory
    * is created if it doesn't exist yet.
+   * @param spellIndex the spell index directory
+   * @param sd the {@link StringDistance} measurement to use 
+   * @throws IOException if Spellchecker can not open the directory
+   */
+  public SpellChecker(Directory spellIndex, StringDistance sd) throws IOException {
+    setSpellIndex(spellIndex);
+    setStringDistance(sd);
+  }
+  /**
+   * Use the given directory as a spell checker index with a
+   * {@link LevensteinDistance} as the default {@link StringDistance}. The
+   * directory is created if it doesn't exist yet.
    * 
    * @param spellIndex
+   *          the spell index directory
    * @throws IOException
+   *           if spellchecker can not open the directory
    */
-  public SpellChecker(Directory spellIndex,StringDistance sd) throws IOException {
-    this.setSpellIndex(spellIndex);
-    this.setStringDistance(sd);
-  }
-
   public SpellChecker(Directory spellIndex) throws IOException {
     this(spellIndex, new LevensteinDistance());
   }
@@ -99,27 +128,41 @@
    * Use a different index as the spell checker index or re-open
    * the existing index if &lt;code&gt;spellIndex&lt;/code&gt; is the same value
    * as given in the constructor.
-   * 
-   * @param spellIndex
-   * @throws IOException
-   */
-  public void setSpellIndex(Directory spellIndex) throws IOException {
-    this.spellIndex = spellIndex;
-    if (!IndexReader.indexExists(spellIndex)) {
-        IndexWriter writer = new IndexWriter(spellIndex, null, true, IndexWriter.MaxFieldLength.UNLIMITED);
-        writer.close();
-    }
-    // close the old searcher, if there was one
-    if (searcher != null) {
-      searcher.close();
+   * @param spellIndexDir the spell directory to use
+   * @throws AlreadyClosedException if the Spellchecker is already closed
+   * @throws  IOException if spellchecker can not open the directory
+   */
+  // TODO: we should make this final as it is called in the constructor
+  public void setSpellIndex(Directory spellIndexDir) throws IOException {
+    // this could be the same directory as the current spellIndex
+    // modifications to the directory should be synchronized 
+    synchronized (modifyCurrentIndexLock) {
+      ensureOpen();
+      if (!IndexReader.indexExists(spellIndexDir)) {
+          IndexWriter writer = new IndexWriter(spellIndexDir, null, true,
+              IndexWriter.MaxFieldLength.UNLIMITED);
+          writer.close();
+      }
+      swapSearcher(spellIndexDir);
     }
-    searcher = new IndexSearcher(this.spellIndex, true);
   }
-  
+  /**
+   * Sets the {@link StringDistance} implementation for this
+   * {@link SpellChecker} instance.
+   * 
+   * @param sd the {@link StringDistance} implementation for this
+   * {@link SpellChecker} instance
+   */
   public void setStringDistance(StringDistance sd) {
     this.sd = sd;
   }
-
+  /**
+   * Returns the {@link StringDistance} instance used by this
+   * {@link SpellChecker} instance.
+   * 
+   * @return the {@link StringDistance} instance used by this
+   *         {@link SpellChecker} instance.
+   */
   public StringDistance getStringDistance() {
     return sd;
   }
@@ -144,7 +187,8 @@
    *
    * @param word the word you want a spell check done on
    * @param numSug the number of suggested words
-   * @throws IOException
+   * @throws IOException if the underlying index throws an {@link IOException}
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @return String[]
    */
   public String[] suggestSimilar(String word, int numSug) throws IOException {
@@ -169,98 +213,104 @@
    * words are restricted to the words present in this field.
    * @param morePopular return only the suggest words that are as frequent or more frequent
than the searched word
    * (only if restricted mode = (indexReader!=null and field!=null)
-   * @throws IOException
+   * @throws IOException if the underlying index throws an {@link IOException}
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @return String[] the sorted list of the suggest words with these 2 criteria:
    * first criteria: the edit distance, second criteria (only if restricted mode): the popularity
    * of the suggest words in the field of the user index
    */
   public String[] suggestSimilar(String word, int numSug, IndexReader ir,
       String field, boolean morePopular) throws IOException {
-
-    float min = this.minScore;
-    final int lengthWord = word.length();
-
-    final int freq = (ir != null &amp;&amp; field != null) ? ir.docFreq(new Term(field, word))
: 0;
-    final int goalFreq = (morePopular &amp;&amp; ir != null &amp;&amp; field != null) ? freq
: 0;
-    // if the word exists in the real index and we don't care for word frequency, return
the word itself
-    if (!morePopular &amp;&amp; freq &gt; 0) {
-      return new String[] { word };
-    }
-
-    BooleanQuery query = new BooleanQuery();
-    String[] grams;
-    String key;
-
-    for (int ng = getMin(lengthWord); ng &lt;= getMax(lengthWord); ng++) {
-
-      key = "gram" + ng; // form key
-
-      grams = formGrams(word, ng); // form word into ngrams (allow dups too)
-
-      if (grams.length == 0) {
-        continue; // hmm
-      }
-
-      if (bStart &gt; 0) { // should we boost prefixes?
-        add(query, "start" + ng, grams[0], bStart); // matches start of word
-
-      }
-      if (bEnd &gt; 0) { // should we boost suffixes
-        add(query, "end" + ng, grams[grams.length - 1], bEnd); // matches end of word
-
-      }
-      for (int i = 0; i &lt; grams.length; i++) {
-        add(query, key, grams[i]);
-      }
-    }
-
-    int maxHits = 10 * numSug;
-    
-//    System.out.println("Q: " + query);
-    ScoreDoc[] hits = searcher.search(query, null, maxHits).scoreDocs;
-//    System.out.println("HITS: " + hits.length());
-    SuggestWordQueue sugQueue = new SuggestWordQueue(numSug);
-
-    // go thru more than 'maxr' matches in case the distance filter triggers
-    int stop = Math.min(hits.length, maxHits);
-    SuggestWord sugWord = new SuggestWord();
-    for (int i = 0; i &lt; stop; i++) {
-
-      sugWord.string = searcher.doc(hits[i].doc).get(F_WORD); // get orig word
-
-      // don't suggest a word for itself, that would be silly
-      if (sugWord.string.equals(word)) {
-        continue;
+    // obtainSearcher calls ensureOpen
+    final IndexSearcher indexSearcher = obtainSearcher();
+    try{
+      float min = this.minScore;
+      final int lengthWord = word.length();
+  
+      final int freq = (ir != null &amp;&amp; field != null) ? ir.docFreq(new Term(field,
word)) : 0;
+      final int goalFreq = (morePopular &amp;&amp; ir != null &amp;&amp; field != null) ?
freq : 0;
+      // if the word exists in the real index and we don't care for word frequency, return
the word itself
+      if (!morePopular &amp;&amp; freq &gt; 0) {
+        return new String[] { word };
       }
-
-      // edit distance
-      sugWord.score = sd.getDistance(word,sugWord.string);
-      if (sugWord.score &lt; min) {
-        continue;
+  
+      BooleanQuery query = new BooleanQuery();
+      String[] grams;
+      String key;
+  
+      for (int ng = getMin(lengthWord); ng &lt;= getMax(lengthWord); ng++) {
+  
+        key = "gram" + ng; // form key
+  
+        grams = formGrams(word, ng); // form word into ngrams (allow dups too)
+  
+        if (grams.length == 0) {
+          continue; // hmm
+        }
+  
+        if (bStart &gt; 0) { // should we boost prefixes?
+          add(query, "start" + ng, grams[0], bStart); // matches start of word
+  
+        }
+        if (bEnd &gt; 0) { // should we boost suffixes
+          add(query, "end" + ng, grams[grams.length - 1], bEnd); // matches end of word
+  
+        }
+        for (int i = 0; i &lt; grams.length; i++) {
+          add(query, key, grams[i]);
+        }
       }
-
-      if (ir != null &amp;&amp; field != null) { // use the user index
-        sugWord.freq = ir.docFreq(new Term(field, sugWord.string)); // freq in the index
-        // don't suggest a word that is not present in the field
-        if ((morePopular &amp;&amp; goalFreq &gt; sugWord.freq) || sugWord.freq &lt; 1) {
+  
+      int maxHits = 10 * numSug;
+      
+  //    System.out.println("Q: " + query);
+      ScoreDoc[] hits = indexSearcher.search(query, null, maxHits).scoreDocs;
+  //    System.out.println("HITS: " + hits.length());
+      SuggestWordQueue sugQueue = new SuggestWordQueue(numSug);
+  
+      // go thru more than 'maxr' matches in case the distance filter triggers
+      int stop = Math.min(hits.length, maxHits);
+      SuggestWord sugWord = new SuggestWord();
+      for (int i = 0; i &lt; stop; i++) {
+  
+        sugWord.string = indexSearcher.doc(hits[i].doc).get(F_WORD); // get orig word
+  
+        // don't suggest a word for itself, that would be silly
+        if (sugWord.string.equals(word)) {
           continue;
         }
+  
+        // edit distance
+        sugWord.score = sd.getDistance(word,sugWord.string);
+        if (sugWord.score &lt; min) {
+          continue;
+        }
+  
+        if (ir != null &amp;&amp; field != null) { // use the user index
+          sugWord.freq = ir.docFreq(new Term(field, sugWord.string)); // freq in the index
+          // don't suggest a word that is not present in the field
+          if ((morePopular &amp;&amp; goalFreq &gt; sugWord.freq) || sugWord.freq &lt; 1)
{
+            continue;
+          }
+        }
+        sugQueue.insertWithOverflow(sugWord);
+        if (sugQueue.size() == numSug) {
+          // if queue full, maintain the minScore score
+          min = sugQueue.top().score;
+        }
+        sugWord = new SuggestWord();
       }
-      sugQueue.insertWithOverflow(sugWord);
-      if (sugQueue.size() == numSug) {
-        // if queue full, maintain the minScore score
-        min = sugQueue.top().score;
+  
+      // convert to array string
+      String[] list = new String[sugQueue.size()];
+      for (int i = sugQueue.size() - 1; i &gt;= 0; i--) {
+        list[i] = sugQueue.pop().string;
       }
-      sugWord = new SuggestWord();
-    }
-
-    // convert to array string
-    String[] list = new String[sugQueue.size()];
-    for (int i = sugQueue.size() - 1; i &gt;= 0; i--) {
-      list[i] = sugQueue.pop().string;
+  
+      return list;
+    } finally {
+      releaseSearcher(indexSearcher);
     }
-
-    return list;
   }
 
   /**
@@ -297,24 +347,33 @@
   /**
    * Removes all terms from the spell check index.
    * @throws IOException
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    */
   public void clearIndex() throws IOException {
-    IndexWriter writer = new IndexWriter(spellIndex, null, true, IndexWriter.MaxFieldLength.UNLIMITED);
-    writer.close();
-    
-    //close the old searcher
-    searcher.close();
-    searcher = new IndexSearcher(this.spellIndex, true);
+    synchronized (modifyCurrentIndexLock) {
+      ensureOpen();
+      final Directory dir = this.spellIndex;
+      final IndexWriter writer = new IndexWriter(dir, null, true, IndexWriter.MaxFieldLength.UNLIMITED);
+      writer.close();
+      swapSearcher(dir);
+    }
   }
 
   /**
    * Check whether the word exists in the index.
    * @param word
    * @throws IOException
-   * @return true iff the word exists in the index
+   * @throws AlreadyClosedException if the Spellchecker is already closed
+   * @return true if the word exists in the index
    */
   public boolean exist(String word) throws IOException {
-    return searcher.docFreq(new Term(F_WORD, word)) &gt; 0;
+    // obtainSearcher calls ensureOpen
+    final IndexSearcher indexSearcher = obtainSearcher();
+    try{
+      return indexSearcher.docFreq(F_WORD_TERM.createTerm(word)) &gt; 0;
+    } finally {
+      releaseSearcher(indexSearcher);
+    }
   }
 
   /**
@@ -322,37 +381,42 @@
    * @param dict Dictionary to index
    * @param mergeFactor mergeFactor to use when indexing
    * @param ramMB the max amount or memory in MB to use
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @throws IOException
    */
   public void indexDictionary(Dictionary dict, int mergeFactor, int ramMB) throws IOException
{
-    IndexWriter writer = new IndexWriter(spellIndex, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
-    writer.setMergeFactor(mergeFactor);
-    writer.setRAMBufferSizeMB(ramMB);
-
-    Iterator&lt;String&gt; iter = dict.getWordsIterator();
-    while (iter.hasNext()) {
-      String word = iter.next();
-
-      int len = word.length();
-      if (len &lt; 3) {
-        continue; // too short we bail but "too long" is fine...
-      }
-
-      if (this.exist(word)) { // if the word already exist in the gramindex
-        continue;
-      }
-
-      // ok index the word
-      Document doc = createDocument(word, getMin(len), getMax(len));
-      writer.addDocument(doc);
-    }
-    // close writer
-    writer.optimize();
-    writer.close();
-    // also re-open the spell index to see our own changes when the next suggestion
-    // is fetched:
-    searcher.close();
-    searcher = new IndexSearcher(this.spellIndex, true);
+    synchronized (modifyCurrentIndexLock) {
+      ensureOpen();
+      final Directory dir = this.spellIndex;
+      final IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(),
+          IndexWriter.MaxFieldLength.UNLIMITED);
+      writer.setMergeFactor(mergeFactor);
+      writer.setRAMBufferSizeMB(ramMB);
+  
+      Iterator&lt;String&gt; iter = dict.getWordsIterator();
+      while (iter.hasNext()) {
+        String word = iter.next();
+  
+        int len = word.length();
+        if (len &lt; 3) {
+          continue; // too short we bail but "too long" is fine...
+        }
+  
+        if (this.exist(word)) { // if the word already exist in the gramindex
+          continue;
+        }
+  
+        // ok index the word
+        Document doc = createDocument(word, getMin(len), getMax(len));
+        writer.addDocument(doc);
+      }
+      // close writer
+      writer.optimize();
+      writer.close();
+      // also re-open the spell index to see our own changes when the next suggestion
+      // is fetched:
+      swapSearcher(dir);
+    }
   }
 
   /**
@@ -364,7 +428,7 @@
     indexDictionary(dict, 300, 10);
   }
 
-  private int getMin(int l) {
+  private static int getMin(int l) {
     if (l &gt; 5) {
       return 3;
     }
@@ -374,7 +438,7 @@
     return 1;
   }
 
-  private int getMax(int l) {
+  private static int getMax(int l) {
     if (l &gt; 5) {
       return 4;
     }
@@ -409,12 +473,84 @@
       }
     }
   }
-
+  
+  private IndexSearcher obtainSearcher() {
+    synchronized (searcherLock) {
+      ensureOpen();
+      searcher.getIndexReader().incRef();
+      return searcher;
+    }
+  }
+  
+  private void releaseSearcher(final IndexSearcher aSearcher) throws IOException{
+      // don't check if open - always decRef 
+      // don't decrement the private searcher - could have been swapped
+      aSearcher.getIndexReader().decRef();      
+  }
+  
+  private void ensureOpen() {
+    if (closed) {
+      throw new AlreadyClosedException("Spellchecker has been closed");
+    }
+  }
+  
   /**
-   * Close the IndexSearcher used by this SpellChecker.
+   * Close the IndexSearcher used by this SpellChecker
+   * @throws IOException if the close operation causes an {@link IOException}
+   * @throws AlreadyClosedException if the {@link SpellChecker} is already closed
    */
   public void close() throws IOException {
-    searcher.close();
-    searcher = null;
+    synchronized (searcherLock) {
+      ensureOpen();
+      closed = true;
+      if (searcher != null) {
+        searcher.close();
+      }
+      searcher = null;
+    }
+  }
+  
+  private void swapSearcher(final Directory dir) throws IOException {
+    /*
+     * opening a searcher is possibly very expensive.
+     * We rather close it again if the Spellchecker was closed during
+     * this operation than block access to the current searcher while opening.
+     */
+    final IndexSearcher indexSearcher = createSearcher(dir);
+    synchronized (searcherLock) {
+      if(closed){
+        indexSearcher.close();
+        throw new AlreadyClosedException("Spellchecker has been closed");
+      }
+      if (searcher != null) {
+        searcher.close();
+      }
+      // set the spellindex in the sync block - ensure consistency.
+      searcher = indexSearcher;
+      this.spellIndex = dir;
+    }
+  }
+  
+  /**
+   * Creates a new read-only IndexSearcher 
+   * @param dir the directory used to open the searcher
+   * @return a new read-only IndexSearcher
+   * @throws IOException f there is a low-level IO error
+   */
+  // for testing purposes
+  IndexSearcher createSearcher(final Directory dir) throws IOException{
+    return new IndexSearcher(dir, true);
   }
+  
+  /**
+   * Returns &lt;code&gt;true&lt;/code&gt; if and only if the {@link SpellChecker} is
+   * closed, otherwise &lt;code&gt;false&lt;/code&gt;.
+   * 
+   * @return &lt;code&gt;true&lt;/code&gt; if and only if the {@link SpellChecker} is
+   *         closed, otherwise &lt;code&gt;false&lt;/code&gt;.
+   */
+  boolean isClosed(){
+    return closed;
+  }
+  
 }

Modified: lucene/java/branches/lucene_3_0/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java?rev=887655&amp;r1=887654&amp;r2=887655&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
(original)
+++ lucene/java/branches/lucene_3_0/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
Sun Dec  6 10:17:26 2009
@@ -18,8 +18,13 @@
  */
 
 import java.io.IOException;
-
-import junit.framework.TestCase;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.apache.lucene.document.Document;
@@ -27,9 +32,12 @@
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.English;
+import org.apache.lucene.util.LuceneTestCase;
 
 
 /**
@@ -37,9 +45,11 @@
  *
  *
  */
-public class TestSpellChecker extends TestCase {
-  private SpellChecker spellChecker;
+public class TestSpellChecker extends LuceneTestCase {
+  private SpellCheckerMock spellChecker;
   private Directory userindex, spellindex;
+  private final Random random = newRandom();
+  private List&lt;IndexSearcher&gt; searchers;
 
   @Override
   protected void setUp() throws Exception {
@@ -56,10 +66,10 @@
       writer.addDocument(doc);
     }
     writer.close();
-
+    searchers = Collections.synchronizedList(new ArrayList&lt;IndexSearcher&gt;());
     // create the spellChecker
     spellindex = new RAMDirectory();
-    spellChecker = new SpellChecker(spellindex);
+    spellChecker = new SpellCheckerMock(spellindex);
   }
 
 
@@ -75,7 +85,9 @@
     int num_field2 = this.numdoc();
 
     assertEquals(num_field2, num_field1 + 1);
-
+    
+    assertLastSearcherOpen(4);
+    
     checkCommonSuggestions(r);
     checkLevenshteinSuggestions(r);
     
@@ -201,4 +213,186 @@
     return num;
   }
   
+  public void testClose() throws IOException {
+    IndexReader r = IndexReader.open(userindex, true);
+    spellChecker.clearIndex();
+    String field = "field1";
+    addwords(r, "field1");
+    int num_field1 = this.numdoc();
+    addwords(r, "field2");
+    int num_field2 = this.numdoc();
+    assertEquals(num_field2, num_field1 + 1);
+    checkCommonSuggestions(r);
+    assertLastSearcherOpen(4);
+    spellChecker.close();
+    assertSearchersClosed();
+    try {
+      spellChecker.close();
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    try {
+      checkCommonSuggestions(r);
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.clearIndex();
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.indexDictionary(new LuceneDictionary(r, field));
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.setSpellIndex(spellindex);
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    assertEquals(4, searchers.size());
+    assertSearchersClosed();
+  }
+  
+  /*
+   * tests if the internally shared indexsearcher is correctly closed 
+   * when the spellchecker is concurrently accessed and closed.
+   */
+  public void testConcurrentAccess() throws IOException, InterruptedException {
+    assertEquals(1, searchers.size());
+    final IndexReader r = IndexReader.open(userindex, true);
+    spellChecker.clearIndex();
+    assertEquals(2, searchers.size());
+    addwords(r, "field1");
+    assertEquals(3, searchers.size());
+    int num_field1 = this.numdoc();
+    addwords(r, "field2");
+    assertEquals(4, searchers.size());
+    int num_field2 = this.numdoc();
+    assertEquals(num_field2, num_field1 + 1);
+    int numThreads = 5 + this.random.nextInt(5);
+    ExecutorService executor = Executors.newFixedThreadPool(numThreads);
+    SpellCheckWorker[] workers = new SpellCheckWorker[numThreads];
+    for (int i = 0; i &lt; numThreads; i++) {
+      SpellCheckWorker spellCheckWorker = new SpellCheckWorker(r);
+      executor.execute(spellCheckWorker);
+      workers[i] = spellCheckWorker;
+      
+    }
+    int iterations = 5 + random.nextInt(5);
+    for (int i = 0; i &lt; iterations; i++) {
+      Thread.sleep(100);
+      // concurrently reset the spell index
+      spellChecker.setSpellIndex(this.spellindex);
+      // for debug - prints the internal open searchers 
+      // showSearchersOpen();
+    }
+    
+    spellChecker.close();
+    executor.shutdown();
+    executor.awaitTermination(5, TimeUnit.SECONDS);
+    
+    
+    for (int i = 0; i &lt; workers.length; i++) {
+      assertFalse(workers[i].failed);
+      assertTrue(workers[i].terminated);
+    }
+    // 4 searchers more than iterations
+    // 1. at creation
+    // 2. clearIndex()
+    // 2. and 3. during addwords
+    assertEquals(iterations + 4, searchers.size());
+    assertSearchersClosed();
+    
+  }
+  
+  private void assertLastSearcherOpen(int numSearchers) {
+    assertEquals(numSearchers, searchers.size());
+    IndexSearcher[] searcherArray = searchers.toArray(new IndexSearcher[0]);
+    for (int i = 0; i &lt; searcherArray.length; i++) {
+      if (i == searcherArray.length - 1) {
+        assertTrue("expected last searcher open but was closed",
+            searcherArray[i].getIndexReader().getRefCount() &gt; 0);
+      } else {
+        assertFalse("expected closed searcher but was open - Index: " + i,
+            searcherArray[i].getIndexReader().getRefCount() &gt; 0);
+      }
+    }
+  }
+  
+  private void assertSearchersClosed() {
+    for (IndexSearcher searcher : searchers) {
+      assertEquals(0, searcher.getIndexReader().getRefCount());
+    }
+  }
+  
+  private void showSearchersOpen() {
+    int count = 0;
+    for (IndexSearcher searcher : searchers) {
+      if(searcher.getIndexReader().getRefCount() &gt; 0)
+        ++count;
+    } 
+    System.out.println(count);
+  }
+
+  
+  private class SpellCheckWorker implements Runnable {
+    private final IndexReader reader;
+    boolean terminated = false;
+    boolean failed = false;
+    
+    SpellCheckWorker(IndexReader reader) {
+      super();
+      this.reader = reader;
+    }
+    
+    public void run() {
+      try {
+        while (true) {
+          try {
+            checkCommonSuggestions(reader);
+          } catch (AlreadyClosedException e) {
+            
+            return;
+          } catch (Throwable e) {
+            
+            e.printStackTrace();
+            failed = true;
+            return;
+          }
+        }
+      } finally {
+        terminated = true;
+      }
+    }
+    
+  }
+  
+  class SpellCheckerMock extends SpellChecker {
+    public SpellCheckerMock(Directory spellIndex) throws IOException {
+      super(spellIndex);
+    }
+
+    public SpellCheckerMock(Directory spellIndex, StringDistance sd)
+        throws IOException {
+      super(spellIndex, sd);
+    }
+
+    @Override
+    IndexSearcher createSearcher(Directory dir) throws IOException {
+      IndexSearcher searcher = super.createSearcher(dir);
+      TestSpellChecker.this.searchers.add(searcher);
+      return searcher;
+    }
+  }
+  
 }

Propchange: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:818601-821336
-/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:881213,881315,881466,881984,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602
+/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:881213,881315,881466,881984,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887532,887602

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602
+/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887532,887602

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestDateTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887532,887602

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestNumberTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887532,887602

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602
+/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887532,887602

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  6 10:17:26 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/util/TestAttributeSource.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/util/TestAttributeSource.java:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/util/TestAttributeSource.java:818601-821336
-/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883079,883554,884870,886257,886911,887602
+/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883079,883554,884870,886257,886911,887532,887602




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887618 - /lucene/java/branches/lucene_3_0/build.xml</title>
<author><name>uschindler@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091206002946.1A76A23888EC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206002946-1A76A23888EC@eris-apache-org%3e</id>
<updated>2009-12-06T00:29:45Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: uschindler
Date: Sun Dec  6 00:29:45 2009
New Revision: 887618

URL: http://svn.apache.org/viewvc?rev=887618&amp;view=rev
Log:
merge to 3.0 branch

Modified:
    lucene/java/branches/lucene_3_0/build.xml   (contents, props changed)

Modified: lucene/java/branches/lucene_3_0/build.xml
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/build.xml?rev=887618&amp;r1=887617&amp;r2=887618&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/build.xml (original)
+++ lucene/java/branches/lucene_3_0/build.xml Sun Dec  6 00:29:45 2009
@@ -683,15 +683,12 @@
     &lt;fail if="contribs.failed"&gt;Contrib tests failed!&lt;/fail&gt;
   &lt;/target&gt;
 
-  &lt;!-- Macro for building checksum files
-       This is only needed until the "format" option is supported
-       by ant's built in checksum task
-   --&gt;
+  &lt;!-- Macro for building checksum files --&gt;
   &lt;macrodef name="lucene-checksum"&gt;
     &lt;attribute name="file"/&gt;
     &lt;sequential&gt;
-      &lt;checksum file="@{file}" algorithm="md5" pattern="{0}  {1}" forceoverwrite="yes"
readbuffersize="65536"/&gt;
-      &lt;checksum file="@{file}" algorithm="sha1" pattern="{0}  {1}" forceoverwrite="yes"
readbuffersize="65536"/&gt;
+      &lt;checksum file="@{file}" algorithm="md5" format="MD5SUM" forceoverwrite="yes" readbuffersize="65536"/&gt;
+      &lt;checksum file="@{file}" algorithm="sha1" format="MD5SUM" forceoverwrite="yes" readbuffersize="65536"/&gt;
     &lt;/sequential&gt;
   &lt;/macrodef&gt;
 

Propchange: lucene/java/branches/lucene_3_0/build.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Sun Dec  6 00:29:45 2009
@@ -0,0 +1,4 @@
+/lucene/java/branches/lucene_2_4/build.xml:748824
+/lucene/java/branches/lucene_2_9/build.xml:817269-818600,825998,829134,829881,831036
+/lucene/java/branches/lucene_2_9_back_compat_tests/build.xml:818601-821336
+/lucene/java/trunk/build.xml:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887617




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887617 - /lucene/java/trunk/build.xml</title>
<author><name>uschindler@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091206002804.E45A723888EC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091206002804-E45A723888EC@eris-apache-org%3e</id>
<updated>2009-12-06T00:28:04Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: uschindler
Date: Sun Dec  6 00:28:04 2009
New Revision: 887617

URL: http://svn.apache.org/viewvc?rev=887617&amp;view=rev
Log:
Use better format for md5sum/sha1 sum on package build (binary files should have * before
file name). The format attribute does that automatically.

Modified:
    lucene/java/trunk/build.xml

Modified: lucene/java/trunk/build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/build.xml?rev=887617&amp;r1=887616&amp;r2=887617&amp;view=diff
==============================================================================
--- lucene/java/trunk/build.xml (original)
+++ lucene/java/trunk/build.xml Sun Dec  6 00:28:04 2009
@@ -683,15 +683,12 @@
     &lt;fail if="contribs.failed"&gt;Contrib tests failed!&lt;/fail&gt;
   &lt;/target&gt;
 
-  &lt;!-- Macro for building checksum files
-       This is only needed until the "format" option is supported
-       by ant's built in checksum task
-   --&gt;
+  &lt;!-- Macro for building checksum files --&gt;
   &lt;macrodef name="lucene-checksum"&gt;
     &lt;attribute name="file"/&gt;
     &lt;sequential&gt;
-      &lt;checksum file="@{file}" algorithm="md5" pattern="{0}  {1}" forceoverwrite="yes"
readbuffersize="65536"/&gt;
-      &lt;checksum file="@{file}" algorithm="sha1" pattern="{0}  {1}" forceoverwrite="yes"
readbuffersize="65536"/&gt;
+      &lt;checksum file="@{file}" algorithm="md5" format="MD5SUM" forceoverwrite="yes" readbuffersize="65536"/&gt;
+      &lt;checksum file="@{file}" algorithm="sha1" format="MD5SUM" forceoverwrite="yes" readbuffersize="65536"/&gt;
     &lt;/sequential&gt;
   &lt;/macrodef&gt;
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887609 - in /lucene/java/branches/lucene_3_0: ./ contrib/ contrib/benchmark/conf/ contrib/highlighter/src/test/ src/java/org/apache/lucene/search/ src/test/org/apache/lucene/analysis/ src/test/org/apache/lucene/document/ src/test/org/apach...</title>
<author><name>uschindler@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091205231750.55A5723889B8@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205231750-55A5723889B8@eris-apache-org%3e</id>
<updated>2009-12-05T23:17:49Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: uschindler
Date: Sat Dec  5 23:17:49 2009
New Revision: 887609

URL: http://svn.apache.org/viewvc?rev=887609&amp;view=rev
Log:
merge the alg file fixes, as in 3.0 we already removed the deprecated DocMakers

Modified:
    lucene/java/branches/lucene_3_0/   (props changed)
    lucene/java/branches/lucene_3_0/CHANGES.txt   (props changed)
    lucene/java/branches/lucene_3_0/contrib/   (props changed)
    lucene/java/branches/lucene_3_0/contrib/CHANGES.txt   (props changed)
    lucene/java/branches/lucene_3_0/contrib/benchmark/conf/extractWikipedia.alg
    lucene/java/branches/lucene_3_0/contrib/benchmark/conf/indexLineFile.alg
    lucene/java/branches/lucene_3_0/contrib/benchmark/conf/wikipediaOneRound.alg
    lucene/java/branches/lucene_3_0/contrib/highlighter/src/test/   (props changed)
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java
  (props changed)

Propchange: lucene/java/branches/lucene_3_0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  5 23:17:49 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4:748824
 /lucene/java/branches/lucene_2_9:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests:818601-821336
-/lucene/java/trunk:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911
+/lucene/java/trunk:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602

Propchange: lucene/java/branches/lucene_3_0/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  5 23:17:49 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/CHANGES.txt:748824
 /lucene/java/branches/lucene_2_9/CHANGES.txt:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/CHANGES.txt:818601-821336
-/lucene/java/trunk/CHANGES.txt:881213,881315,881466,882374,882464,882672,882807,882888,882977,883074-883075,883554,883654,883661,884870,886257,886911
+/lucene/java/trunk/CHANGES.txt:881213,881315,881466,882374,882464,882672,882807,882888,882977,883074-883075,883554,883654,883661,884870,886257,886911,887602

Propchange: lucene/java/branches/lucene_3_0/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  5 23:17:49 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib:748824
 /lucene/java/branches/lucene_2_9/contrib:817269-818600,825998,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib:818601-821336
-/lucene/java/trunk/contrib:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911
+/lucene/java/trunk/contrib:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602

Propchange: lucene/java/branches/lucene_3_0/contrib/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  5 23:17:49 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib/CHANGES.txt:748824
 /lucene/java/branches/lucene_2_9/contrib/CHANGES.txt:817269-818600,825998,826775,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/CHANGES.txt:818601-821336
-/lucene/java/trunk/contrib/CHANGES.txt:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911
+/lucene/java/trunk/contrib/CHANGES.txt:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602

Modified: lucene/java/branches/lucene_3_0/contrib/benchmark/conf/extractWikipedia.alg
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/contrib/benchmark/conf/extractWikipedia.alg?rev=887609&amp;r1=887608&amp;r2=887609&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/contrib/benchmark/conf/extractWikipedia.alg (original)
+++ lucene/java/branches/lucene_3_0/contrib/benchmark/conf/extractWikipedia.alg Sat Dec  5
23:17:49 2009
@@ -29,7 +29,7 @@
 #
 
 # Where to get documents from:
-doc.maker=org.apache.lucene.benchmark.byTask.feeds.EnwikiDocMaker
+content.source=org.apache.lucene.benchmark.byTask.feeds.EnwikiContentSource
 docs.file=temp/enwiki-20070527-pages-articles.xml
 
 # Where to write the line file output:

Modified: lucene/java/branches/lucene_3_0/contrib/benchmark/conf/indexLineFile.alg
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/contrib/benchmark/conf/indexLineFile.alg?rev=887609&amp;r1=887608&amp;r2=887609&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/contrib/benchmark/conf/indexLineFile.alg (original)
+++ lucene/java/branches/lucene_3_0/contrib/benchmark/conf/indexLineFile.alg Sat Dec  5 23:17:49
2009
@@ -32,7 +32,7 @@
 analyzer=org.apache.lucene.analysis.SimpleAnalyzer
 
 # Feed that knows how to process the line file format:
-doc.maker=org.apache.lucene.benchmark.byTask.feeds.LineDocMaker
+content.source=org.apache.lucene.benchmark.byTask.feeds.LineDocSource
 
 # File that contains one document per line:
 docs.file=work/reuters.lines.txt

Modified: lucene/java/branches/lucene_3_0/contrib/benchmark/conf/wikipediaOneRound.alg
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/contrib/benchmark/conf/wikipediaOneRound.alg?rev=887609&amp;r1=887608&amp;r2=887609&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/contrib/benchmark/conf/wikipediaOneRound.alg (original)
+++ lucene/java/branches/lucene_3_0/contrib/benchmark/conf/wikipediaOneRound.alg Sat Dec 
5 23:17:49 2009
@@ -37,7 +37,7 @@
 
 docs.file=temp/enwiki-20070527-pages-articles.xml
 
-doc.maker=org.apache.lucene.benchmark.byTask.feeds.EnwikiDocMaker
+content.source=org.apache.lucene.benchmark.byTask.feeds.EnwikiContentSource
 
 query.maker=org.apache.lucene.benchmark.byTask.feeds.ReutersQueryMaker
 

Propchange: lucene/java/branches/lucene_3_0/contrib/highlighter/src/test/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  5 23:17:49 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib/highlighter/src/test:748824
 /lucene/java/branches/lucene_2_9/contrib/highlighter/src/test:817269-818600,825998,826775,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/highlighter/src/test:818601-821336
-/lucene/java/trunk/contrib/highlighter/src/test:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911
+/lucene/java/trunk/contrib/highlighter/src/test:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602

Propchange: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  5 23:17:49 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:818601-821336
-/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:881213,881315,881466,881984,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911
+/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:881213,881315,881466,881984,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  5 23:17:49 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911
+/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  5 23:17:49 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestDateTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  5 23:17:49 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestNumberTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  5 23:17:49 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911
+/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887602

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  5 23:17:49 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/util/TestAttributeSource.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/util/TestAttributeSource.java:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/util/TestAttributeSource.java:818601-821336
-/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883079,883554,884870,886257,886911
+/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883079,883554,884870,886257,886911,887602




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887602 - in /lucene/java/trunk/contrib/benchmark/conf: extractWikipedia.alg indexLineFile.alg wikipediaOneRound.alg</title>
<author><name>rmuir@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091205223737.E434823888FD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205223737-E434823888FD@eris-apache-org%3e</id>
<updated>2009-12-05T22:37:37Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: rmuir
Date: Sat Dec  5 22:37:36 2009
New Revision: 887602

URL: http://svn.apache.org/viewvc?rev=887602&amp;view=rev
Log:
fix enwiki (and a few others) task, DocMaker was removed in 3.0

Modified:
    lucene/java/trunk/contrib/benchmark/conf/extractWikipedia.alg
    lucene/java/trunk/contrib/benchmark/conf/indexLineFile.alg
    lucene/java/trunk/contrib/benchmark/conf/wikipediaOneRound.alg

Modified: lucene/java/trunk/contrib/benchmark/conf/extractWikipedia.alg
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/conf/extractWikipedia.alg?rev=887602&amp;r1=887601&amp;r2=887602&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/conf/extractWikipedia.alg (original)
+++ lucene/java/trunk/contrib/benchmark/conf/extractWikipedia.alg Sat Dec  5 22:37:36 2009
@@ -29,7 +29,7 @@
 #
 
 # Where to get documents from:
-doc.maker=org.apache.lucene.benchmark.byTask.feeds.EnwikiDocMaker
+content.source=org.apache.lucene.benchmark.byTask.feeds.EnwikiContentSource
 docs.file=temp/enwiki-20070527-pages-articles.xml
 
 # Where to write the line file output:

Modified: lucene/java/trunk/contrib/benchmark/conf/indexLineFile.alg
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/conf/indexLineFile.alg?rev=887602&amp;r1=887601&amp;r2=887602&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/conf/indexLineFile.alg (original)
+++ lucene/java/trunk/contrib/benchmark/conf/indexLineFile.alg Sat Dec  5 22:37:36 2009
@@ -32,7 +32,7 @@
 analyzer=org.apache.lucene.analysis.SimpleAnalyzer
 
 # Feed that knows how to process the line file format:
-doc.maker=org.apache.lucene.benchmark.byTask.feeds.LineDocMaker
+content.source=org.apache.lucene.benchmark.byTask.feeds.LineDocSource
 
 # File that contains one document per line:
 docs.file=work/reuters.lines.txt

Modified: lucene/java/trunk/contrib/benchmark/conf/wikipediaOneRound.alg
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/conf/wikipediaOneRound.alg?rev=887602&amp;r1=887601&amp;r2=887602&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/conf/wikipediaOneRound.alg (original)
+++ lucene/java/trunk/contrib/benchmark/conf/wikipediaOneRound.alg Sat Dec  5 22:37:36 2009
@@ -37,7 +37,7 @@
 
 docs.file=temp/enwiki-20070527-pages-articles.xml
 
-doc.maker=org.apache.lucene.benchmark.byTask.feeds.EnwikiDocMaker
+content.source=org.apache.lucene.benchmark.byTask.feeds.EnwikiContentSource
 
 query.maker=org.apache.lucene.benchmark.byTask.feeds.ReutersQueryMaker
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887591 - /lucene/java/branches/lucene_2_9/contrib/fast-vector-highlighter/pom.xml.template</title>
<author><name>uschindler@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091205213406.C07EB23888C5@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205213406-C07EB23888C5@eris-apache-org%3e</id>
<updated>2009-12-05T21:34:06Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: uschindler
Date: Sat Dec  5 21:34:06 2009
New Revision: 887591

URL: http://svn.apache.org/viewvc?rev=887591&amp;view=rev
Log:
backport LUCENE-2107: Added a pom.xml.template to contrib/fast-vector-highlighter

Added:
    lucene/java/branches/lucene_2_9/contrib/fast-vector-highlighter/pom.xml.template
      - copied unchanged from r887588, lucene/java/trunk/contrib/fast-vector-highlighter/pom.xml.template



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887590 - /lucene/java/branches/lucene_3_0/contrib/fast-vector-highlighter/pom.xml.template</title>
<author><name>uschindler@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091205213332.429FA23888C5@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205213332-429FA23888C5@eris-apache-org%3e</id>
<updated>2009-12-05T21:33:32Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: uschindler
Date: Sat Dec  5 21:33:31 2009
New Revision: 887590

URL: http://svn.apache.org/viewvc?rev=887590&amp;view=rev
Log:
backport LUCENE-2107: Added a pom.xml.template to contrib/fast-vector-highlighter

Added:
    lucene/java/branches/lucene_3_0/contrib/fast-vector-highlighter/pom.xml.template
      - copied unchanged from r887588, lucene/java/trunk/contrib/fast-vector-highlighter/pom.xml.template



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887569 - in /lucene/java/trunk: ./ lib/ src/test/org/apache/lucene/search/function/ src/test/org/apache/lucene/util/</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091205182729.0B6C723888E9@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205182729-0B6C723888E9@eris-apache-org%3e</id>
<updated>2009-12-05T18:27:28Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Sat Dec  5 18:27:27 2009
New Revision: 887569

URL: http://svn.apache.org/viewvc?rev=887569&amp;view=rev
Log:
LUCENE-2037: switch to junit 4.7

Added:
    lucene/java/trunk/lib/junit-4.7.jar   (with props)
    lucene/java/trunk/src/test/org/apache/lucene/util/InterceptTestCaseEvents.java   (with props)
    lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java   (with props)
Removed:
    lucene/java/trunk/lib/junit-3.8.2.jar
Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/common-build.xml
    lucene/java/trunk/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
    lucene/java/trunk/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java
    lucene/java/trunk/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/function/TestDocValues.java
    lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/function/TestOrdValues.java
    lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=887569&amp;r1=887568&amp;r2=887569&amp;view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Sat Dec  5 18:27:27 2009
@@ -63,6 +63,9 @@
 
 Test Cases
 
+* LUCENE-2037 Allow Junit4 tests in our envrionment (Erick Erickson
+  via Mike McCandless)
+
 * LUCENE-1844: Speed up the unit tests (Mark Miller, Erick Erickson,
   Mike McCandless)
 

Modified: lucene/java/trunk/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/common-build.xml?rev=887569&amp;r1=887568&amp;r2=887569&amp;view=diff
==============================================================================
--- lucene/java/trunk/common-build.xml (original)
+++ lucene/java/trunk/common-build.xml Sat Dec  5 18:27:27 2009
@@ -47,7 +47,7 @@
   &lt;property name="year" value="2000-${current.year}"/&gt;
   &lt;property name="final.name" value="lucene-${name}-${version}"/&gt;
 
-  &lt;property name="junit.jar" value="junit-3.8.2.jar"/&gt;
+  &lt;property name="junit.jar" value="junit-4.7.jar"/&gt;
   &lt;property name="junit-location.jar" value="${common.dir}/lib/${junit.jar}"/&gt;
   &lt;path id="junit-path"&gt;
     &lt;pathelement location="${junit-location.jar}"/&gt;

Added: lucene/java/trunk/lib/junit-4.7.jar
URL: http://svn.apache.org/viewvc/lucene/java/trunk/lib/junit-4.7.jar?rev=887569&amp;view=auto
==============================================================================
Binary file - no diff available.

Propchange: lucene/java/trunk/lib/junit-4.7.jar
------------------------------------------------------------------------------
    svn:executable = *

Propchange: lucene/java/trunk/lib/junit-4.7.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/function/FunctionTestSetup.java?rev=887569&amp;r1=887568&amp;r2=887569&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/function/FunctionTestSetup.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/function/FunctionTestSetup.java Sat Dec  5 18:27:27 2009
@@ -25,20 +25,23 @@
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
-
-import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.LuceneTestCaseJ4;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
 
 /**
  * Setup for function tests
  */
-public abstract class FunctionTestSetup extends LuceneTestCase {
+@Ignore
+public class FunctionTestSetup extends LuceneTestCaseJ4 {
 
   /**
    * Actual score computation order is slightly different than assumptios
    * this allows for a small amount of variation
    */
-  public static float TEST_SCORE_TOLERANCE_DELTA = 0.001f;
-  
+  protected static float TEST_SCORE_TOLERANCE_DELTA = 0.001f;
+
   protected static final boolean DBG = false; // change to true for logging to print
 
   protected static final int N_DOCS = 17; // select a primary number &gt; 2
@@ -47,62 +50,57 @@
   protected static final String TEXT_FIELD = "text";
   protected static final String INT_FIELD = "iii";
   protected static final String FLOAT_FIELD = "fff";
-  
+
   private static final String DOC_TEXT_LINES[] = {
-    "Well, this is just some plain text we use for creating the ",
-    "test documents. It used to be a text from an online collection ",
-    "devoted to first aid, but if there was there an (online) lawyers ",
-    "first aid collection with legal advices, \"it\" might have quite ",
-    "probably advised one not to include \"it\"'s text or the text of ",
-    "any other online collection in one's code, unless one has money ",
-    "that one don't need and one is happy to donate for lawyers ",
-    "charity. Anyhow at some point, rechecking the usage of this text, ",
-    "it became uncertain that this text is free to use, because ",
-    "the web site in the disclaimer of he eBook containing that text ",
-    "was not responding anymore, and at the same time, in projGut, ",
-    "searching for first aid no longer found that eBook as well. ",
-    "So here we are, with a perhaps much less interesting ",
-    "text for the test, but oh much much safer. ",
+          "Well, this is just some plain text we use for creating the ",
+          "test documents. It used to be a text from an online collection ",
+          "devoted to first aid, but if there was there an (online) lawyers ",
+          "first aid collection with legal advices, \"it\" might have quite ",
+          "probably advised one not to include \"it\"'s text or the text of ",
+          "any other online collection in one's code, unless one has money ",
+          "that one don't need and one is happy to donate for lawyers ",
+          "charity. Anyhow at some point, rechecking the usage of this text, ",
+          "it became uncertain that this text is free to use, because ",
+          "the web site in the disclaimer of he eBook containing that text ",
+          "was not responding anymore, and at the same time, in projGut, ",
+          "searching for first aid no longer found that eBook as well. ",
+          "So here we are, with a perhaps much less interesting ",
+          "text for the test, but oh much much safer. ",
   };
-  
-  protected Directory dir;
-  protected Analyzer anlzr;
-  
-  /* @override constructor */
-  public FunctionTestSetup(String name) {
-    super(name);
-  }
 
-  /* @override */
+  protected Directory dir = null;
+  protected Analyzer anlzr = null;
+
   @Override
-  protected void tearDown() throws Exception {
+  @After
+  public void tearDown() throws Exception {
     super.tearDown();
     dir = null;
     anlzr = null;
   }
 
-  /* @override */
   @Override
-  protected void setUp() throws Exception {
+  @Before
+  public void setUp() throws Exception {
     super.setUp();
     // prepare a small index with just a few documents.  
     super.setUp();
     dir = new RAMDirectory();
     anlzr = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
     IndexWriter iw = new IndexWriter(dir, anlzr,
-                                     IndexWriter.MaxFieldLength.LIMITED);
+            IndexWriter.MaxFieldLength.LIMITED);
     // add docs not exactly in natural ID order, to verify we do check the order of docs by scores
     int remaining = N_DOCS;
     boolean done[] = new boolean[N_DOCS];
     int i = 0;
-    while (remaining&gt;0) {
+    while (remaining &gt; 0) {
       if (done[i]) {
-        throw new Exception("to set this test correctly N_DOCS="+N_DOCS+" must be primary and greater than 2!");
+        throw new Exception("to set this test correctly N_DOCS=" + N_DOCS + " must be primary and greater than 2!");
       }
-      addDoc(iw,i);
+      addDoc(iw, i);
       done[i] = true;
-      i = (i+4)%N_DOCS;
-      remaining --;
+      i = (i + 4) % N_DOCS;
+      remaining--;
     }
     iw.close();
   }
@@ -110,36 +108,36 @@
   private void addDoc(IndexWriter iw, int i) throws Exception {
     Document d = new Document();
     Fieldable f;
-    int scoreAndID = i+1;
-    
-    f = new Field(ID_FIELD,id2String(scoreAndID),Field.Store.YES,Field.Index.NOT_ANALYZED); // for debug purposes
+    int scoreAndID = i + 1;
+
+    f = new Field(ID_FIELD, id2String(scoreAndID), Field.Store.YES, Field.Index.NOT_ANALYZED); // for debug purposes
     f.setOmitNorms(true);
     d.add(f);
-    
-    f = new Field(TEXT_FIELD,"text of doc"+scoreAndID+textLine(i),Field.Store.NO,Field.Index.ANALYZED); // for regular search
+
+    f = new Field(TEXT_FIELD, "text of doc" + scoreAndID + textLine(i), Field.Store.NO, Field.Index.ANALYZED); // for regular search
     f.setOmitNorms(true);
     d.add(f);
-    
-    f = new Field(INT_FIELD,""+scoreAndID,Field.Store.NO,Field.Index.NOT_ANALYZED); // for function scoring
+
+    f = new Field(INT_FIELD, "" + scoreAndID, Field.Store.NO, Field.Index.NOT_ANALYZED); // for function scoring
     f.setOmitNorms(true);
     d.add(f);
-    
-    f = new Field(FLOAT_FIELD,scoreAndID+".000",Field.Store.NO,Field.Index.NOT_ANALYZED); // for function scoring
+
+    f = new Field(FLOAT_FIELD, scoreAndID + ".000", Field.Store.NO, Field.Index.NOT_ANALYZED); // for function scoring
     f.setOmitNorms(true);
     d.add(f);
 
     iw.addDocument(d);
-    log("added: "+d);
+    log("added: " + d);
   }
 
   // 17 --&gt; ID00017
   protected String id2String(int scoreAndID) {
-    String s = "000000000"+scoreAndID;
-    int n = (""+N_DOCS).length() + 3;
-    int k = s.length() - n; 
-    return "ID"+s.substring(k);
+    String s = "000000000" + scoreAndID;
+    int n = ("" + N_DOCS).length() + 3;
+    int k = s.length() - n;
+    return "ID" + s.substring(k);
   }
-  
+
   // some text line for regular search
   private String textLine(int docNum) {
     return DOC_TEXT_LINES[docNum % DOC_TEXT_LINES.length];
@@ -147,11 +145,11 @@
 
   // extract expected doc score from its ID Field: "ID7" --&gt; 7.0
   protected float expectedFieldScore(String docIDFieldVal) {
-    return Float.parseFloat(docIDFieldVal.substring(2)); 
+    return Float.parseFloat(docIDFieldVal.substring(2));
   }
-  
+
   // debug messages (change DBG to true for anything to print) 
-  protected void log (Object o) {
+  protected void log(Object o) {
     if (DBG) {
       System.out.println(o.toString());
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java?rev=887569&amp;r1=887568&amp;r2=887569&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java Sat Dec  5 18:27:27 2009
@@ -17,11 +17,11 @@
  * limitations under the License.
  */
 
-import java.io.IOException;
-
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.FieldCache;
 
+import java.io.IOException;
+
 /**
  * Holds all implementations of classes in the o.a.l.s.function package as a
  * back-compatibility test. It does not run any tests per-se, however if
@@ -34,7 +34,6 @@
   private static final String UNSUPPORTED_MSG = "unsupported: used for back-compat testing only !";
 
   static final class JustCompileDocValues extends DocValues {
-
     @Override
     public float floatVal(int doc) {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
@@ -44,7 +43,7 @@
     public String toString(int doc) {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
-    
+
   }
 
   static final class JustCompileFieldCacheSource extends FieldCacheSource {
@@ -65,14 +64,13 @@
 
     @Override
     public DocValues getCachedFieldValues(FieldCache cache, String field,
-        IndexReader reader) throws IOException {
+                                          IndexReader reader) throws IOException {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
-    
+
   }
 
   static final class JustCompileValueSource extends ValueSource {
-
     @Override
     public String description() {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
@@ -92,7 +90,7 @@
     public int hashCode() {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
-    
+
   }
-  
+
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java?rev=887569&amp;r1=887568&amp;r2=887569&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java Sat Dec  5 18:27:27 2009
@@ -17,98 +17,114 @@
  * limitations under the License.
  */
 
-import java.io.IOException;
-import java.util.HashMap;
-
-import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Explanation;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.QueryUtils;
-import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.search.*;
 import org.apache.lucene.util.Version;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Test CustomScoreQuery search.
  */
+@SuppressWarnings({"MagicNumber"})
 public class TestCustomScoreQuery extends FunctionTestSetup {
 
-  /* @override constructor */
-  public TestCustomScoreQuery(String name) {
-    super(name);
-  }
 
-  /** Test that CustomScoreQuery of Type.BYTE returns the expected scores. */
-  public void testCustomScoreByte () throws CorruptIndexException, Exception {
+  /**
+   * Test that CustomScoreQuery of Type.BYTE returns the expected scores.
+   */
+  @Test
+  public void testCustomScoreByte() throws Exception, ParseException {
     // INT field values are small enough to be parsed as byte
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.BYTE,1.0);
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.BYTE,2.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.BYTE, 1.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.BYTE, 2.0);
   }
 
-  /** Test that CustomScoreQuery of Type.SHORT returns the expected scores. */
-  public void testCustomScoreShort () throws CorruptIndexException, Exception {
+  /**
+   * Test that CustomScoreQuery of Type.SHORT returns the expected scores.
+   */
+  @Test
+  public void testCustomScoreShort() throws Exception, ParseException {
     // INT field values are small enough to be parsed as short
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.SHORT,1.0);
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.SHORT,3.0);
-  }
-
-  /** Test that CustomScoreQuery of Type.INT returns the expected scores. */
-  public void testCustomScoreInt () throws CorruptIndexException, Exception {
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.INT,1.0);
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.INT,4.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.SHORT, 1.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.SHORT, 3.0);
   }
 
-  /** Test that CustomScoreQuery of Type.FLOAT returns the expected scores. */
-  public void testCustomScoreFloat () throws CorruptIndexException, Exception {
+  /**
+   * Test that CustomScoreQuery of Type.INT returns the expected scores.
+   */
+  @Test
+  public void testCustomScoreInt() throws Exception, ParseException {
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.INT, 1.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.INT, 4.0);
+  }
+
+  /**
+   * Test that CustomScoreQuery of Type.FLOAT returns the expected scores.
+   */
+  @Test
+  public void testCustomScoreFloat() throws Exception, ParseException {
     // INT field can be parsed as float
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.FLOAT,1.0);
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.FLOAT,5.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.FLOAT, 1.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.FLOAT, 5.0);
     // same values, but in flot format
-    doTestCustomScore(FLOAT_FIELD,FieldScoreQuery.Type.FLOAT,1.0);
-    doTestCustomScore(FLOAT_FIELD,FieldScoreQuery.Type.FLOAT,6.0);
+    doTestCustomScore(FLOAT_FIELD, FieldScoreQuery.Type.FLOAT, 1.0);
+    doTestCustomScore(FLOAT_FIELD, FieldScoreQuery.Type.FLOAT, 6.0);
   }
 
   // must have static class otherwise serialization tests fail
+  @SuppressWarnings({"SerializableHasSerializationMethods", "serial"})
   private static class CustomAddQuery extends CustomScoreQuery {
     // constructor
-    CustomAddQuery (Query q, ValueSourceQuery qValSrc) {
-      super(q,qValSrc);
+    CustomAddQuery(Query q, ValueSourceQuery qValSrc) {
+      super(q, qValSrc);
     }
+
     /*(non-Javadoc) @see org.apache.lucene.search.function.CustomScoreQuery#name() */
     @Override
     public String name() {
       return "customAdd";
     }
+
     /*(non-Javadoc) @see org.apache.lucene.search.function.CustomScoreQuery#customScore(int, float, float) */
     @Override
     public float customScore(int doc, float subQueryScore, float valSrcScore) {
       return subQueryScore + valSrcScore;
     }
+
     /* (non-Javadoc)@see org.apache.lucene.search.function.CustomScoreQuery#customExplain(int, org.apache.lucene.search.Explanation, org.apache.lucene.search.Explanation)*/
     @Override
     public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl) {
-      float valSrcScore = valSrcExpl==null ? 0 : valSrcExpl.getValue();
-      Explanation exp = new Explanation( valSrcScore + subQueryExpl.getValue(), "custom score: sum of:");
+      float valSrcScore = valSrcExpl == null ? 0 : valSrcExpl.getValue();
+      Explanation exp = new Explanation(valSrcScore + subQueryExpl.getValue(), "custom score: sum of:");
       exp.addDetail(subQueryExpl);
       if (valSrcExpl != null) {
         exp.addDetail(valSrcExpl);
       }
-      return exp;      
-    } 
+      return exp;
+    }
   }
-  
+
   // must have static class otherwise serialization tests fail
+  @SuppressWarnings({"SerializableHasSerializationMethods", "serial"})
   private static class CustomMulAddQuery extends CustomScoreQuery {
     // constructor
     CustomMulAddQuery(Query q, ValueSourceQuery qValSrc1, ValueSourceQuery qValSrc2) {
-      super(q,new ValueSourceQuery[]{qValSrc1,qValSrc2});
+      super(q, new ValueSourceQuery[]{qValSrc1, qValSrc2});
     }
+
     /*(non-Javadoc) @see org.apache.lucene.search.function.CustomScoreQuery#name() */
     @Override
     public String name() {
       return "customMulAdd";
     }
+
     /*(non-Javadoc) @see org.apache.lucene.search.function.CustomScoreQuery#customScore(int, float, float) */
     @Override
     public float customScore(int doc, float subQueryScore, float valSrcScores[]) {
@@ -119,7 +135,8 @@
         return subQueryScore + valSrcScores[0];
       }
       return (subQueryScore + valSrcScores[0]) * valSrcScores[1]; // we know there are two
-    } 
+    }
+
     /* (non-Javadoc)@see org.apache.lucene.search.function.CustomScoreQuery#customExplain(int, org.apache.lucene.search.Explanation, org.apache.lucene.search.Explanation)*/
     @Override
     public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpls[]) {
@@ -136,67 +153,67 @@
       Explanation exp2 = new Explanation(valSrcExpls[1].getValue() * exp.getValue(), "custom score: product of:");
       exp2.addDetail(valSrcExpls[1]);
       exp2.addDetail(exp);
-      return exp2;      
-    } 
+      return exp2;
+    }
   }
-  
+
   // Test that FieldScoreQuery returns docs with expected score.
-  private void doTestCustomScore (String field, FieldScoreQuery.Type tp, double dboost) throws CorruptIndexException, Exception {
+  private void doTestCustomScore(String field, FieldScoreQuery.Type tp, double dboost) throws Exception, ParseException {
     float boost = (float) dboost;
     IndexSearcher s = new IndexSearcher(dir, true);
-    FieldScoreQuery qValSrc = new FieldScoreQuery(field,tp); // a query that would score by the field
-    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, TEXT_FIELD,anlzr); 
+    FieldScoreQuery qValSrc = new FieldScoreQuery(field, tp); // a query that would score by the field
+    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, TEXT_FIELD, anlzr);
     String qtxt = "first aid text"; // from the doc texts in FunctionQuerySetup.
-    
+
     // regular (boolean) query.
-    Query q1 = qp.parse(qtxt); 
+    Query q1 = qp.parse(qtxt);
     log(q1);
-    
+
     // custom query, that should score the same as q1.
-    CustomScoreQuery q2CustomNeutral = new CustomScoreQuery(q1);
+    Query q2CustomNeutral = new CustomScoreQuery(q1);
     q2CustomNeutral.setBoost(boost);
     log(q2CustomNeutral);
-    
+
     // custom query, that should (by default) multiply the scores of q1 by that of the field
-    CustomScoreQuery q3CustomMul = new CustomScoreQuery(q1,qValSrc);
+    CustomScoreQuery q3CustomMul = new CustomScoreQuery(q1, qValSrc);
     q3CustomMul.setStrict(true);
     q3CustomMul.setBoost(boost);
     log(q3CustomMul);
-    
+
     // custom query, that should add the scores of q1 to that of the field
-    CustomScoreQuery q4CustomAdd = new CustomAddQuery(q1,qValSrc); 
+    CustomScoreQuery q4CustomAdd = new CustomAddQuery(q1, qValSrc);
     q4CustomAdd.setStrict(true);
     q4CustomAdd.setBoost(boost);
     log(q4CustomAdd);
 
     // custom query, that multiplies and adds the field score to that of q1
-    CustomScoreQuery q5CustomMulAdd = new CustomMulAddQuery(q1,qValSrc,qValSrc);
+    CustomScoreQuery q5CustomMulAdd = new CustomMulAddQuery(q1, qValSrc, qValSrc);
     q5CustomMulAdd.setStrict(true);
     q5CustomMulAdd.setBoost(boost);
     log(q5CustomMulAdd);
 
     // do al the searches 
-    TopDocs td1 = s.search(q1,null,1000);
-    TopDocs td2CustomNeutral = s.search(q2CustomNeutral,null,1000);
-    TopDocs td3CustomMul = s.search(q3CustomMul,null,1000);
-    TopDocs td4CustomAdd = s.search(q4CustomAdd,null,1000);
-    TopDocs td5CustomMulAdd = s.search(q5CustomMulAdd,null,1000);
-    
+    TopDocs td1 = s.search(q1, null, 1000);
+    TopDocs td2CustomNeutral = s.search(q2CustomNeutral, null, 1000);
+    TopDocs td3CustomMul = s.search(q3CustomMul, null, 1000);
+    TopDocs td4CustomAdd = s.search(q4CustomAdd, null, 1000);
+    TopDocs td5CustomMulAdd = s.search(q5CustomMulAdd, null, 1000);
+
     // put results in map so we can verify the scores although they have changed
-    HashMap&lt;Integer,Float&gt; h1               = topDocsToMap(td1);
-    HashMap&lt;Integer,Float&gt; h2CustomNeutral  = topDocsToMap(td2CustomNeutral);
-    HashMap&lt;Integer,Float&gt; h3CustomMul      = topDocsToMap(td3CustomMul);
-    HashMap&lt;Integer,Float&gt; h4CustomAdd      = topDocsToMap(td4CustomAdd);
-    HashMap&lt;Integer,Float&gt; h5CustomMulAdd   = topDocsToMap(td5CustomMulAdd);
+    Map&lt;Integer,Float&gt; h1               = topDocsToMap(td1);
+    Map&lt;Integer,Float&gt; h2CustomNeutral  = topDocsToMap(td2CustomNeutral);
+    Map&lt;Integer,Float&gt; h3CustomMul      = topDocsToMap(td3CustomMul);
+    Map&lt;Integer,Float&gt; h4CustomAdd      = topDocsToMap(td4CustomAdd);
+    Map&lt;Integer,Float&gt; h5CustomMulAdd   = topDocsToMap(td5CustomMulAdd);
     
     verifyResults(boost, s, 
         h1, h2CustomNeutral, h3CustomMul, h4CustomAdd, h5CustomMulAdd,
         q1, q2CustomNeutral, q3CustomMul, q4CustomAdd, q5CustomMulAdd);
   }
-  
+
   // verify results are as expected.
   private void verifyResults(float boost, IndexSearcher s, 
-      HashMap&lt;Integer,Float&gt; h1, HashMap&lt;Integer,Float&gt; h2customNeutral, HashMap&lt;Integer,Float&gt; h3CustomMul, HashMap&lt;Integer,Float&gt; h4CustomAdd, HashMap&lt;Integer,Float&gt; h5CustomMulAdd,
+      Map&lt;Integer,Float&gt; h1, Map&lt;Integer,Float&gt; h2customNeutral, Map&lt;Integer,Float&gt; h3CustomMul, Map&lt;Integer,Float&gt; h4CustomAdd, Map&lt;Integer,Float&gt; h5CustomMulAdd,
       Query q1, Query q2, Query q3, Query q4, Query q5) throws Exception {
     
     // verify numbers of matches
@@ -213,37 +230,36 @@
     QueryUtils.check(q5,s);
 
     // verify scores ratios
-    for (final Integer x : h1.keySet()) {
+    for (final Integer doc : h1.keySet()) {
 
-      int doc =  x.intValue();
       log("doc = "+doc);
 
       float fieldScore = expectedFieldScore(s.getIndexReader().document(doc).get(ID_FIELD));
-      log("fieldScore = "+fieldScore);
-      assertTrue("fieldScore should not be 0",fieldScore&gt;0);
+      log("fieldScore = " + fieldScore);
+      assertTrue("fieldScore should not be 0", fieldScore &gt; 0);
 
-      float score1 = h1.get(x).floatValue();
+      float score1 = h1.get(doc);
       logResult("score1=", s, q1, doc, score1);
       
-      float score2 = h2customNeutral.get(x).floatValue();
+      float score2 = h2customNeutral.get(doc);
       logResult("score2=", s, q2, doc, score2);
       assertEquals("same score (just boosted) for neutral", boost * score1, score2, TEST_SCORE_TOLERANCE_DELTA);
 
-      float score3 = h3CustomMul.get(x).floatValue();
+      float score3 = h3CustomMul.get(doc);
       logResult("score3=", s, q3, doc, score3);
       assertEquals("new score for custom mul", boost * fieldScore * score1, score3, TEST_SCORE_TOLERANCE_DELTA);
       
-      float score4 = h4CustomAdd.get(x).floatValue();
+      float score4 = h4CustomAdd.get(doc);
       logResult("score4=", s, q4, doc, score4);
       assertEquals("new score for custom add", boost * (fieldScore + score1), score4, TEST_SCORE_TOLERANCE_DELTA);
       
-      float score5 = h5CustomMulAdd.get(x).floatValue();
+      float score5 = h5CustomMulAdd.get(doc);
       logResult("score5=", s, q5, doc, score5);
       assertEquals("new score for custom mul add", boost * fieldScore * (score1 + fieldScore), score5, TEST_SCORE_TOLERANCE_DELTA);
     }
   }
 
-  private void logResult(String msg, IndexSearcher s, Query q, int doc, float score1) throws IOException {
+  private void logResult(String msg, Searcher s, Query q, int doc, float score1) throws IOException {
     log(msg+" "+score1);
     log("Explain by: "+q);
     log(s.explain(q,doc));
@@ -251,10 +267,10 @@
 
   // since custom scoring modifies the order of docs, map results 
   // by doc ids so that we can later compare/verify them 
-  private HashMap&lt;Integer,Float&gt; topDocsToMap(TopDocs td) {
-    HashMap&lt;Integer,Float&gt; h = new HashMap&lt;Integer,Float&gt;(); 
+  private Map&lt;Integer,Float&gt; topDocsToMap(TopDocs td) {
+    Map&lt;Integer,Float&gt; h = new HashMap&lt;Integer,Float&gt;();
     for (int i=0; i&lt;td.totalHits; i++) {
-      h.put(Integer.valueOf(td.scoreDocs[i].doc), Float.valueOf(td.scoreDocs[i].score));
+      h.put(td.scoreDocs[i].doc, td.scoreDocs[i].score);
     }
     return h;
   }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/function/TestDocValues.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/function/TestDocValues.java?rev=887569&amp;r1=887568&amp;r2=887569&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/function/TestDocValues.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/function/TestDocValues.java Sat Dec  5 18:27:27 2009
@@ -17,18 +17,17 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.LuceneTestCaseJ4;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 /**
  * DocValues TestCase  
  */
-public class TestDocValues extends LuceneTestCase {
-
-  /* @override constructor */
-  public TestDocValues(String name) {
-    super(name);
-  }
+public class TestDocValues extends LuceneTestCaseJ4 {
 
+  @Test
   public void testGetMinValue() {
     float[] innerArray = new float[] { 1.0f, 2.0f, -1.0f, 100.0f };
     DocValuesTestImpl docValues = new DocValuesTestImpl(innerArray);
@@ -41,7 +40,7 @@
     assertTrue("max is NaN - no values in inner array", Float.isNaN(docValues
         .getMinValue()));
   }
-
+  @Test
   public void testGetMaxValue() {
     float[] innerArray = new float[] { 1.0f, 2.0f, -1.0f, 10.0f };
     DocValuesTestImpl docValues = new DocValuesTestImpl(innerArray);
@@ -66,6 +65,7 @@
         .getMaxValue()));
   }
 
+  @Test
   public void testGetAverageValue() {
     float[] innerArray = new float[] { 1.0f, 1.0f, 1.0f, 1.0f };
     DocValuesTestImpl docValues = new DocValuesTestImpl(innerArray);
@@ -97,7 +97,6 @@
     /**
      * @see org.apache.lucene.search.function.DocValues#floatVal(int)
      */
-    /* @Override */
     @Override
     public float floatVal(int doc) {
       return innerArray[doc];
@@ -106,7 +105,6 @@
     /**
      * @see org.apache.lucene.search.function.DocValues#toString(int)
      */
-    /* @Override */
     @Override
     public String toString(int doc) {
       return Integer.toString(doc);

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java?rev=887569&amp;r1=887568&amp;r2=887569&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java Sat Dec  5 18:27:27 2009
@@ -18,14 +18,16 @@
  */
 
 import java.util.HashMap;
+import java.util.Map;
 
-import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryUtils;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TopDocs;
+import org.junit.Test;
+import static org.junit.Assert.*;
 
 /**
  * Test FieldScoreQuery search.
@@ -38,32 +40,32 @@
  * &lt;p&gt;
  * The exact score tests use TopDocs top to verify the exact score.  
  */
+@SuppressWarnings({"UseOfSystemOutOrSystemErr"})
 public class TestFieldScoreQuery extends FunctionTestSetup {
 
-  /* @override constructor */
-  public TestFieldScoreQuery(String name) {
-    super(name);
-  }
-
   /** Test that FieldScoreQuery of Type.BYTE returns docs in expected order. */
-  public void testRankByte () throws CorruptIndexException, Exception {
+  @Test
+  public void testRankByte () throws Exception {
     // INT field values are small enough to be parsed as byte
     doTestRank(INT_FIELD,FieldScoreQuery.Type.BYTE);
   }
 
   /** Test that FieldScoreQuery of Type.SHORT returns docs in expected order. */
-  public void testRankShort () throws CorruptIndexException, Exception {
+  @Test
+  public void testRankShort () throws Exception {
     // INT field values are small enough to be parsed as short
     doTestRank(INT_FIELD,FieldScoreQuery.Type.SHORT);
   }
 
   /** Test that FieldScoreQuery of Type.INT returns docs in expected order. */
-  public void testRankInt () throws CorruptIndexException, Exception {
+  @Test
+  public void testRankInt () throws Exception {
     doTestRank(INT_FIELD,FieldScoreQuery.Type.INT);
   }
 
   /** Test that FieldScoreQuery of Type.FLOAT returns docs in expected order. */
-  public void testRankFloat () throws CorruptIndexException, Exception {
+  @Test
+  public void testRankFloat () throws Exception {
     // INT field can be parsed as float
     doTestRank(INT_FIELD,FieldScoreQuery.Type.FLOAT);
     // same values, but in flot format
@@ -71,7 +73,7 @@
   }
 
   // Test that FieldScoreQuery returns docs in expected order.
-  private void doTestRank (String field, FieldScoreQuery.Type tp) throws CorruptIndexException, Exception {
+  private void doTestRank (String field, FieldScoreQuery.Type tp) throws Exception {
     IndexSearcher s = new IndexSearcher(dir, true);
     Query q = new FieldScoreQuery(field,tp);
     log("test: "+q);
@@ -89,24 +91,28 @@
   }
 
   /** Test that FieldScoreQuery of Type.BYTE returns the expected scores. */
-  public void testExactScoreByte () throws CorruptIndexException, Exception {
+  @Test
+  public void testExactScoreByte () throws Exception {
     // INT field values are small enough to be parsed as byte
     doTestExactScore(INT_FIELD,FieldScoreQuery.Type.BYTE);
   }
 
   /** Test that FieldScoreQuery of Type.SHORT returns the expected scores. */
-  public void testExactScoreShort () throws CorruptIndexException, Exception {
+  @Test
+  public void testExactScoreShort () throws  Exception {
     // INT field values are small enough to be parsed as short
     doTestExactScore(INT_FIELD,FieldScoreQuery.Type.SHORT);
   }
 
   /** Test that FieldScoreQuery of Type.INT returns the expected scores. */
-  public void testExactScoreInt () throws CorruptIndexException, Exception {
+  @Test
+  public void testExactScoreInt () throws  Exception {
     doTestExactScore(INT_FIELD,FieldScoreQuery.Type.INT);
   }
 
   /** Test that FieldScoreQuery of Type.FLOAT returns the expected scores. */
-  public void testExactScoreFloat () throws CorruptIndexException, Exception {
+  @Test
+  public void testExactScoreFloat () throws  Exception {
     // INT field can be parsed as float
     doTestExactScore(INT_FIELD,FieldScoreQuery.Type.FLOAT);
     // same values, but in flot format
@@ -114,40 +120,44 @@
   }
 
   // Test that FieldScoreQuery returns docs with expected score.
-  private void doTestExactScore (String field, FieldScoreQuery.Type tp) throws CorruptIndexException, Exception {
+  private void doTestExactScore (String field, FieldScoreQuery.Type tp) throws Exception {
     IndexSearcher s = new IndexSearcher(dir, true);
     Query q = new FieldScoreQuery(field,tp);
     TopDocs td = s.search(q,null,1000);
     assertEquals("All docs should be matched!",N_DOCS,td.totalHits);
     ScoreDoc sd[] = td.scoreDocs;
-    for (int i=0; i&lt;sd.length; i++) {
-      float score = sd[i].score;
-      log(s.explain(q,sd[i].doc));
-      String id = s.getIndexReader().document(sd[i].doc).get(ID_FIELD);
+    for (ScoreDoc aSd : sd) {
+      float score = aSd.score;
+      log(s.explain(q, aSd.doc));
+      String id = s.getIndexReader().document(aSd.doc).get(ID_FIELD);
       float expectedScore = expectedFieldScore(id); // "ID7" --&gt; 7.0
-      assertEquals("score of "+id+" shuould be "+expectedScore+" != "+score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA);
+      assertEquals("score of " + id + " shuould be " + expectedScore + " != " + score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA);
     }
   }
 
   /** Test that FieldScoreQuery of Type.BYTE caches/reuses loaded values and consumes the proper RAM resources. */
-  public void testCachingByte () throws CorruptIndexException, Exception {
+  @Test
+  public void testCachingByte () throws  Exception {
     // INT field values are small enough to be parsed as byte
     doTestCaching(INT_FIELD,FieldScoreQuery.Type.BYTE);
   }
 
   /** Test that FieldScoreQuery of Type.SHORT caches/reuses loaded values and consumes the proper RAM resources. */
-  public void testCachingShort () throws CorruptIndexException, Exception {
+  @Test
+  public void testCachingShort () throws  Exception {
     // INT field values are small enough to be parsed as short
     doTestCaching(INT_FIELD,FieldScoreQuery.Type.SHORT);
   }
 
   /** Test that FieldScoreQuery of Type.INT caches/reuses loaded values and consumes the proper RAM resources. */
-  public void testCachingInt () throws CorruptIndexException, Exception {
+  @Test
+  public void testCachingInt () throws Exception {
     doTestCaching(INT_FIELD,FieldScoreQuery.Type.INT);
   }
 
   /** Test that FieldScoreQuery of Type.FLOAT caches/reuses loaded values and consumes the proper RAM resources. */
-  public void testCachingFloat () throws CorruptIndexException, Exception {
+  @Test
+  public void testCachingFloat () throws  Exception {
     // INT field values can be parsed as float
     doTestCaching(INT_FIELD,FieldScoreQuery.Type.FLOAT);
     // same values, but in flot format
@@ -155,7 +165,7 @@
   }
 
   // Test that values loaded for FieldScoreQuery are cached properly and consumes the proper RAM resources.
-  private void doTestCaching (String field, FieldScoreQuery.Type tp) throws CorruptIndexException, Exception {
+  private void doTestCaching (String field, FieldScoreQuery.Type tp) throws Exception {
     // prepare expected array types for comparison
     HashMap&lt;FieldScoreQuery.Type,Object&gt; expectedArrayTypes = new HashMap&lt;FieldScoreQuery.Type,Object&gt;();
     expectedArrayTypes.put(FieldScoreQuery.Type.BYTE, new byte[0]);
@@ -223,7 +233,7 @@
   }
 
   private String testName() {
-    return getClass().getName()+"."+getName();
+    return getClass().getName()+"."+ getName();
   }
 
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/function/TestOrdValues.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/function/TestOrdValues.java?rev=887569&amp;r1=887568&amp;r2=887569&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/function/TestOrdValues.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/function/TestOrdValues.java Sat Dec  5 18:27:27 2009
@@ -19,42 +19,42 @@
 
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.QueryUtils;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.search.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
 
 /**
  * Test search based on OrdFieldSource and ReverseOrdFieldSource.
- * &lt;p&gt;
+ * &lt;p/&gt;
  * Tests here create an index with a few documents, each having
  * an indexed "id" field.
  * The ord values of this field are later used for scoring.
- * &lt;p&gt;
+ * &lt;p/&gt;
  * The order tests use Hits to verify that docs are ordered as expected.
- * &lt;p&gt;
- * The exact score tests use TopDocs top to verify the exact score.  
+ * &lt;p/&gt;
+ * The exact score tests use TopDocs top to verify the exact score.
  */
+@SuppressWarnings({"UseOfSystemOutOrSystemErr"})
 public class TestOrdValues extends FunctionTestSetup {
 
-  /* @override constructor */
-  public TestOrdValues(String name) {
-    super(name);
+  /**
+   * Test OrdFieldSource
+   */
+  @Test
+  public void testOrdFieldRank() throws CorruptIndexException, Exception {
+    doTestRank(ID_FIELD, true);
   }
 
-  /** Test OrdFieldSource */
-  public void testOrdFieldRank () throws CorruptIndexException, Exception {
-    doTestRank(ID_FIELD,true);
-  }
-
-  /** Test ReverseOrdFieldSource */
-  public void testReverseOrdFieldRank () throws CorruptIndexException, Exception {
-    doTestRank(ID_FIELD,false);
+  /**
+   * Test ReverseOrdFieldSource
+   */
+  @Test
+  public void testReverseOrdFieldRank() throws CorruptIndexException, Exception {
+    doTestRank(ID_FIELD, false);
   }
 
   // Test that queries based on reverse/ordFieldScore scores correctly
-  private void doTestRank (String field, boolean inOrder) throws CorruptIndexException, Exception {
+  private void doTestRank(String field, boolean inOrder) throws CorruptIndexException, Exception {
     IndexSearcher s = new IndexSearcher(dir, true);
     ValueSource vs;
     if (inOrder) {
@@ -62,42 +62,48 @@
     } else {
       vs = new ReverseOrdFieldSource(field);
     }
-        
+
     Query q = new ValueSourceQuery(vs);
-    log("test: "+q);
-    QueryUtils.check(q,s);
+    log("test: " + q);
+    QueryUtils.check(q, s);
     ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
-    assertEquals("All docs should be matched!",N_DOCS,h.length);
+    assertEquals("All docs should be matched!", N_DOCS, h.length);
     String prevID = inOrder
-      ? "IE"   // greater than all ids of docs in this test ("ID0001", etc.)
-      : "IC";  // smaller than all ids of docs in this test ("ID0001", etc.)
-          
-    for (int i=0; i&lt;h.length; i++) {
+            ? "IE"   // greater than all ids of docs in this test ("ID0001", etc.)
+            : "IC";  // smaller than all ids of docs in this test ("ID0001", etc.)
+
+    for (int i = 0; i &lt; h.length; i++) {
       String resID = s.doc(h[i].doc).get(ID_FIELD);
-      log(i+".   score="+h[i].score+"  -  "+resID);
-      log(s.explain(q,h[i].doc));
+      log(i + ".   score=" + h[i].score + "  -  " + resID);
+      log(s.explain(q, h[i].doc));
       if (inOrder) {
-        assertTrue("res id "+resID+" should be &lt; prev res id "+prevID, resID.compareTo(prevID)&lt;0);
+        assertTrue("res id " + resID + " should be &lt; prev res id " + prevID, resID.compareTo(prevID) &lt; 0);
       } else {
-        assertTrue("res id "+resID+" should be &gt; prev res id "+prevID, resID.compareTo(prevID)&gt;0);
+        assertTrue("res id " + resID + " should be &gt; prev res id " + prevID, resID.compareTo(prevID) &gt; 0);
       }
       prevID = resID;
     }
   }
 
-  /** Test exact score for OrdFieldSource */
-  public void testOrdFieldExactScore () throws CorruptIndexException, Exception {
-    doTestExactScore(ID_FIELD,true);
+  /**
+   * Test exact score for OrdFieldSource
+   */
+  @Test
+  public void testOrdFieldExactScore() throws CorruptIndexException, Exception {
+    doTestExactScore(ID_FIELD, true);
   }
 
-  /** Test exact score for ReverseOrdFieldSource */
-  public void testReverseOrdFieldExactScore () throws CorruptIndexException, Exception {
-    doTestExactScore(ID_FIELD,false);
+  /**
+   * Test exact score for ReverseOrdFieldSource
+   */
+  @Test
+  public void testReverseOrdFieldExactScore() throws CorruptIndexException, Exception {
+    doTestExactScore(ID_FIELD, false);
   }
 
-  
+
   // Test that queries based on reverse/ordFieldScore returns docs with expected score.
-  private void doTestExactScore (String field, boolean inOrder) throws CorruptIndexException, Exception {
+  private void doTestExactScore(String field, boolean inOrder) throws CorruptIndexException, Exception {
     IndexSearcher s = new IndexSearcher(dir, true);
     ValueSource vs;
     if (inOrder) {
@@ -106,41 +112,47 @@
       vs = new ReverseOrdFieldSource(field);
     }
     Query q = new ValueSourceQuery(vs);
-    TopDocs td = s.search(q,null,1000);
-    assertEquals("All docs should be matched!",N_DOCS,td.totalHits);
+    TopDocs td = s.search(q, null, 1000);
+    assertEquals("All docs should be matched!", N_DOCS, td.totalHits);
     ScoreDoc sd[] = td.scoreDocs;
-    for (int i=0; i&lt;sd.length; i++) {
+    for (int i = 0; i &lt; sd.length; i++) {
       float score = sd[i].score;
       String id = s.getIndexReader().document(sd[i].doc).get(ID_FIELD);
-      log("-------- "+i+". Explain doc "+id);
-      log(s.explain(q,sd[i].doc));
-      float expectedScore =  N_DOCS-i;
-      assertEquals("score of result "+i+" shuould be "+expectedScore+" != "+score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA);
-      String expectedId =  inOrder 
-        ? id2String(N_DOCS-i) // in-order ==&gt; larger  values first 
-        : id2String(i+1);     // reverse  ==&gt; smaller values first 
-      assertTrue("id of result "+i+" shuould be "+expectedId+" != "+score, expectedId.equals(id));
-    }
-  }
-  
-  /** Test caching OrdFieldSource */
-  public void testCachingOrd () throws CorruptIndexException, Exception {
-    doTestCaching(ID_FIELD,true);
-  }
-  
-  /** Test caching for ReverseOrdFieldSource */
-  public void tesCachingReverseOrd () throws CorruptIndexException, Exception {
-    doTestCaching(ID_FIELD,false);
+      log("-------- " + i + ". Explain doc " + id);
+      log(s.explain(q, sd[i].doc));
+      float expectedScore = N_DOCS - i;
+      assertEquals("score of result " + i + " shuould be " + expectedScore + " != " + score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA);
+      String expectedId = inOrder
+              ? id2String(N_DOCS - i) // in-order ==&gt; larger  values first
+              : id2String(i + 1);     // reverse  ==&gt; smaller values first
+      assertTrue("id of result " + i + " shuould be " + expectedId + " != " + score, expectedId.equals(id));
+    }
+  }
+
+  /**
+   * Test caching OrdFieldSource
+   */
+  @Test
+  public void testCachingOrd() throws CorruptIndexException, Exception {
+    doTestCaching(ID_FIELD, true);
+  }
+
+  /**
+   * Test caching for ReverseOrdFieldSource
+   */
+  @Test
+  public void testCachingReverseOrd() throws CorruptIndexException, Exception {
+    doTestCaching(ID_FIELD, false);
   }
 
   // Test that values loaded for FieldScoreQuery are cached properly and consumes the proper RAM resources.
-  private void doTestCaching (String field, boolean inOrder) throws CorruptIndexException, Exception {
+  private void doTestCaching(String field, boolean inOrder) throws CorruptIndexException, Exception {
     IndexSearcher s = new IndexSearcher(dir, true);
     Object innerArray = null;
 
     boolean warned = false; // print warning once
-    
-    for (int i=0; i&lt;10; i++) {
+
+    for (int i = 0; i &lt; 10; i++) {
       ValueSource vs;
       if (inOrder) {
         vs = new OrdFieldSource(field);
@@ -150,30 +162,29 @@
       ValueSourceQuery q = new ValueSourceQuery(vs);
       ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
       try {
-        assertEquals("All docs should be matched!",N_DOCS,h.length);
+        assertEquals("All docs should be matched!", N_DOCS, h.length);
         IndexReader[] readers = s.getIndexReader().getSequentialSubReaders();
 
-        for(int j = 0; j &lt; readers.length; j++) {
-          IndexReader reader = readers[j];
-          if (i==0) {
+        for (IndexReader reader : readers) {
+          if (i == 0) {
             innerArray = q.valSrc.getValues(reader).getInnerArray();
           } else {
-            log(i+".  compare: "+innerArray+" to "+q.valSrc.getValues(reader).getInnerArray());
+            log(i + ".  compare: " + innerArray + " to " + q.valSrc.getValues(reader).getInnerArray());
             assertSame("field values should be cached and reused!", innerArray, q.valSrc.getValues(reader).getInnerArray());
           }
         }
       } catch (UnsupportedOperationException e) {
         if (!warned) {
-          System.err.println("WARNING: "+testName()+" cannot fully test values of "+q);
+          System.err.println("WARNING: " + testName() + " cannot fully test values of " + q);
           warned = true;
         }
       }
     }
-    
+
     ValueSource vs;
     ValueSourceQuery q;
     ScoreDoc[] h;
-    
+
     // verify that different values are loaded for a different field
     String field2 = INT_FIELD;
     assertFalse(field.equals(field2)); // otherwise this test is meaningless.
@@ -184,21 +195,20 @@
     }
     q = new ValueSourceQuery(vs);
     h = s.search(q, null, 1000).scoreDocs;
-    assertEquals("All docs should be matched!",N_DOCS,h.length);
+    assertEquals("All docs should be matched!", N_DOCS, h.length);
     IndexReader[] readers = s.getIndexReader().getSequentialSubReaders();
 
-    for (int j = 0; j &lt; readers.length; j++) {
-      IndexReader reader = readers[j];
+    for (IndexReader reader : readers) {
       try {
         log("compare (should differ): " + innerArray + " to "
-            + q.valSrc.getValues(reader).getInnerArray());
+                + q.valSrc.getValues(reader).getInnerArray());
         assertNotSame(
-            "different values shuold be loaded for a different field!",
-            innerArray, q.valSrc.getValues(reader).getInnerArray());
+                "different values shuold be loaded for a different field!",
+                innerArray, q.valSrc.getValues(reader).getInnerArray());
       } catch (UnsupportedOperationException e) {
         if (!warned) {
           System.err.println("WARNING: " + testName()
-              + " cannot fully test values of " + q);
+                  + " cannot fully test values of " + q);
           warned = true;
         }
       }
@@ -213,21 +223,20 @@
     }
     q = new ValueSourceQuery(vs);
     h = s.search(q, null, 1000).scoreDocs;
-    assertEquals("All docs should be matched!",N_DOCS,h.length);
+    assertEquals("All docs should be matched!", N_DOCS, h.length);
     readers = s.getIndexReader().getSequentialSubReaders();
 
-    for (int j = 0; j &lt; readers.length; j++) {
-      IndexReader reader = readers[j];
+    for (IndexReader reader : readers) {
       try {
         log("compare (should differ): " + innerArray + " to "
-            + q.valSrc.getValues(reader).getInnerArray());
+                + q.valSrc.getValues(reader).getInnerArray());
         assertNotSame(
-            "cached field values should not be reused if reader as changed!",
-            innerArray, q.valSrc.getValues(reader).getInnerArray());
+                "cached field values should not be reused if reader as changed!",
+                innerArray, q.valSrc.getValues(reader).getInnerArray());
       } catch (UnsupportedOperationException e) {
         if (!warned) {
           System.err.println("WARNING: " + testName()
-              + " cannot fully test values of " + q);
+                  + " cannot fully test values of " + q);
           warned = true;
         }
       }
@@ -235,7 +244,7 @@
   }
 
   private String testName() {
-    return getClass().getName()+"."+getName();
+    return getClass().getName() + "." + getName();
   }
 
 }

Added: lucene/java/trunk/src/test/org/apache/lucene/util/InterceptTestCaseEvents.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/InterceptTestCaseEvents.java?rev=887569&amp;view=auto
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/InterceptTestCaseEvents.java (added)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/InterceptTestCaseEvents.java Sat Dec  5 18:27:27 2009
@@ -0,0 +1,60 @@
+package org.apache.lucene.util;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+import org.junit.rules.TestWatchman;
+import org.junit.runners.model.FrameworkMethod;
+
+import java.lang.reflect.Method;
+
+
+public final class InterceptTestCaseEvents extends TestWatchman {
+  private Object obj;
+
+  public InterceptTestCaseEvents(Object obj) {
+    this.obj = obj;
+  }
+
+  @Override
+  public void failed(Throwable e, FrameworkMethod method) {
+    try {
+      Method reporter = method.getMethod().getDeclaringClass().getMethod("reportAdditionalFailureInfo",(Class&lt;?&gt;[]) null);
+      reporter.invoke(obj, (Object[])null);
+    } catch (Exception e1) {
+      System.err.println("InterceptTestCaseEvents.failed(). Cannot invoke reportAdditionalFailureInfo() method in" +
+              " consuming class, is it declared and public?");
+    }
+    super.failed(e, method);
+  }
+
+  @Override
+  public void finished(FrameworkMethod method) {
+    super.finished(method);
+  }
+
+  @Override
+  public void starting(FrameworkMethod method) {
+    super.starting(method);
+  }
+
+  @Override
+  public void succeeded(FrameworkMethod method) {
+    super.succeeded(method);
+  }
+}

Propchange: lucene/java/trunk/src/test/org/apache/lucene/util/InterceptTestCaseEvents.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=887569&amp;r1=887568&amp;r2=887569&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java Sat Dec  5 18:27:27 2009
@@ -46,7 +46,11 @@
  * &lt;code&gt;super.tearDown()&lt;/code&gt;
  * &lt;/p&gt;
  * @see #assertSaneFieldCaches
+ *
+ * @deprecated Replaced by {@link #LuceneTestCaseJ4}
+ *
  */
+@Deprecated
 public abstract class LuceneTestCase extends TestCase {
 
   public LuceneTestCase() {

Added: lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java?rev=887569&amp;view=auto
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (added)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java Sat Dec  5 18:27:27 2009
@@ -0,0 +1,254 @@
+package org.apache.lucene.util;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.index.ConcurrentMergeScheduler;
+import org.apache.lucene.search.FieldCache;
+import org.apache.lucene.search.FieldCache.CacheEntry;
+import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.TestWatchman;
+
+import java.io.PrintStream;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Random;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Base class for all Lucene unit tests, Junit4 variant.
+ * Replaces LuceneTestCase.
+ * &lt;p&gt;
+ * &lt;/p&gt;
+ * &lt;p&gt;
+ * If you
+ * override either &lt;code&gt;setUp()&lt;/code&gt; or
+ * &lt;code&gt;tearDown()&lt;/code&gt; in your unit test, make sure you
+ * call &lt;code&gt;super.setUp()&lt;/code&gt; and
+ * &lt;code&gt;super.tearDown()&lt;/code&gt;
+ * &lt;/p&gt;
+ *
+ * @After - replaces setup
+ * @Before - replaces teardown
+ * @Test - any public method with this annotation is a test case, regardless
+ * of its name
+ * &lt;p/&gt;
+ * &lt;p/&gt;
+ * See Junit4 documentation for a complete list of features at
+ * http://junit.org/junit/javadoc/4.7/
+ * &lt;p/&gt;
+ * Import from org.junit rather than junit.framework.
+ * &lt;p/&gt;
+ * You should be able to use this class anywhere you used LuceneTestCase
+ * if you annotate your derived class correctly with the annotations above
+ * @see assertSaneFieldCaches
+ *      &lt;p/&gt;
+ */
+
+
+// If we really need functionality in runBare override from LuceneTestCase,
+// we can introduce RunBareWrapper and override runChild, and add the
+// @RunWith annotation as below. runChild will be called for
+// every test. But the functionality we used to
+// get from that override is provided by InterceptTestCaseEvents
+//@RunWith(RunBareWrapper.class)
+public class LuceneTestCaseJ4 extends TestWatchman {
+
+  // This is how we get control when errors occur.
+  // Think of this as start/end/success/failed
+  // events.
+  @Rule
+  public InterceptTestCaseEvents intercept = new InterceptTestCaseEvents(this);
+
+  public LuceneTestCaseJ4() {
+  }
+
+  public LuceneTestCaseJ4(String name) {
+    this.name = name;
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    ConcurrentMergeScheduler.setTestMode();
+    seed = null;
+  }
+
+
+  /**
+   * Forcible purges all cache entries from the FieldCache.
+   * &lt;p&gt;
+   * This method will be called by tearDown to clean up FieldCache.DEFAULT.
+   * If a (poorly written) test has some expectation that the FieldCache
+   * will persist across test methods (ie: a static IndexReader) this
+   * method can be overridden to do nothing.
+   * &lt;/p&gt;
+   *
+   * @see FieldCache#purgeAllCaches()
+   */
+  protected void purgeFieldCache(final FieldCache fc) {
+    fc.purgeAllCaches();
+  }
+
+  protected String getTestLabel() {
+    return getClass().getName() + "." + getName();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    try {
+      // this isn't as useful as calling directly from the scope where the
+      // index readers are used, because they could be gc'ed just before
+      // tearDown is called.
+      // But it's better then nothing.
+      assertSaneFieldCaches(getTestLabel());
+
+      if (ConcurrentMergeScheduler.anyUnhandledExceptions()) {
+        // Clear the failure so that we don't just keep
+        // failing subsequent test cases
+        ConcurrentMergeScheduler.clearUnhandledExceptions();
+        fail("ConcurrentMergeScheduler hit unhandled exceptions");
+      }
+    } finally {
+      purgeFieldCache(FieldCache.DEFAULT);
+    }
+  }
+
+  /**
+   * Asserts that FieldCacheSanityChecker does not detect any
+   * problems with FieldCache.DEFAULT.
+   * &lt;p&gt;
+   * If any problems are found, they are logged to System.err
+   * (allong with the msg) when the Assertion is thrown.
+   * &lt;/p&gt;
+   * &lt;p&gt;
+   * This method is called by tearDown after every test method,
+   * however IndexReaders scoped inside test methods may be garbage
+   * collected prior to this method being called, causing errors to
+   * be overlooked. Tests are encouraged to keep their IndexReaders
+   * scoped at the class level, or to explicitly call this method
+   * directly in the same scope as the IndexReader.
+   * &lt;/p&gt;
+   *
+   * @see FieldCacheSanityChecker
+   */
+  protected void assertSaneFieldCaches(final String msg) {
+    final CacheEntry[] entries = FieldCache.DEFAULT.getCacheEntries();
+    Insanity[] insanity = null;
+    try {
+      try {
+        insanity = FieldCacheSanityChecker.checkSanity(entries);
+      } catch (RuntimeException e) {
+        dumpArray(msg + ": FieldCache", entries, System.err);
+        throw e;
+      }
+
+      assertEquals(msg + ": Insane FieldCache usage(s) found",
+              0, insanity.length);
+      insanity = null;
+    } finally {
+
+      // report this in the event of any exception/failure
+      // if no failure, then insanity will be null anyway
+      if (null != insanity) {
+        dumpArray(msg + ": Insane FieldCache usage(s)", insanity, System.err);
+      }
+
+    }
+  }
+
+  /**
+   * Convinience method for logging an iterator.
+   *
+   * @param label  String logged before/after the items in the iterator
+   * @param iter   Each next() is toString()ed and logged on it's own line. If iter is null this is logged differnetly then an empty iterator.
+   * @param stream Stream to log messages to.
+   */
+  public static void dumpIterator(String label, Iterator iter,
+                                  PrintStream stream) {
+    stream.println("*** BEGIN " + label + " ***");
+    if (null == iter) {
+      stream.println(" ... NULL ...");
+    } else {
+      while (iter.hasNext()) {
+        stream.println(iter.next().toString());
+      }
+    }
+    stream.println("*** END " + label + " ***");
+  }
+
+  /**
+   * Convinience method for logging an array.  Wraps the array in an iterator and delegates
+   *
+   * @see dumpIterator(String,Iterator,PrintStream)
+   */
+  public static void dumpArray(String label, Object[] objs,
+                               PrintStream stream) {
+    Iterator iter = (null == objs) ? null : Arrays.asList(objs).iterator();
+    dumpIterator(label, iter, stream);
+  }
+
+  /**
+   * Returns a {@link Random} instance for generating random numbers during the test.
+   * The random seed is logged during test execution and printed to System.out on any failure
+   * for reproducing the test using {@link #newRandom(long)} with the recorded seed
+   * .
+   */
+  public Random newRandom() {
+    if (seed != null) {
+      throw new IllegalStateException("please call LuceneTestCase.newRandom only once per test");
+    }
+    return newRandom(seedRnd.nextLong());
+  }
+
+  /**
+   * Returns a {@link Random} instance for generating random numbers during the test.
+   * If an error occurs in the test that is not reproducible, you can use this method to
+   * initialize the number generator with the seed that was printed out during the failing test.
+   */
+  public Random newRandom(long seed) {
+    if (this.seed != null) {
+      throw new IllegalStateException("please call LuceneTestCase.newRandom only once per test");
+    }
+    this.seed = Long.valueOf(seed);
+    return new Random(seed);
+  }
+
+  public String getName() {
+    return this.name;
+  }
+
+  // We get here fro InterceptTestCaseEvents on the 'failed' event.... 
+  public void reportAdditionalFailureInfo() {
+    if (seed != null) {
+      System.out.println("NOTE: random seed of testcase '" + getName() + "' was: " + seed);
+    }
+  }
+
+  // recorded seed
+  protected Long seed = null;
+
+  // static members
+  private static final Random seedRnd = new Random();
+
+  private String name = "";
+
+}

Propchange: lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
------------------------------------------------------------------------------
    svn:eol-style = native




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887535 - in /lucene/java/trunk/contrib: ./ analyzers/common/src/java/org/apache/lucene/analysis/tr/ analyzers/common/src/test/org/apache/lucene/analysis/tr/</title>
<author><name>simonw@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091205124606.0D29A23888FE@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205124606-0D29A23888FE@eris-apache-org%3e</id>
<updated>2009-12-05T12:46:05Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: simonw
Date: Sat Dec  5 12:46:05 2009
New Revision: 887535

URL: http://svn.apache.org/viewvc?rev=887535&amp;view=rev
Log:
LUCENE-2102: Add Turkish LowerCaseFilter which handles Turkish and Azeri unique casing behavior
correctly.

Added:
    lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/
    lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/TurkishLowerCaseFilter.java
  (with props)
    lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/package.html
  (with props)
    lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/tr/
    lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/tr/TestTurkishLowerCaseFilter.java
  (with props)
Modified:
    lucene/java/trunk/contrib/CHANGES.txt

Modified: lucene/java/trunk/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/CHANGES.txt?rev=887535&amp;r1=887534&amp;r2=887535&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/CHANGES.txt Sat Dec  5 12:46:05 2009
@@ -16,6 +16,10 @@
    reader.  (Eirik BjÃ¸rsnÃ¸s via Mike McCandless)
 
 New features
+
+ * LUCENE-2102: Add a Turkish LowerCase Filter. TurkishLowerCaseFilter handles
+   Turkish and Azeri unique casing behavior correctly.
+   (Ahmet Arslan, Robert Muir via Simon Willnauer)
  
  * LUCENE-2039: Add a extensible query parser to contrib/misc.
    ExtendableQueryParser enables arbitrary parser extensions based on a

Added: lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/TurkishLowerCaseFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/TurkishLowerCaseFilter.java?rev=887535&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/TurkishLowerCaseFilter.java
(added)
+++ lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/TurkishLowerCaseFilter.java
Sat Dec  5 12:46:05 2009
@@ -0,0 +1,125 @@
+package org.apache.lucene.analysis.tr;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.lucene.analysis.TokenFilter;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+
+/**
+ * Normalizes Turkish token text to lower case.
+ * &lt;p&gt;
+ * Turkish and Azeri have unique casing behavior for some characters. This
+ * filter applies Turkish lowercase rules. For more information, see &lt;a
+ * href="http://en.wikipedia.org/wiki/Turkish_dotted_and_dotless_I"
+ * &gt;http://en.wikipedia.org/wiki/Turkish_dotted_and_dotless_I&lt;/a&gt;
+ * &lt;/p&gt;
+ */
+public final class TurkishLowerCaseFilter extends TokenFilter {
+  private static final int LATIN_CAPITAL_LETTER_I = '\u0049';
+  private static final int LATIN_SMALL_LETTER_I = '\u0069';
+  private static final int LATIN_SMALL_LETTER_DOTLESS_I = '\u0131';
+  private static final int COMBINING_DOT_ABOVE = '\u0307';
+  private final TermAttribute termAtt;
+  
+  /**
+   * Create a new TurkishLowerCaseFilter, that normalizes Turkish token text 
+   * to lower case.
+   * 
+   * @param in TokenStream to filter
+   */
+  public TurkishLowerCaseFilter(TokenStream in) {
+    super(in);
+    termAtt = addAttribute(TermAttribute.class);
+  }
+  
+  @Override
+  public final boolean incrementToken() throws IOException {
+    boolean iOrAfter = false;
+    
+    if (input.incrementToken()) {
+      final char[] buffer = termAtt.termBuffer();
+      int length = termAtt.termLength();
+      for (int i = 0; i &lt; length;) {
+        final int ch = Character.codePointAt(buffer, i);
+    
+        iOrAfter = (ch == LATIN_CAPITAL_LETTER_I || 
+            (iOrAfter &amp;&amp; Character.getType(ch) == Character.NON_SPACING_MARK));
+        
+        if (iOrAfter) { // all the special I turkish handling happens here.
+          switch(ch) {
+            // remove COMBINING_DOT_ABOVE to mimic composed lowercase
+            case COMBINING_DOT_ABOVE:
+              length = delete(buffer, i, length);
+              continue;
+            // i itself, it depends if it is followed by COMBINING_DOT_ABOVE
+            // if it is, we will make it small i and later remove the dot
+            case LATIN_CAPITAL_LETTER_I:
+              if (isBeforeDot(buffer, i + 1, length)) {
+                buffer[i] = LATIN_SMALL_LETTER_I;
+              } else {
+                buffer[i] = LATIN_SMALL_LETTER_DOTLESS_I;
+                // below is an optimization. no COMBINING_DOT_ABOVE follows,
+                // so don't waste time calculating Character.getType(), etc
+                iOrAfter = false;
+              }
+              i++;
+              continue;
+          }
+        }
+        
+        i += Character.toChars(Character.toLowerCase(ch), buffer, i);
+      }
+      
+      termAtt.setTermLength(length);
+      return true;
+    } else
+      return false;
+  }
+  
+  
+  /**
+   * lookahead for a combining dot above.
+   * other NSMs may be in between.
+   */
+  private boolean isBeforeDot(char s[], int pos, int len) {
+    for (int i = pos; i &lt; len;) {
+      final int ch = Character.codePointAt(s, i);
+      if (Character.getType(ch) != Character.NON_SPACING_MARK)
+        return false;
+      if (ch == COMBINING_DOT_ABOVE)
+        return true;
+      i += Character.charCount(ch);
+    }
+    
+    return false;
+  }
+  
+  /**
+   * delete a character in-place.
+   * rarely happens, only if COMBINING_DOT_ABOVE is found after an i
+   */
+  private int delete(char s[], int pos, int len) {
+    if (pos &lt; len) 
+      System.arraycopy(s, pos + 1, s, pos, len - pos - 1);
+    
+    return len - 1;
+  }
+}

Propchange: lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/TurkishLowerCaseFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/TurkishLowerCaseFilter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/package.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/package.html?rev=887535&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/package.html
(added)
+++ lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/package.html
Sat Dec  5 12:46:05 2009
@@ -0,0 +1,31 @@
+&lt;!doctype html public "-//w3c//dtd html 4.0 transitional//en"&gt;
+&lt;!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--&gt;
+&lt;html&gt;&lt;head&gt;&lt;/head&gt;
+&lt;body&gt;
+Support for Turkish.
+&lt;p&gt;
+This package contains just the TokenStream for handling turkish casing,
+for a stemmer please see the snowball package. 
+&lt;/p&gt;
+&lt;p&gt;
+WARNING: SnowballAnalyzer uses LowerCaseFilter by default, even when the
+language is set to Turkish, so you will need to construct your own
+analyzer that combines TurkishLowerCaseFilter and SnowballFilter.
+&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
\ No newline at end of file

Propchange: lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/tr/package.html
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/tr/TestTurkishLowerCaseFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/tr/TestTurkishLowerCaseFilter.java?rev=887535&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/tr/TestTurkishLowerCaseFilter.java
(added)
+++ lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/tr/TestTurkishLowerCaseFilter.java
Sat Dec  5 12:46:05 2009
@@ -0,0 +1,65 @@
+package org.apache.lucene.analysis.tr;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.StringReader;
+
+import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.WhitespaceTokenizer;
+
+/**
+ * Test the Turkish lowercase filter.
+ */
+public class TestTurkishLowerCaseFilter extends BaseTokenStreamTestCase {
+  
+  /**
+   * Test composed forms
+   */
+  public void testTurkishLowerCaseFilter() throws Exception {
+    TokenStream stream = new WhitespaceTokenizer(new StringReader(
+        "\u0130STANBUL \u0130ZM\u0130R ISPARTA"));
+    TurkishLowerCaseFilter filter = new TurkishLowerCaseFilter(stream);
+    assertTokenStreamContents(filter, new String[] {"istanbul", "izmir",
+        "\u0131sparta",});
+  }
+  
+  /**
+   * Test decomposed forms
+   */
+  public void testDecomposed() throws Exception {
+    TokenStream stream = new WhitespaceTokenizer(new StringReader(
+        "\u0049\u0307STANBUL \u0049\u0307ZM\u0049\u0307R ISPARTA"));
+    TurkishLowerCaseFilter filter = new TurkishLowerCaseFilter(stream);
+    assertTokenStreamContents(filter, new String[] {"istanbul", "izmir",
+        "\u0131sparta",});
+  }
+  
+  /**
+   * Test decomposed forms with additional accents
+   * In this example, U+0049 + U+0316 + U+0307 is canonically equivalent
+   * to U+0130 + U+0316, and is lowercased the same way.
+   */
+  public void testDecomposed2() throws Exception {
+    TokenStream stream = new WhitespaceTokenizer(new StringReader(
+        "\u0049\u0316\u0307STANBUL \u0049\u0307ZM\u0049\u0307R I\u0316SPARTA"));
+    TurkishLowerCaseFilter filter = new TurkishLowerCaseFilter(stream);
+    assertTokenStreamContents(filter, new String[] {"i\u0316stanbul", "izmir",
+        "\u0131\u0316sparta",});
+  }
+}

Propchange: lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/tr/TestTurkishLowerCaseFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/tr/TestTurkishLowerCaseFilter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887533 - in /lucene/java/trunk/contrib: ./ misc/src/java/org/apache/lucene/queryParser/ext/ misc/src/test/org/apache/lucene/queryParser/ext/</title>
<author><name>simonw@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091205123003.1EC7423888FE@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205123003-1EC7423888FE@eris-apache-org%3e</id>
<updated>2009-12-05T12:30:02Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: simonw
Date: Sat Dec  5 12:29:59 2009
New Revision: 887533

URL: http://svn.apache.org/viewvc?rev=887533&amp;view=rev
Log:
LUCENE-2039: Added extensible query parser which enables arbitrary parser extensions based
on field naming scheme

Added:
    lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/
    lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtendableQueryParser.java
  (with props)
    lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtensionQuery.java
  (with props)
    lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/Extensions.java
  (with props)
    lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ParserExtension.java
  (with props)
    lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/package.html
  (with props)
    lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/
    lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/ExtensionStub.java
  (with props)
    lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtendableQueryParser.java
  (with props)
    lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtensions.java
  (with props)
Modified:
    lucene/java/trunk/contrib/CHANGES.txt

Modified: lucene/java/trunk/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/CHANGES.txt?rev=887533&amp;r1=887532&amp;r2=887533&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/CHANGES.txt Sat Dec  5 12:29:59 2009
@@ -16,6 +16,11 @@
    reader.  (Eirik BjÃ¸rsnÃ¸s via Mike McCandless)
 
 New features
+ 
+ * LUCENE-2039: Add a extensible query parser to contrib/misc.
+   ExtendableQueryParser enables arbitrary parser extensions based on a
+   customizable field naming scheme.
+   (Simon Willnauer)
 
  * LUCENE-2108: Spellchecker now safely supports concurrent modifications to
    the spell-index. Threads can safely obtain term suggestions while the spell-

Added: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtendableQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtendableQueryParser.java?rev=887533&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtendableQueryParser.java
(added)
+++ lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtendableQueryParser.java
Sat Dec  5 12:29:59 2009
@@ -0,0 +1,142 @@
+package org.apache.lucene.queryParser.ext;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.queryParser.ext.Extensions.Pair;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.util.Version;
+
+/**
+ * The {@link ExtendableQueryParser} enables arbitrary query parser extension
+ * based on a customizable field naming scheme. The lucene query syntax allows
+ * implicit and explicit field definitions as query prefix followed by a colon
+ * (':') character. The {@link ExtendableQueryParser} allows to encode extension
+ * keys into the field symbol associated with a registered instance of
+ * {@link ParserExtension}. A customizable separation character separates the
+ * extension key from the actual field symbol. The {@link ExtendableQueryParser}
+ * splits (@see {@link Extensions#splitExtensionField(String, String)}) the
+ * extension key from the field symbol and tries to resolve the associated
+ * {@link ParserExtension}. If the parser can't resolve the key or the field
+ * token does not contain a separation character, {@link ExtendableQueryParser}
+ * yields the same behavior as its super class {@link QueryParser}. Otherwise,
+ * if the key is associated with a {@link ParserExtension} instance, the parser
+ * builds an instance of {@link ExtensionQuery} to be processed by
+ * {@link ParserExtension#parse(ExtensionQuery)}.If a extension field does not
+ * contain a field part the default field for the query will be used.
+ * &lt;p&gt;
+ * To guarantee that an extension field is processed with its associated
+ * extension, the extension query part must escape any special characters like
+ * '*' or '['. If the extension query contains any whitespace characters, the
+ * extension query part must be enclosed in quotes.
+ * Example ('_' used as separation character):
+ * &lt;pre&gt;
+ *   title_customExt:"Apache Lucene\?" OR content_customExt:prefix\*
+ * &lt;/pre&gt;
+ * 
+ * Search on the default field:
+ * &lt;pre&gt;
+ *   _customExt:"Apache Lucene\?" OR _customExt:prefix\*
+ * &lt;/pre&gt;
+ * &lt;/p&gt;
+ * &lt;p&gt;
+ * The {@link ExtendableQueryParser} itself does not implement the logic how
+ * field and extension key are separated or ordered. All logic regarding the
+ * extension key and field symbol parsing is located in {@link Extensions}.
+ * Customized extension schemes should be implemented by sub-classing
+ * {@link Extensions}.
+ * &lt;/p&gt;
+ * &lt;p&gt;
+ * For details about the default encoding scheme see {@link Extensions}.
+ * &lt;/p&gt;
+ * 
+ * @see Extensions
+ * @see ParserExtension
+ * @see ExtensionQuery
+ */
+public class ExtendableQueryParser extends QueryParser {
+
+  private final String defaultField;
+  private final Extensions extensions;
+
+  /**
+   * Default empty extensions instance
+   */
+  private static final Extensions DEFAULT_EXTENSION = new Extensions();
+
+  /**
+   * Creates a new {@link ExtendableQueryParser} instance
+   * 
+   * @param matchVersion
+   *          the lucene version to use.
+   * @param f
+   *          the default query field
+   * @param a
+   *          the analyzer used to find terms in a query string
+   */
+  public ExtendableQueryParser(final Version matchVersion, final String f,
+      final Analyzer a) {
+    this(matchVersion, f, a, DEFAULT_EXTENSION);
+
+  }
+
+  /**
+   * Creates a new {@link ExtendableQueryParser} instance
+   * 
+   * @param matchVersion
+   *          the lucene version to use.
+   * @param f
+   *          the default query field
+   * @param a
+   *          the analyzer used to find terms in a query string
+   * @param ext
+   *          the query parser extensions
+   */
+  public ExtendableQueryParser(final Version matchVersion, final String f,
+      final Analyzer a, final Extensions ext) {
+    super(matchVersion, f, a);
+    this.defaultField = f;
+    this.extensions = ext;
+  }
+
+  /**
+   * Returns the extension field delimiter character.
+   * 
+   * @return the extension field delimiter character.
+   */
+  public char getExtensionFieldDelimiter() {
+    return extensions.getExtensionFieldDelimiter();
+  }
+
+  @Override
+  protected Query getFieldQuery(final String field, final String queryText)
+      throws ParseException {
+    final Pair&lt;String,String&gt; splitExtensionField = this.extensions
+        .splitExtensionField(defaultField, field);
+    final ParserExtension extension = this.extensions
+        .getExtension(splitExtensionField.cud);
+    if (extension != null) {
+      return extension.parse(new ExtensionQuery(splitExtensionField.cur,
+          queryText));
+    }
+    return super.getFieldQuery(field, queryText);
+  }
+
+}

Propchange: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtendableQueryParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtendableQueryParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtensionQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtensionQuery.java?rev=887533&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtensionQuery.java
(added)
+++ lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtensionQuery.java
Sat Dec  5 12:29:59 2009
@@ -0,0 +1,63 @@
+package org.apache.lucene.queryParser.ext;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * {@link ExtensionQuery} holds all query components extracted from the original
+ * query string like the query field and the extension query string.
+ * 
+ * @see Extensions
+ * @see ExtendableQueryParser
+ * @see ParserExtension
+ */
+public class ExtensionQuery {
+
+  private final String field;
+  private final String rawQueryString;
+
+  /**
+   * Creates a new {@link ExtensionQuery}
+   * 
+   * @param field
+   *          the query field
+   * @param rawQueryString
+   *          the raw extension query string
+   */
+  public ExtensionQuery(String field, String rawQueryString) {
+    this.field = field;
+    this.rawQueryString = rawQueryString;
+  }
+
+  /**
+   * Returns the query field
+   * 
+   * @return the query field
+   */
+  public String getField() {
+    return field;
+  }
+
+  /**
+   * Returns the raw extension query string
+   * 
+   * @return the raw extension query string
+   */
+  public String getRawQueryString() {
+    return rawQueryString;
+  }
+}

Propchange: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtensionQuery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ExtensionQuery.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/Extensions.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/Extensions.java?rev=887533&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/Extensions.java
(added)
+++ lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/Extensions.java
Sat Dec  5 12:29:59 2009
@@ -0,0 +1,217 @@
+package org.apache.lucene.queryParser.ext;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.lucene.queryParser.QueryParser;
+
+/**
+ * The {@link Extensions} class represents an extension mapping to associate
+ * {@link ParserExtension} instances with extension keys. An extension key is a
+ * string encoded into a Lucene standard query parser field symbol recognized by
+ * {@link ExtendableQueryParser}. The query parser passes each extension field
+ * token to {@link #splitExtensionField(String, String)} to separate the
+ * extension key from the field identifier.
+ * &lt;p&gt;
+ * In addition to the key to extension mapping this class also defines the field
+ * name overloading scheme. {@link ExtendableQueryParser} uses the given
+ * extension to split the actual field name and extension key by calling
+ * {@link #splitExtensionField(String, String)}. To change the order or the key
+ * / field name encoding scheme users can subclass {@link Extensions} to
+ * implement their own.
+ * 
+ * @see ExtendableQueryParser
+ * @see ParserExtension
+ */
+public class Extensions {
+  private final Map&lt;String,ParserExtension&gt; extensions = new HashMap&lt;String,ParserExtension&gt;();
+  private final char extensionFieldDelimiter;
+  /**
+   * The default extension field delimiter character. This constant is set to
+   * ':'
+   */
+  public static final char DEFAULT_EXTENSION_FIELD_DELIMITER = ':';
+
+  /**
+   * Creates a new {@link Extensions} instance with the
+   * {@link #DEFAULT_EXTENSION_FIELD_DELIMITER} as a delimiter character.
+   */
+  public Extensions() {
+    this(DEFAULT_EXTENSION_FIELD_DELIMITER);
+  }
+
+  /**
+   * Creates a new {@link Extensions} instance
+   * 
+   * @param extensionFieldDelimiter
+   *          the extensions field delimiter character
+   */
+  public Extensions(char extensionFieldDelimiter) {
+    this.extensionFieldDelimiter = extensionFieldDelimiter;
+  }
+
+  /**
+   * Adds a new {@link ParserExtension} instance associated with the given key.
+   * 
+   * @param key
+   *          the parser extension key
+   * @param extension
+   *          the parser extension
+   */
+  public void add(String key, ParserExtension extension) {
+    this.extensions.put(key, extension);
+  }
+
+  /**
+   * Returns the {@link ParserExtension} instance for the given key or
+   * &lt;code&gt;null&lt;/code&gt; if no extension can be found for the key.
+   * 
+   * @param key
+   *          the extension key
+   * @return the {@link ParserExtension} instance for the given key or
+   *         &lt;code&gt;null&lt;/code&gt; if no extension can be found for the key.
+   */
+  public final ParserExtension getExtension(String key) {
+    return this.extensions.get(key);
+  }
+
+  /**
+   * Returns the extension field delimiter
+   * 
+   * @return the extension field delimiter
+   */
+  public char getExtensionFieldDelimiter() {
+    return extensionFieldDelimiter;
+  }
+
+  /**
+   * Splits a extension field and returns the field / extension part as a
+   * {@link Pair}. This method tries to split on the first occurrence of the
+   * extension field delimiter, if the delimiter is not present in the string
+   * the result will contain a &lt;code&gt;null&lt;/code&gt; value for the extension key
and
+   * the given field string as the field value. If the given extension field
+   * string contains no field identifier the result pair will carry the given
+   * default field as the field value.
+   * 
+   * @param defaultField
+   *          the default query field
+   * @param field
+   *          the extension field string
+   * @return a {@link Pair} with the field name as the {@link Pair#cur} and the
+   *         extension key as the {@link Pair#cud}
+   */
+  public Pair&lt;String,String&gt; splitExtensionField(String defaultField,
+      String field) {
+    int indexOf = field.indexOf(this.extensionFieldDelimiter);
+    if (indexOf &lt; 0)
+      return new Pair&lt;String,String&gt;(field, null);
+    final String indexField = indexOf == 0 ? defaultField : field.substring(0,
+        indexOf);
+    final String extensionKey = field.substring(indexOf + 1);
+    return new Pair&lt;String,String&gt;(indexField, extensionKey);
+
+  }
+
+  /**
+   * Escapes an extension field. The default implementation is equivalent to
+   * {@link QueryParser#escape(String)}.
+   * 
+   * @param extfield
+   *          the extension field identifier
+   * @return the extension field identifier with all special chars escaped with
+   *         a backslash character.
+   */
+  public String escapeExtensionField(String extfield) {
+    return QueryParser.escape(extfield);
+  }
+
+  /**
+   * Builds an extension field string from a given extension key and the default
+   * query field. The default field and the key are delimited with the extension
+   * field delimiter character. This method makes no assumption about the order
+   * of the extension key and the field. By default the extension key is
+   * appended to the end of the returned string while the field is added to the
+   * beginning. Special Query characters are escaped in the result.
+   * &lt;p&gt;
+   * Note: {@link Extensions} subclasses must maintain the contract between
+   * {@link #buildExtensionField(String)} and
+   * {@link #splitExtensionField(String, String)} where the latter inverts the
+   * former.
+   * &lt;/p&gt;
+   */
+  public String buildExtensionField(String extensionKey) {
+    return buildExtensionField(extensionKey, "");
+  }
+
+  /**
+   * Builds an extension field string from a given extension key and the
+   * extensions field. The field and the key are delimited with the extension
+   * field delimiter character. This method makes no assumption about the order
+   * of the extension key and the field. By default the extension key is
+   * appended to the end of the returned string while the field is added to the
+   * beginning. Special Query characters are escaped in the result.
+   * &lt;p&gt;
+   * Note: {@link Extensions} subclasses must maintain the contract between
+   * {@link #buildExtensionField(String, String)} and
+   * {@link #splitExtensionField(String, String)} where the latter inverts the
+   * former.
+   * &lt;/p&gt;
+   * 
+   * @param extensionKey
+   *          the extension key
+   * @param field
+   *          the field to apply the extension on.
+   * @return escaped extension field identifier
+   * @see #buildExtensionField(String) to use the default query field
+   */
+  public String buildExtensionField(String extensionKey, String field) {
+    StringBuilder builder = new StringBuilder(field);
+    builder.append(this.extensionFieldDelimiter);
+    builder.append(extensionKey);
+    return escapeExtensionField(builder.toString());
+  }
+
+  /**
+   * This class represents a generic pair.
+   * 
+   * @param &lt;Cur&gt;
+   *          the pairs first element
+   * @param &lt;Cud&gt;
+   *          the pairs last element of the pair.
+   */
+  public static class Pair&lt;Cur,Cud&gt; {
+
+    public final Cur cur;
+    public final Cud cud;
+
+    /**
+     * Creates a new Pair
+     * 
+     * @param cur
+     *          the pairs first element
+     * @param cud
+     *          the pairs last element
+     */
+    public Pair(Cur cur, Cud cud) {
+      this.cur = cur;
+      this.cud = cud;
+    }
+  }
+
+}

Propchange: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/Extensions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/Extensions.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ParserExtension.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ParserExtension.java?rev=887533&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ParserExtension.java
(added)
+++ lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ParserExtension.java
Sat Dec  5 12:29:59 2009
@@ -0,0 +1,53 @@
+package org.apache.lucene.queryParser.ext;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+
+/**
+ * This class represents an extension base class to the Lucene standard
+ * {@link QueryParser}. The {@link QueryParser} is generated by the JavaCC
+ * parser generator. Changing or adding functionality or syntax in the standard
+ * query parser requires changes to the JavaCC source file. To enable extending
+ * the standard query parser without changing the JavaCC sources and re-generate
+ * the parser the {@link ParserExtension} can be customized and plugged into an
+ * instance of {@link ExtendableQueryParser}, a direct subclass of
+ * {@link QueryParser}.
+ * 
+ * @see Extensions
+ * @see ExtendableQueryParser
+ */
+public abstract class ParserExtension {
+
+  /**
+   * Processes the given {@link ExtensionQuery} and returns a corresponding
+   * {@link Query} instance. Subclasses must either return a {@link Query}
+   * instance or raise a {@link ParseException}. This method must not return
+   * &lt;code&gt;null&lt;/code&gt;.
+   * 
+   * @param query
+   *          the extension query
+   * @return a new query instance
+   * @throws ParseException
+   *           if the query can not be parsed.
+   */
+  public abstract Query parse(final ExtensionQuery query) throws ParseException;
+
+}

Propchange: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ParserExtension.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/ParserExtension.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/package.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/package.html?rev=887533&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/package.html
(added)
+++ lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/package.html
Sat Dec  5 12:29:59 2009
@@ -0,0 +1,22 @@
+&lt;!doctype html public "-//w3c//dtd html 4.0 transitional//en"&gt;
+&lt;!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--&gt;
+&lt;html&gt;&lt;head&gt;&lt;/head&gt;
+&lt;body&gt;
+Extendable QueryParser provides a simple and flexible extension mechanism by overloading
query field names.
+&lt;/body&gt;
+&lt;/html&gt;

Propchange: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/misc/src/java/org/apache/lucene/queryParser/ext/package.html
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/ExtensionStub.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/ExtensionStub.java?rev=887533&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/ExtensionStub.java
(added)
+++ lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/ExtensionStub.java
Sat Dec  5 12:29:59 2009
@@ -0,0 +1,33 @@
+package org.apache.lucene.queryParser.ext;
+
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class ExtensionStub extends ParserExtension {
+
+  @Override
+  public Query parse(ExtensionQuery components) throws ParseException {
+    return new TermQuery(new Term(components.getField(), components
+        .getRawQueryString()));
+  }
+
+}
\ No newline at end of file

Propchange: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/ExtensionStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/ExtensionStub.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtendableQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtendableQueryParser.java?rev=887533&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtendableQueryParser.java
(added)
+++ lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtendableQueryParser.java
Sat Dec  5 12:29:59 2009
@@ -0,0 +1,137 @@
+package org.apache.lucene.queryParser.ext;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.SimpleAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.queryParser.TestQueryParser;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.util.Version;
+
+/**
+ * Testcase for the class {@link ExtendableQueryParser}
+ */
+public class TestExtendableQueryParser extends TestQueryParser {
+  private static char[] DELIMITERS = new char[] {
+      Extensions.DEFAULT_EXTENSION_FIELD_DELIMITER, '-', '|' };
+
+  public TestExtendableQueryParser(String name) {
+    super(name);
+  }
+
+  @Override
+  public QueryParser getParser(Analyzer a) throws Exception {
+    return getParser(a, null);
+  }
+
+  public QueryParser getParser(Analyzer a, Extensions extensions)
+      throws Exception {
+    if (a == null)
+      a = new SimpleAnalyzer();
+    QueryParser qp = extensions == null ? new ExtendableQueryParser(
+        Version.LUCENE_CURRENT, "field", a) : new ExtendableQueryParser(
+        Version.LUCENE_CURRENT, "field", a, extensions);
+    qp.setDefaultOperator(QueryParser.OR_OPERATOR);
+    return qp;
+  }
+
+  public void testUnescapedExtDelimiter() throws Exception {
+    Extensions ext = newExtensions(':');
+    ext.add("testExt", new ExtensionStub());
+    ExtendableQueryParser parser = (ExtendableQueryParser) getParser(null, ext);
+    try {
+      parser.parse("aField:testExt:\"foo \\&amp; bar\"");
+      fail("extension field delimiter is not escaped");
+    } catch (ParseException e) {
+    }
+  }
+
+  public void testExtFieldUnqoted() throws Exception {
+    for (int i = 0; i &lt; DELIMITERS.length; i++) {
+      Extensions ext = newExtensions(DELIMITERS[i]);
+      ext.add("testExt", new ExtensionStub());
+      ExtendableQueryParser parser = (ExtendableQueryParser) getParser(null,
+          ext);
+      String field = ext.buildExtensionField("testExt", "aField");
+      Query query = parser.parse(String.format("%s:foo bar", field));
+      assertTrue("expected instance of BooleanQuery but was "
+          + query.getClass(), query instanceof BooleanQuery);
+      BooleanQuery bquery = (BooleanQuery) query;
+      BooleanClause[] clauses = bquery.getClauses();
+      assertEquals(2, clauses.length);
+      BooleanClause booleanClause = clauses[0];
+      query = booleanClause.getQuery();
+      assertTrue("expected instance of TermQuery but was " + query.getClass(),
+          query instanceof TermQuery);
+      TermQuery tquery = (TermQuery) query;
+      assertEquals("aField", tquery.getTerm()
+          .field());
+      assertEquals("foo", tquery.getTerm().text());
+
+      booleanClause = clauses[1];
+      query = booleanClause.getQuery();
+      assertTrue("expected instance of TermQuery but was " + query.getClass(),
+          query instanceof TermQuery);
+      tquery = (TermQuery) query;
+      assertEquals("field", tquery.getTerm().field());
+      assertEquals("bar", tquery.getTerm().text());
+    }
+  }
+
+  public void testExtDefaultField() throws Exception {
+    for (int i = 0; i &lt; DELIMITERS.length; i++) {
+      Extensions ext = newExtensions(DELIMITERS[i]);
+      ext.add("testExt", new ExtensionStub());
+      ExtendableQueryParser parser = (ExtendableQueryParser) getParser(null,
+          ext);
+      String field = ext.buildExtensionField("testExt");
+      Query parse = parser.parse(String.format("%s:\"foo \\&amp; bar\"", field));
+      assertTrue("expected instance of TermQuery but was " + parse.getClass(),
+          parse instanceof TermQuery);
+      TermQuery tquery = (TermQuery) parse;
+      assertEquals("field", tquery.getTerm().field());
+      assertEquals("foo &amp; bar", tquery.getTerm().text());
+    }
+  }
+
+  public Extensions newExtensions(char delimiter) {
+    return new Extensions(delimiter);
+  }
+
+  public void testExtField() throws Exception {
+    for (int i = 0; i &lt; DELIMITERS.length; i++) {
+      Extensions ext = newExtensions(DELIMITERS[i]);
+      ext.add("testExt", new ExtensionStub());
+      ExtendableQueryParser parser = (ExtendableQueryParser) getParser(null,
+          ext);
+      String field = ext.buildExtensionField("testExt", "afield");
+      Query parse = parser.parse(String.format("%s:\"foo \\&amp; bar\"", field));
+      assertTrue("expected instance of TermQuery but was " + parse.getClass(),
+          parse instanceof TermQuery);
+      TermQuery tquery = (TermQuery) parse;
+      assertEquals("afield", tquery.getTerm().field());
+      assertEquals("foo &amp; bar", tquery.getTerm().text());
+    }
+  }
+
+}

Propchange: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtendableQueryParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtendableQueryParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtensions.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtensions.java?rev=887533&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtensions.java
(added)
+++ lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtensions.java
Sat Dec  5 12:29:59 2009
@@ -0,0 +1,78 @@
+package org.apache.lucene.queryParser.ext;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.util.LuceneTestCase;
+
+/**
+ * Testcase for the {@link Extensions} class
+ */
+public class TestExtensions extends LuceneTestCase {
+
+  private Extensions ext;
+
+  protected void setUp() throws Exception {
+    super.setUp();
+    this.ext = new Extensions();
+  }
+
+  public void testBuildExtensionField() {
+    assertEquals("field\\:key", ext.buildExtensionField("key", "field"));
+    assertEquals("\\:key", ext.buildExtensionField("key"));
+
+    ext = new Extensions('.');
+    assertEquals("field.key", ext.buildExtensionField("key", "field"));
+    assertEquals(".key", ext.buildExtensionField("key"));
+  }
+
+  public void testSplitExtensionField() {
+    assertEquals("field\\:key", ext.buildExtensionField("key", "field"));
+    assertEquals("\\:key", ext.buildExtensionField("key"));
+
+    ext = new Extensions('.');
+    assertEquals("field.key", ext.buildExtensionField("key", "field"));
+    assertEquals(".key", ext.buildExtensionField("key"));
+  }
+
+  public void testAddGetExtension() {
+    ParserExtension extension = new ExtensionStub();
+    assertNull(ext.getExtension("foo"));
+    ext.add("foo", extension);
+    assertSame(extension, ext.getExtension("foo"));
+    ext.add("foo", null);
+    assertNull(ext.getExtension("foo"));
+  }
+
+  public void testGetExtDelimiter() {
+    assertEquals(Extensions.DEFAULT_EXTENSION_FIELD_DELIMITER, this.ext
+        .getExtensionFieldDelimiter());
+    ext = new Extensions('?');
+    assertEquals('?', this.ext.getExtensionFieldDelimiter());
+  }
+
+  public void testEscapeExtension() {
+    assertEquals("abc\\:\\?\\{\\}\\[\\]\\\\\\(\\)\\+\\-\\!\\~", ext
+        .escapeExtensionField("abc:?{}[]\\()+-!~"));
+    try {
+      ext.escapeExtensionField(null);
+      fail("should throw NPE - escape string is null");
+    } catch (NullPointerException e) {
+      // 
+    }
+  }
+}

Propchange: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtensions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/ext/TestExtensions.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887532 - in /lucene/java/trunk/contrib: CHANGES.txt spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java</title>
<author><name>simonw@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091205121718.8105F23888DC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205121718-8105F23888DC@eris-apache-org%3e</id>
<updated>2009-12-05T12:17:18Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: simonw
Date: Sat Dec  5 12:17:17 2009
New Revision: 887532

URL: http://svn.apache.org/viewvc?rev=887532&amp;view=rev
Log:
LUCENE-2108: Enable safe concurrent spell-index modifications in Spellchecker

Modified:
    lucene/java/trunk/contrib/CHANGES.txt
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
    lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java

Modified: lucene/java/trunk/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/CHANGES.txt?rev=887532&amp;r1=887531&amp;r2=887532&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/CHANGES.txt Sat Dec  5 12:17:17 2009
@@ -17,6 +17,12 @@
 
 New features
 
+ * LUCENE-2108: Spellchecker now safely supports concurrent modifications to
+   the spell-index. Threads can safely obtain term suggestions while the spell-
+   index is rebuild, cleared or reset. Internal IndexSearcher instances remain
+   open until the last thread accessing them releases the reference.
+   (Simon Willnauer)
+
  * LUCENE-2067: Add a Czech light stemmer. CzechAnalyzer will now stem words
    when Version is set to 3.1 or higher.  (Robert Muir)
    

Modified: lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java?rev=887532&amp;r1=887531&amp;r2=887532&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
(original)
+++ lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
Sat Dec  5 12:17:17 2009
@@ -32,6 +32,7 @@
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
 
 /**
@@ -60,10 +61,14 @@
    * Field name for each word in the ngram index.
    */
   public static final String F_WORD = "word";
+  
+  private static final Term F_WORD_TERM = new Term(F_WORD);
 
   /**
    * the spell index
    */
+  // don't modify the directory directly - see #swapSearcher()
+  // TODO: why is this package private?
   Directory spellIndex;
 
   /**
@@ -72,7 +77,22 @@
   private float bStart = 2.0f;
   private float bEnd = 1.0f;
 
+  // don't use this searcher directly - see #swapSearcher()
   private IndexSearcher searcher;
+  
+  /*
+   * this locks all modifications to the current searcher. 
+   */
+  private final Object searcherLock = new Object();
+  
+  /*
+   * this lock synchronizes all possible modifications to the 
+   * current index directory. It should not be possible to try modifying
+   * the same index concurrently. Note: Do not acquire the searcher lock
+   * before acquiring this lock! 
+   */
+  private final Object modifyCurrentIndexLock = new Object();
+  private volatile boolean closed = false;
 
   // minimum score for hits generated by the spell checker query
   private float minScore = 0.5f;
@@ -82,15 +102,24 @@
   /**
    * Use the given directory as a spell checker index. The directory
    * is created if it doesn't exist yet.
+   * @param spellIndex the spell index directory
+   * @param sd the {@link StringDistance} measurement to use 
+   * @throws IOException if Spellchecker can not open the directory
+   */
+  public SpellChecker(Directory spellIndex, StringDistance sd) throws IOException {
+    setSpellIndex(spellIndex);
+    setStringDistance(sd);
+  }
+  /**
+   * Use the given directory as a spell checker index with a
+   * {@link LevensteinDistance} as the default {@link StringDistance}. The
+   * directory is created if it doesn't exist yet.
    * 
    * @param spellIndex
+   *          the spell index directory
    * @throws IOException
+   *           if spellchecker can not open the directory
    */
-  public SpellChecker(Directory spellIndex,StringDistance sd) throws IOException {
-    this.setSpellIndex(spellIndex);
-    this.setStringDistance(sd);
-  }
-
   public SpellChecker(Directory spellIndex) throws IOException {
     this(spellIndex, new LevensteinDistance());
   }
@@ -99,27 +128,41 @@
    * Use a different index as the spell checker index or re-open
    * the existing index if &lt;code&gt;spellIndex&lt;/code&gt; is the same value
    * as given in the constructor.
-   * 
-   * @param spellIndex
-   * @throws IOException
-   */
-  public void setSpellIndex(Directory spellIndex) throws IOException {
-    this.spellIndex = spellIndex;
-    if (!IndexReader.indexExists(spellIndex)) {
-        IndexWriter writer = new IndexWriter(spellIndex, null, true, IndexWriter.MaxFieldLength.UNLIMITED);
-        writer.close();
-    }
-    // close the old searcher, if there was one
-    if (searcher != null) {
-      searcher.close();
+   * @param spellIndexDir the spell directory to use
+   * @throws AlreadyClosedException if the Spellchecker is already closed
+   * @throws  IOException if spellchecker can not open the directory
+   */
+  // TODO: we should make this final as it is called in the constructor
+  public void setSpellIndex(Directory spellIndexDir) throws IOException {
+    // this could be the same directory as the current spellIndex
+    // modifications to the directory should be synchronized 
+    synchronized (modifyCurrentIndexLock) {
+      ensureOpen();
+      if (!IndexReader.indexExists(spellIndexDir)) {
+          IndexWriter writer = new IndexWriter(spellIndexDir, null, true,
+              IndexWriter.MaxFieldLength.UNLIMITED);
+          writer.close();
+      }
+      swapSearcher(spellIndexDir);
     }
-    searcher = new IndexSearcher(this.spellIndex, true);
   }
-  
+  /**
+   * Sets the {@link StringDistance} implementation for this
+   * {@link SpellChecker} instance.
+   * 
+   * @param sd the {@link StringDistance} implementation for this
+   * {@link SpellChecker} instance
+   */
   public void setStringDistance(StringDistance sd) {
     this.sd = sd;
   }
-
+  /**
+   * Returns the {@link StringDistance} instance used by this
+   * {@link SpellChecker} instance.
+   * 
+   * @return the {@link StringDistance} instance used by this
+   *         {@link SpellChecker} instance.
+   */
   public StringDistance getStringDistance() {
     return sd;
   }
@@ -144,7 +187,8 @@
    *
    * @param word the word you want a spell check done on
    * @param numSug the number of suggested words
-   * @throws IOException
+   * @throws IOException if the underlying index throws an {@link IOException}
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @return String[]
    */
   public String[] suggestSimilar(String word, int numSug) throws IOException {
@@ -169,98 +213,104 @@
    * words are restricted to the words present in this field.
    * @param morePopular return only the suggest words that are as frequent or more frequent
than the searched word
    * (only if restricted mode = (indexReader!=null and field!=null)
-   * @throws IOException
+   * @throws IOException if the underlying index throws an {@link IOException}
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @return String[] the sorted list of the suggest words with these 2 criteria:
    * first criteria: the edit distance, second criteria (only if restricted mode): the popularity
    * of the suggest words in the field of the user index
    */
   public String[] suggestSimilar(String word, int numSug, IndexReader ir,
       String field, boolean morePopular) throws IOException {
-
-    float min = this.minScore;
-    final int lengthWord = word.length();
-
-    final int freq = (ir != null &amp;&amp; field != null) ? ir.docFreq(new Term(field, word))
: 0;
-    final int goalFreq = (morePopular &amp;&amp; ir != null &amp;&amp; field != null) ? freq
: 0;
-    // if the word exists in the real index and we don't care for word frequency, return
the word itself
-    if (!morePopular &amp;&amp; freq &gt; 0) {
-      return new String[] { word };
-    }
-
-    BooleanQuery query = new BooleanQuery();
-    String[] grams;
-    String key;
-
-    for (int ng = getMin(lengthWord); ng &lt;= getMax(lengthWord); ng++) {
-
-      key = "gram" + ng; // form key
-
-      grams = formGrams(word, ng); // form word into ngrams (allow dups too)
-
-      if (grams.length == 0) {
-        continue; // hmm
-      }
-
-      if (bStart &gt; 0) { // should we boost prefixes?
-        add(query, "start" + ng, grams[0], bStart); // matches start of word
-
-      }
-      if (bEnd &gt; 0) { // should we boost suffixes
-        add(query, "end" + ng, grams[grams.length - 1], bEnd); // matches end of word
-
-      }
-      for (int i = 0; i &lt; grams.length; i++) {
-        add(query, key, grams[i]);
-      }
-    }
-
-    int maxHits = 10 * numSug;
-    
-//    System.out.println("Q: " + query);
-    ScoreDoc[] hits = searcher.search(query, null, maxHits).scoreDocs;
-//    System.out.println("HITS: " + hits.length());
-    SuggestWordQueue sugQueue = new SuggestWordQueue(numSug);
-
-    // go thru more than 'maxr' matches in case the distance filter triggers
-    int stop = Math.min(hits.length, maxHits);
-    SuggestWord sugWord = new SuggestWord();
-    for (int i = 0; i &lt; stop; i++) {
-
-      sugWord.string = searcher.doc(hits[i].doc).get(F_WORD); // get orig word
-
-      // don't suggest a word for itself, that would be silly
-      if (sugWord.string.equals(word)) {
-        continue;
+    // obtainSearcher calls ensureOpen
+    final IndexSearcher indexSearcher = obtainSearcher();
+    try{
+      float min = this.minScore;
+      final int lengthWord = word.length();
+  
+      final int freq = (ir != null &amp;&amp; field != null) ? ir.docFreq(new Term(field,
word)) : 0;
+      final int goalFreq = (morePopular &amp;&amp; ir != null &amp;&amp; field != null) ?
freq : 0;
+      // if the word exists in the real index and we don't care for word frequency, return
the word itself
+      if (!morePopular &amp;&amp; freq &gt; 0) {
+        return new String[] { word };
       }
-
-      // edit distance
-      sugWord.score = sd.getDistance(word,sugWord.string);
-      if (sugWord.score &lt; min) {
-        continue;
+  
+      BooleanQuery query = new BooleanQuery();
+      String[] grams;
+      String key;
+  
+      for (int ng = getMin(lengthWord); ng &lt;= getMax(lengthWord); ng++) {
+  
+        key = "gram" + ng; // form key
+  
+        grams = formGrams(word, ng); // form word into ngrams (allow dups too)
+  
+        if (grams.length == 0) {
+          continue; // hmm
+        }
+  
+        if (bStart &gt; 0) { // should we boost prefixes?
+          add(query, "start" + ng, grams[0], bStart); // matches start of word
+  
+        }
+        if (bEnd &gt; 0) { // should we boost suffixes
+          add(query, "end" + ng, grams[grams.length - 1], bEnd); // matches end of word
+  
+        }
+        for (int i = 0; i &lt; grams.length; i++) {
+          add(query, key, grams[i]);
+        }
       }
-
-      if (ir != null &amp;&amp; field != null) { // use the user index
-        sugWord.freq = ir.docFreq(new Term(field, sugWord.string)); // freq in the index
-        // don't suggest a word that is not present in the field
-        if ((morePopular &amp;&amp; goalFreq &gt; sugWord.freq) || sugWord.freq &lt; 1) {
+  
+      int maxHits = 10 * numSug;
+      
+  //    System.out.println("Q: " + query);
+      ScoreDoc[] hits = indexSearcher.search(query, null, maxHits).scoreDocs;
+  //    System.out.println("HITS: " + hits.length());
+      SuggestWordQueue sugQueue = new SuggestWordQueue(numSug);
+  
+      // go thru more than 'maxr' matches in case the distance filter triggers
+      int stop = Math.min(hits.length, maxHits);
+      SuggestWord sugWord = new SuggestWord();
+      for (int i = 0; i &lt; stop; i++) {
+  
+        sugWord.string = indexSearcher.doc(hits[i].doc).get(F_WORD); // get orig word
+  
+        // don't suggest a word for itself, that would be silly
+        if (sugWord.string.equals(word)) {
           continue;
         }
+  
+        // edit distance
+        sugWord.score = sd.getDistance(word,sugWord.string);
+        if (sugWord.score &lt; min) {
+          continue;
+        }
+  
+        if (ir != null &amp;&amp; field != null) { // use the user index
+          sugWord.freq = ir.docFreq(new Term(field, sugWord.string)); // freq in the index
+          // don't suggest a word that is not present in the field
+          if ((morePopular &amp;&amp; goalFreq &gt; sugWord.freq) || sugWord.freq &lt; 1)
{
+            continue;
+          }
+        }
+        sugQueue.insertWithOverflow(sugWord);
+        if (sugQueue.size() == numSug) {
+          // if queue full, maintain the minScore score
+          min = sugQueue.top().score;
+        }
+        sugWord = new SuggestWord();
       }
-      sugQueue.insertWithOverflow(sugWord);
-      if (sugQueue.size() == numSug) {
-        // if queue full, maintain the minScore score
-        min = sugQueue.top().score;
+  
+      // convert to array string
+      String[] list = new String[sugQueue.size()];
+      for (int i = sugQueue.size() - 1; i &gt;= 0; i--) {
+        list[i] = sugQueue.pop().string;
       }
-      sugWord = new SuggestWord();
-    }
-
-    // convert to array string
-    String[] list = new String[sugQueue.size()];
-    for (int i = sugQueue.size() - 1; i &gt;= 0; i--) {
-      list[i] = sugQueue.pop().string;
+  
+      return list;
+    } finally {
+      releaseSearcher(indexSearcher);
     }
-
-    return list;
   }
 
   /**
@@ -297,24 +347,33 @@
   /**
    * Removes all terms from the spell check index.
    * @throws IOException
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    */
   public void clearIndex() throws IOException {
-    IndexWriter writer = new IndexWriter(spellIndex, null, true, IndexWriter.MaxFieldLength.UNLIMITED);
-    writer.close();
-    
-    //close the old searcher
-    searcher.close();
-    searcher = new IndexSearcher(this.spellIndex, true);
+    synchronized (modifyCurrentIndexLock) {
+      ensureOpen();
+      final Directory dir = this.spellIndex;
+      final IndexWriter writer = new IndexWriter(dir, null, true, IndexWriter.MaxFieldLength.UNLIMITED);
+      writer.close();
+      swapSearcher(dir);
+    }
   }
 
   /**
    * Check whether the word exists in the index.
    * @param word
    * @throws IOException
-   * @return true iff the word exists in the index
+   * @throws AlreadyClosedException if the Spellchecker is already closed
+   * @return true if the word exists in the index
    */
   public boolean exist(String word) throws IOException {
-    return searcher.docFreq(new Term(F_WORD, word)) &gt; 0;
+    // obtainSearcher calls ensureOpen
+    final IndexSearcher indexSearcher = obtainSearcher();
+    try{
+      return indexSearcher.docFreq(F_WORD_TERM.createTerm(word)) &gt; 0;
+    } finally {
+      releaseSearcher(indexSearcher);
+    }
   }
 
   /**
@@ -322,37 +381,42 @@
    * @param dict Dictionary to index
    * @param mergeFactor mergeFactor to use when indexing
    * @param ramMB the max amount or memory in MB to use
+   * @throws AlreadyClosedException if the Spellchecker is already closed
    * @throws IOException
    */
   public void indexDictionary(Dictionary dict, int mergeFactor, int ramMB) throws IOException
{
-    IndexWriter writer = new IndexWriter(spellIndex, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
-    writer.setMergeFactor(mergeFactor);
-    writer.setRAMBufferSizeMB(ramMB);
-
-    Iterator&lt;String&gt; iter = dict.getWordsIterator();
-    while (iter.hasNext()) {
-      String word = iter.next();
-
-      int len = word.length();
-      if (len &lt; 3) {
-        continue; // too short we bail but "too long" is fine...
-      }
-
-      if (this.exist(word)) { // if the word already exist in the gramindex
-        continue;
-      }
-
-      // ok index the word
-      Document doc = createDocument(word, getMin(len), getMax(len));
-      writer.addDocument(doc);
-    }
-    // close writer
-    writer.optimize();
-    writer.close();
-    // also re-open the spell index to see our own changes when the next suggestion
-    // is fetched:
-    searcher.close();
-    searcher = new IndexSearcher(this.spellIndex, true);
+    synchronized (modifyCurrentIndexLock) {
+      ensureOpen();
+      final Directory dir = this.spellIndex;
+      final IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(),
+          IndexWriter.MaxFieldLength.UNLIMITED);
+      writer.setMergeFactor(mergeFactor);
+      writer.setRAMBufferSizeMB(ramMB);
+  
+      Iterator&lt;String&gt; iter = dict.getWordsIterator();
+      while (iter.hasNext()) {
+        String word = iter.next();
+  
+        int len = word.length();
+        if (len &lt; 3) {
+          continue; // too short we bail but "too long" is fine...
+        }
+  
+        if (this.exist(word)) { // if the word already exist in the gramindex
+          continue;
+        }
+  
+        // ok index the word
+        Document doc = createDocument(word, getMin(len), getMax(len));
+        writer.addDocument(doc);
+      }
+      // close writer
+      writer.optimize();
+      writer.close();
+      // also re-open the spell index to see our own changes when the next suggestion
+      // is fetched:
+      swapSearcher(dir);
+    }
   }
 
   /**
@@ -364,7 +428,7 @@
     indexDictionary(dict, 300, 10);
   }
 
-  private int getMin(int l) {
+  private static int getMin(int l) {
     if (l &gt; 5) {
       return 3;
     }
@@ -374,7 +438,7 @@
     return 1;
   }
 
-  private int getMax(int l) {
+  private static int getMax(int l) {
     if (l &gt; 5) {
       return 4;
     }
@@ -409,12 +473,84 @@
       }
     }
   }
-
+  
+  private IndexSearcher obtainSearcher() {
+    synchronized (searcherLock) {
+      ensureOpen();
+      searcher.getIndexReader().incRef();
+      return searcher;
+    }
+  }
+  
+  private void releaseSearcher(final IndexSearcher aSearcher) throws IOException{
+      // don't check if open - always decRef 
+      // don't decrement the private searcher - could have been swapped
+      aSearcher.getIndexReader().decRef();      
+  }
+  
+  private void ensureOpen() {
+    if (closed) {
+      throw new AlreadyClosedException("Spellchecker has been closed");
+    }
+  }
+  
   /**
-   * Close the IndexSearcher used by this SpellChecker.
+   * Close the IndexSearcher used by this SpellChecker
+   * @throws IOException if the close operation causes an {@link IOException}
+   * @throws AlreadyClosedException if the {@link SpellChecker} is already closed
    */
   public void close() throws IOException {
-    searcher.close();
-    searcher = null;
+    synchronized (searcherLock) {
+      ensureOpen();
+      closed = true;
+      if (searcher != null) {
+        searcher.close();
+      }
+      searcher = null;
+    }
+  }
+  
+  private void swapSearcher(final Directory dir) throws IOException {
+    /*
+     * opening a searcher is possibly very expensive.
+     * We rather close it again if the Spellchecker was closed during
+     * this operation than block access to the current searcher while opening.
+     */
+    final IndexSearcher indexSearcher = createSearcher(dir);
+    synchronized (searcherLock) {
+      if(closed){
+        indexSearcher.close();
+        throw new AlreadyClosedException("Spellchecker has been closed");
+      }
+      if (searcher != null) {
+        searcher.close();
+      }
+      // set the spellindex in the sync block - ensure consistency.
+      searcher = indexSearcher;
+      this.spellIndex = dir;
+    }
+  }
+  
+  /**
+   * Creates a new read-only IndexSearcher 
+   * @param dir the directory used to open the searcher
+   * @return a new read-only IndexSearcher
+   * @throws IOException f there is a low-level IO error
+   */
+  // for testing purposes
+  IndexSearcher createSearcher(final Directory dir) throws IOException{
+    return new IndexSearcher(dir, true);
   }
+  
+  /**
+   * Returns &lt;code&gt;true&lt;/code&gt; if and only if the {@link SpellChecker} is
+   * closed, otherwise &lt;code&gt;false&lt;/code&gt;.
+   * 
+   * @return &lt;code&gt;true&lt;/code&gt; if and only if the {@link SpellChecker} is
+   *         closed, otherwise &lt;code&gt;false&lt;/code&gt;.
+   */
+  boolean isClosed(){
+    return closed;
+  }
+  
 }

Modified: lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java?rev=887532&amp;r1=887531&amp;r2=887532&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
(original)
+++ lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
Sat Dec  5 12:17:17 2009
@@ -18,8 +18,13 @@
  */
 
 import java.io.IOException;
-
-import junit.framework.TestCase;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.apache.lucene.document.Document;
@@ -27,9 +32,12 @@
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.English;
+import org.apache.lucene.util.LuceneTestCase;
 
 
 /**
@@ -37,9 +45,11 @@
  *
  *
  */
-public class TestSpellChecker extends TestCase {
-  private SpellChecker spellChecker;
+public class TestSpellChecker extends LuceneTestCase {
+  private SpellCheckerMock spellChecker;
   private Directory userindex, spellindex;
+  private final Random random = newRandom();
+  private List&lt;IndexSearcher&gt; searchers;
 
   @Override
   protected void setUp() throws Exception {
@@ -56,10 +66,10 @@
       writer.addDocument(doc);
     }
     writer.close();
-
+    searchers = Collections.synchronizedList(new ArrayList&lt;IndexSearcher&gt;());
     // create the spellChecker
     spellindex = new RAMDirectory();
-    spellChecker = new SpellChecker(spellindex);
+    spellChecker = new SpellCheckerMock(spellindex);
   }
 
 
@@ -75,7 +85,9 @@
     int num_field2 = this.numdoc();
 
     assertEquals(num_field2, num_field1 + 1);
-
+    
+    assertLastSearcherOpen(4);
+    
     checkCommonSuggestions(r);
     checkLevenshteinSuggestions(r);
     
@@ -201,4 +213,186 @@
     return num;
   }
   
+  public void testClose() throws IOException {
+    IndexReader r = IndexReader.open(userindex, true);
+    spellChecker.clearIndex();
+    String field = "field1";
+    addwords(r, "field1");
+    int num_field1 = this.numdoc();
+    addwords(r, "field2");
+    int num_field2 = this.numdoc();
+    assertEquals(num_field2, num_field1 + 1);
+    checkCommonSuggestions(r);
+    assertLastSearcherOpen(4);
+    spellChecker.close();
+    assertSearchersClosed();
+    try {
+      spellChecker.close();
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    try {
+      checkCommonSuggestions(r);
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.clearIndex();
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.indexDictionary(new LuceneDictionary(r, field));
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    
+    try {
+      spellChecker.setSpellIndex(spellindex);
+      fail("spellchecker was already closed");
+    } catch (AlreadyClosedException e) {
+      // expected
+    }
+    assertEquals(4, searchers.size());
+    assertSearchersClosed();
+  }
+  
+  /*
+   * tests if the internally shared indexsearcher is correctly closed 
+   * when the spellchecker is concurrently accessed and closed.
+   */
+  public void testConcurrentAccess() throws IOException, InterruptedException {
+    assertEquals(1, searchers.size());
+    final IndexReader r = IndexReader.open(userindex, true);
+    spellChecker.clearIndex();
+    assertEquals(2, searchers.size());
+    addwords(r, "field1");
+    assertEquals(3, searchers.size());
+    int num_field1 = this.numdoc();
+    addwords(r, "field2");
+    assertEquals(4, searchers.size());
+    int num_field2 = this.numdoc();
+    assertEquals(num_field2, num_field1 + 1);
+    int numThreads = 5 + this.random.nextInt(5);
+    ExecutorService executor = Executors.newFixedThreadPool(numThreads);
+    SpellCheckWorker[] workers = new SpellCheckWorker[numThreads];
+    for (int i = 0; i &lt; numThreads; i++) {
+      SpellCheckWorker spellCheckWorker = new SpellCheckWorker(r);
+      executor.execute(spellCheckWorker);
+      workers[i] = spellCheckWorker;
+      
+    }
+    int iterations = 5 + random.nextInt(5);
+    for (int i = 0; i &lt; iterations; i++) {
+      Thread.sleep(100);
+      // concurrently reset the spell index
+      spellChecker.setSpellIndex(this.spellindex);
+      // for debug - prints the internal open searchers 
+      // showSearchersOpen();
+    }
+    
+    spellChecker.close();
+    executor.shutdown();
+    executor.awaitTermination(5, TimeUnit.SECONDS);
+    
+    
+    for (int i = 0; i &lt; workers.length; i++) {
+      assertFalse(workers[i].failed);
+      assertTrue(workers[i].terminated);
+    }
+    // 4 searchers more than iterations
+    // 1. at creation
+    // 2. clearIndex()
+    // 2. and 3. during addwords
+    assertEquals(iterations + 4, searchers.size());
+    assertSearchersClosed();
+    
+  }
+  
+  private void assertLastSearcherOpen(int numSearchers) {
+    assertEquals(numSearchers, searchers.size());
+    IndexSearcher[] searcherArray = searchers.toArray(new IndexSearcher[0]);
+    for (int i = 0; i &lt; searcherArray.length; i++) {
+      if (i == searcherArray.length - 1) {
+        assertTrue("expected last searcher open but was closed",
+            searcherArray[i].getIndexReader().getRefCount() &gt; 0);
+      } else {
+        assertFalse("expected closed searcher but was open - Index: " + i,
+            searcherArray[i].getIndexReader().getRefCount() &gt; 0);
+      }
+    }
+  }
+  
+  private void assertSearchersClosed() {
+    for (IndexSearcher searcher : searchers) {
+      assertEquals(0, searcher.getIndexReader().getRefCount());
+    }
+  }
+  
+  private void showSearchersOpen() {
+    int count = 0;
+    for (IndexSearcher searcher : searchers) {
+      if(searcher.getIndexReader().getRefCount() &gt; 0)
+        ++count;
+    } 
+    System.out.println(count);
+  }
+
+  
+  private class SpellCheckWorker implements Runnable {
+    private final IndexReader reader;
+    boolean terminated = false;
+    boolean failed = false;
+    
+    SpellCheckWorker(IndexReader reader) {
+      super();
+      this.reader = reader;
+    }
+    
+    public void run() {
+      try {
+        while (true) {
+          try {
+            checkCommonSuggestions(reader);
+          } catch (AlreadyClosedException e) {
+            
+            return;
+          } catch (Throwable e) {
+            
+            e.printStackTrace();
+            failed = true;
+            return;
+          }
+        }
+      } finally {
+        terminated = true;
+      }
+    }
+    
+  }
+  
+  class SpellCheckerMock extends SpellChecker {
+    public SpellCheckerMock(Directory spellIndex) throws IOException {
+      super(spellIndex);
+    }
+
+    public SpellCheckerMock(Directory spellIndex, StringDistance sd)
+        throws IOException {
+      super(spellIndex, sd);
+    }
+
+    @Override
+    IndexSearcher createSearcher(Directory dir) throws IOException {
+      IndexSearcher searcher = super.createSearcher(dir);
+      TestSpellChecker.this.searchers.add(searcher);
+      return searcher;
+    }
+  }
+  
 }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887525 - in /lucene/java/branches/flex_1458/src: java/org/apache/lucene/index/ java/org/apache/lucene/index/codecs/ java/org/apache/lucene/index/codecs/preflex/ java/org/apache/lucene/index/codecs/standard/ test/org/apache/lucene/ test/org...</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091205104749.0009E23888FE@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205104749-0009E23888FE@eris-apache-org%3e</id>
<updated>2009-12-05T10:47:48Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Sat Dec  5 10:47:47 2009
New Revision: 887525

URL: http://svn.apache.org/viewvc?rev=887525&amp;view=rev
Log:
LUCENE-2111: fix bug in 'flex API on non-flex index' layer

Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNames.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFields.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacySegmentMergeInfo.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyTerms.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/Terms.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/FieldsProducer.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/SimpleStandardTermsIndexReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexReader.java
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileReader.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileReader.java
Sat Dec  5 10:47:47 2009
@@ -32,7 +32,8 @@
  * This class implements a directory, but is limited to only read operations.
  * Directory methods that would normally modify data throw an exception.
  */
-class CompoundFileReader extends Directory {
+// nocmmit -- made public
+public class CompoundFileReader extends Directory {
 
     private int readBufferSize;
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java Sat
Dec  5 10:47:47 2009
@@ -1127,8 +1127,8 @@
     public FieldsEnumWithBase(IndexReader reader, int base) throws IOException {
       this.base = base;
       length = reader.maxDoc();
-      deletedDocs = reader.getDeletedDocs();
-      fields = reader.fields().iterator();
+      deletedDocs = reader.getDeletedDocs(); 
+     fields = reader.fields().iterator();
     }
   }
 
@@ -1265,6 +1265,7 @@
     }
   }
 
+  // Exposes flex API, merged from flex API of sub-segments
   private final static class MultiFieldsEnum extends FieldsEnum {
     private final FieldMergeQueue queue;
 
@@ -1329,6 +1330,7 @@
     }
   }
 
+  // Exposes flex API, merged from flex API of sub-segments
   private static final class MultiTermsEnum extends TermsEnum {
     
     private final TermMergeQueue queue;
@@ -1641,8 +1643,9 @@
     }
   }
 
-
-  // Legacy API
+  // @deprecated This is pre-flex API
+  // Exposes pre-flex API by doing on-the-fly merging
+  // pre-flex API to each segment
   static class MultiTermEnum extends TermEnum {
     IndexReader topReader; // used for matching TermEnum to TermDocs
     private LegacySegmentMergeQueue queue;
@@ -1729,7 +1732,9 @@
     }
   }
 
-  // Legacy API
+  // @deprecated This is pre-flex API
+  // Exposes pre-flex API by doing on-the-fly merging
+  // pre-flex API to each segment
   static class MultiTermDocs implements TermDocs {
     IndexReader topReader;  // used for matching TermEnum to TermDocs
     protected IndexReader[] readers;
@@ -1881,7 +1886,9 @@
     }
   }
 
-  // Legacy API
+  // @deprecated This is pre-flex API
+  // Exposes pre-flex API by doing on-the-fly merging
+  // pre-flex API to each segment
   static class MultiTermPositions extends MultiTermDocs implements TermPositions {
     public MultiTermPositions(IndexReader topReader, IndexReader[] r, int[] s) {
       super(topReader,r,s);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNames.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNames.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNames.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNames.java Sat
Dec  5 10:47:47 2009
@@ -64,7 +64,8 @@
   static final String VECTORS_INDEX_EXTENSION = "tvx";
 
   /** Extension of compound file */
-  static final String COMPOUND_FILE_EXTENSION = "cfs";
+  // nocommit made public
+  public static final String COMPOUND_FILE_EXTENSION = "cfs";
 
   /** Extension of compound file for doc store files*/
   static final String COMPOUND_FILE_STORE_EXTENSION = "cfx";

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java Sat Dec
 5 10:47:47 2009
@@ -621,7 +621,7 @@
           // index (eg because it's doing deletes, or an NRT
           // reader is being opened) we ask the reader to
           // load its terms index.
-          sr.loadTermsIndex();
+          sr.loadTermsIndex(termsIndexDivisor);
         }
       }
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFields.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFields.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFields.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFields.java Sat
Dec  5 10:47:47 2009
@@ -40,8 +40,4 @@
     // nocommit
     return new LegacyTerms(r, field);
   }
-
-  public void close() throws IOException {
-    // nocommit
-  }
-}
\ No newline at end of file
+}

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
Sat Dec  5 10:47:47 2009
@@ -20,9 +20,9 @@
 import java.io.IOException;
 import org.apache.lucene.util.Bits;
 
-/** Implements new API (FieldsEnum/TermsEnum) on top of old
- *  API.  Used only for IndexReader impls outside Lucene's
- *  core. */
+/** Implements flex API (FieldsEnum/TermsEnum) on top of
+ *  pre-flex API.  Used only for IndexReader impls outside
+ *  Lucene's core. */
 class LegacyFieldsEnum extends FieldsEnum {
   private final IndexReader r;
   private TermEnum terms;
@@ -38,14 +38,6 @@
     terms = r.terms(t);
   }
 
-  /*
-  public boolean seek(String field) throws IOException {
-    this.field = field;
-    doSeek(new Term(field, ""));
-    return terms.term() != null &amp;&amp; terms.term().field.equals(field);
-  }
-  */
-
   @Override
   public String next() throws IOException {
 
@@ -68,11 +60,6 @@
     return new LegacyTermsEnum(r, field);
   }
 
-  public void close() throws IOException {
-    terms.close();
-  }
-
-  // Emulates flex on top of legacy API
   static class LegacyTermsEnum extends TermsEnum {
     private final IndexReader r;
     private final String field;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacySegmentMergeInfo.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacySegmentMergeInfo.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacySegmentMergeInfo.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacySegmentMergeInfo.java
Sat Dec  5 10:47:47 2009
@@ -19,6 +19,7 @@
 
 import java.io.IOException;
 
+// @deprecated This is pre-flex API
 final class LegacySegmentMergeInfo {
   Term term;
   int base;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyTerms.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyTerms.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyTerms.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyTerms.java Sat Dec
 5 10:47:47 2009
@@ -20,9 +20,9 @@
 
 import java.io.IOException;
 
-/** Implements new API (FieldsEnum/TermsEnum) on top of old
- *  API.  Used only for IndexReader impls outside Lucene's
- *  core. */
+/** Implements flex API (FieldsEnum/TermsEnum) on top of
+ *  pre-flex API.  Used only for IndexReader impls outside
+ *  Lucene's core. */
 class LegacyTerms extends Terms {
 
   private final IndexReader r;
@@ -38,9 +38,6 @@
     return new LegacyFieldsEnum.LegacyTermsEnum(r, field);
   }
 
-  public void close() {
-  }
-
   @Override
   public TermRef.Comparator getTermComparator() {
     // Pre-flex indexes always sorted in UTF16 order

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java Sat
Dec  5 10:47:47 2009
@@ -1136,8 +1136,8 @@
   // sharing a segment that's still being merged.  This
   // method is not thread safe, and relies on the
   // synchronization in IndexWriter
-  void loadTermsIndex() throws IOException {
-    core.fields.loadTermsIndex();
+  void loadTermsIndex(int indexDivisor) throws IOException {
+    core.fields.loadTermsIndex(indexDivisor);
   }
 
   // for testing only

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/Terms.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/Terms.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/Terms.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/Terms.java Sat Dec  5
10:47:47 2009
@@ -26,7 +26,6 @@
 
 public abstract class Terms {
 
-  // nocommit -- char[] or byte[] version?
   /** Returns an iterator that will step through all terms */
   public abstract TermsEnum iterator() throws IOException;
   

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/FieldsProducer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/FieldsProducer.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/FieldsProducer.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/FieldsProducer.java
Sat Dec  5 10:47:47 2009
@@ -30,5 +30,5 @@
  */
 public abstract class FieldsProducer extends Fields {
   public abstract void close() throws IOException;
-  public abstract void loadTermsIndex() throws IOException;
+  public abstract void loadTermsIndex(int indexDivisor) throws IOException;
 }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
Sat Dec  5 10:47:47 2009
@@ -33,27 +33,43 @@
 import org.apache.lucene.index.TermRef;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.index.CompoundFileReader;
 import org.apache.lucene.index.codecs.Codec;
 import org.apache.lucene.index.codecs.FieldsProducer;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.util.Bits;
 
+/** Exposes flex API on a pre-flex index, as a codec. */
 public class PreFlexFields extends FieldsProducer {
 
   // nocommit -- needed public by SegmentReader
-  public final TermInfosReader tis;
+  public TermInfosReader tis;
+  public final TermInfosReader tisNoIndex;
 
   // nocomit -- needed public by SR
   public final IndexInput freqStream;
   // nocomit -- needed public by SR
   public final IndexInput proxStream;
   final private FieldInfos fieldInfos;
+  private final SegmentInfo si;
   final TreeMap&lt;String,FieldInfo&gt; fields = new TreeMap&lt;String,FieldInfo&gt;();
+  private final Directory dir;
+  private final int readBufferSize;
+  private Directory cfsReader;
 
   PreFlexFields(Directory dir, FieldInfos fieldInfos, SegmentInfo info, int readBufferSize,
int indexDivisor)
     throws IOException {
-    tis = new TermInfosReader(dir, info.name, fieldInfos, readBufferSize, indexDivisor);
   
+
+    si = info;
+    TermInfosReader r = new TermInfosReader(dir, info.name, fieldInfos, readBufferSize, indexDivisor);
   
+    if (indexDivisor == -1) {
+      tisNoIndex = r;
+    } else {
+      tisNoIndex = null;
+      tis = r;
+    }
+    this.readBufferSize = readBufferSize;
     this.fieldInfos = fieldInfos;
 
     // make sure that all index files have been read or are kept open
@@ -76,6 +92,8 @@
     } else {
       proxStream = null;
     }
+
+    this.dir = dir;
   }
 
   static void files(Directory dir, SegmentInfo info, Collection&lt;String&gt; files) throws
IOException {
@@ -111,20 +129,58 @@
     }
   }
 
+  synchronized private TermInfosReader getTermsDict() {
+    if (tis != null) {
+      return tis;
+    } else {
+      return tisNoIndex;
+    }
+  }
+
   @Override
-  public void loadTermsIndex() throws IOException {
-    // nocommit -- todo
+  synchronized public void loadTermsIndex(int indexDivisor) throws IOException {
+    if (tis == null) {
+      Directory dir0;
+      if (si.getUseCompoundFile()) {
+        // In some cases, we were originally opened when CFS
+        // was not used, but then we are asked to open the
+        // terms reader with index, the segment has switched
+        // to CFS
+
+        // nocommit -- not clean that I open my own CFS
+        // reader here; caller should pass it in?
+        if (!(dir instanceof CompoundFileReader)) {
+          dir0 = cfsReader = new CompoundFileReader(dir, si.name + "." + IndexFileNames.COMPOUND_FILE_EXTENSION,
readBufferSize);
+        } else {
+          dir0 = dir;
+        }
+        dir0 = cfsReader;
+      } else {
+        dir0 = dir;
+      }
+
+      tis = new TermInfosReader(dir0, si.name, fieldInfos, readBufferSize, indexDivisor);
+    }
   }
 
   @Override
   public void close() throws IOException {
-    tis.close();
+    if (tis != null) {
+      tis.close();
+    }
+    if (tisNoIndex != null) {
+      tisNoIndex.close();
+    }
+    if (cfsReader != null) {
+      cfsReader.close();
+    }
   }
 
   private class Fields extends FieldsEnum {
     Iterator&lt;FieldInfo&gt; it;
     FieldInfo current;
-    private PreTermsEnum lastTermsEnum;
+    private SegmentTermEnum lastTermEnum;
+    private int fieldCount;
 
     public Fields() {
       it = fields.values().iterator();
@@ -133,6 +189,7 @@
     @Override
     public String next() {
       if (it.hasNext()) {
+        fieldCount++;
         current = it.next();
         return current.name;
       } else {
@@ -143,13 +200,17 @@
     @Override
     public TermsEnum terms() throws IOException {
       final PreTermsEnum terms;
-      if (lastTermsEnum != null) {
-        // Carry over SegmentTermsEnum
-        terms = new PreTermsEnum(current, lastTermsEnum.terms);
+      if (lastTermEnum != null) {
+        // Re-use SegmentTermEnum to avoid seeking for
+        // linear scan (done by merging)
+        terms = new PreTermsEnum(current, lastTermEnum);
       } else {
-        terms = new PreTermsEnum(current);
+        // If fieldCount is 1 then the terms enum can simply
+        // start at the start of the index (need not seek to
+        // the current field):
+        terms = new PreTermsEnum(current, fieldCount != 1);
+        lastTermEnum = terms.terms;
       }
-      lastTermsEnum = terms;
       return terms;
     }
   }
@@ -161,9 +222,9 @@
     }
 
     @Override
-    public TermsEnum iterator() {
+    public TermsEnum iterator() throws IOException {
       //System.out.println("pff.init create no context");
-      return new PreTermsEnum(fieldInfo);
+      return new PreTermsEnum(fieldInfo, true);
     }
 
     @Override
@@ -176,18 +237,36 @@
   private class PreTermsEnum extends TermsEnum {
     private SegmentTermEnum terms;
     private final FieldInfo fieldInfo;
-    private PreDocsEnum docsEnum;
+    private PreDocsEnum docsEnum; // nocommit -- unused
     private boolean skipNext;
     private TermRef current;
+    private final TermRef scratchTermRef = new TermRef();
 
-    PreTermsEnum(FieldInfo fieldInfo) {
+    // Pass needsSeek=false if the field is the very first
+    // field in the index -- this is used for linear scan of
+    // the index, eg when merging segments:
+    PreTermsEnum(FieldInfo fieldInfo, boolean needsSeek) throws IOException {
       this.fieldInfo = fieldInfo;
-      terms = tis.terms();
+      if (!needsSeek) {
+        terms = getTermsDict().terms();
+      } else {
+        terms = getTermsDict().terms(new Term(fieldInfo.name, ""));
+        skipNext = true;
+      }
     }
 
-    PreTermsEnum(FieldInfo fieldInfo, SegmentTermEnum terms) {
+    PreTermsEnum(FieldInfo fieldInfo, SegmentTermEnum terms) throws IOException {
       this.fieldInfo = fieldInfo;
-      this.terms = terms;
+      if (terms.term() == null || terms.term().field() != fieldInfo.name) {
+        terms = getTermsDict().terms(new Term(fieldInfo.name, ""));
+      } else {
+        // Carefully avoid seeking in the linear-scan case,
+        // because segment doesn't load/need the terms dict
+        // index during merging.  If the terms is already on
+        // our field, it must be because it had seeked to
+        // exhaustion on the last field
+        this.terms = terms;
+      }
       skipNext = true;
       if (Codec.DEBUG) {
         System.out.println("pff.terms.init field=" + fieldInfo.name);
@@ -215,15 +294,13 @@
       if (Codec.DEBUG) {
         System.out.println("pff.seek term=" + term);
       }
-      terms = tis.terms(new Term(fieldInfo.name, term.toString()));
+      terms = getTermsDict().terms(new Term(fieldInfo.name, term.toString()));
       final Term t = terms.term();
-      //System.out.println("  got to term=" + t  + " field eq?=" + (t.field() == fieldInfo.name)
+ " term eq?=" +
-      //term.equals(new TermRef(t.text())));
 
-      // nocommit -- reuse TermRef instance
       final TermRef tr;
       if (t != null) {
-        tr = new TermRef(t.text());
+        tr = scratchTermRef;
+        scratchTermRef.copy(t.text());
       } else {
         tr = null;
       }
@@ -245,8 +322,8 @@
       if (skipNext) {
         // nocommit -- is there a cleaner way?
         skipNext = false;
-        // nocommit -- reuse TermRef
-        current = new TermRef(terms.term().text());
+        scratchTermRef.copy(terms.term().text());
+        current = scratchTermRef;
         return current;
       }
       if (terms.next()) {
@@ -255,11 +332,11 @@
           System.out.println("pff.next term=" + t);
         }
         if (t.field() == fieldInfo.name) {
-          // nocommit -- reuse TermRef instance
           if (Codec.DEBUG) {
             System.out.println("  ok");
           }
-          current = new TermRef(t.text());
+          scratchTermRef.copy(t.text());
+          current = scratchTermRef;
           return current;
         } else {
           // Crossed into new field
@@ -298,16 +375,16 @@
     final private PrePositionsEnum prePos;
 
     PreDocsEnum(Bits skipDocs, Term t) throws IOException {
-      current = docs = new SegmentTermDocs(freqStream, skipDocs, tis, fieldInfos);
-      pos = new SegmentTermPositions(freqStream, proxStream, skipDocs, tis, fieldInfos);
+      current = docs = new SegmentTermDocs(freqStream, skipDocs, getTermsDict(), fieldInfos);
+      pos = new SegmentTermPositions(freqStream, proxStream, skipDocs, getTermsDict(), fieldInfos);
       prePos = new PrePositionsEnum(pos);
       docs.seek(t);
       pos.seek(t);
     }
 
     PreDocsEnum(Bits skipDocs, SegmentTermEnum te) throws IOException {
-      current = docs = new SegmentTermDocs(freqStream, skipDocs, tis, fieldInfos);
-      pos = new SegmentTermPositions(freqStream, proxStream, skipDocs, tis, fieldInfos);
+      current = docs = new SegmentTermDocs(freqStream, skipDocs, getTermsDict(), fieldInfos);
+      pos = new SegmentTermPositions(freqStream, proxStream, skipDocs, getTermsDict(), fieldInfos);
       prePos = new PrePositionsEnum(pos);
       docs.seek(te);
       pos.seek(te);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/SimpleStandardTermsIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/SimpleStandardTermsIndexReader.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/SimpleStandardTermsIndexReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/SimpleStandardTermsIndexReader.java
Sat Dec  5 10:47:47 2009
@@ -59,7 +59,7 @@
 public class SimpleStandardTermsIndexReader extends StandardTermsIndexReader {
 
   final private int totalIndexInterval;
-  final private int indexDivisor;
+  private int indexDivisor;
   final private int indexInterval;
 
   final private IndexInput in;
@@ -471,10 +471,11 @@
   }
 
   @Override
-  public void loadTermsIndex() throws IOException {
-
+  public void loadTermsIndex(int indexDivisor) throws IOException {
     if (!indexLoaded) {
 
+      this.indexDivisor = indexDivisor;
+
       // mxx
       if (Codec.DEBUG) {
         System.out.println(Thread.currentThread().getName() + ": sstir: load coreIndex on
demand");

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
Sat Dec  5 10:47:47 2009
@@ -296,7 +296,7 @@
 
         while(true) {
           if (count == docFreq) {
-            return NO_MORE_DOCS;
+            return doc = NO_MORE_DOCS;
           }
 
           count++;
@@ -499,8 +499,7 @@
         
         // Now, linear scan for the rest:
         do {
-          if (nextDoc() == NO_MORE_DOCS)
-            return NO_MORE_DOCS;
+          nextDoc();
         } while (target &gt; doc);
 
         return doc;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
Sat Dec  5 10:47:47 2009
@@ -127,8 +127,11 @@
   }
 
   @Override
-  public void loadTermsIndex() throws IOException {
-    indexReader.loadTermsIndex();
+  public void loadTermsIndex(int indexDivisor) throws IOException {
+    // nocommit -- must handle case where segment has become
+    // a CFS since we originall opened; maybe Directory
+    // should be passed in?
+    indexReader.loadTermsIndex(indexDivisor);
   }
 
   @Override

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexReader.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsIndexReader.java
Sat Dec  5 10:47:47 2009
@@ -63,7 +63,7 @@
 
   public abstract FieldReader getField(FieldInfo fieldInfo);
 
-  public abstract void loadTermsIndex() throws IOException;
+  public abstract void loadTermsIndex(int indexDivisor) throws IOException;
 
   public abstract void close() throws IOException;
 

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java Sat
Dec  5 10:47:47 2009
@@ -88,7 +88,7 @@
       }
 
       @Override
-      public void loadTermsIndex() {
+      public void loadTermsIndex(int indexDivisor) {
       }
     } 
 
@@ -586,11 +586,11 @@
       }
 
       @Override
-      public void loadTermsIndex() throws IOException {
+      public void loadTermsIndex(int indexDivisor) throws IOException {
         Iterator&lt;FieldsProducer&gt; it = codecs.values().iterator();
         while(it.hasNext()) {
           // nocommit -- catch exc and keep closing the rest?
-          it.next().loadTermsIndex();
+          it.next().loadTermsIndex(indexDivisor);
         }
       }
     }

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=887525&amp;r1=887524&amp;r2=887525&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
(original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
Sat Dec  5 10:47:47 2009
@@ -645,4 +645,59 @@
   /* This was used in 2.9 to generate an index with compressed field:
   static final int BINARY_COMPRESSED_LENGTH = CompressionTools.compress(BINARY_TO_COMPRESS).length;
   */
+
+  private int countDocs(DocsEnum docs) throws IOException {
+    int count = 0;
+    while((docs.nextDoc()) != DocsEnum.NO_MORE_DOCS) {
+      count ++;
+    }
+    return count;
+  }
+
+  // flex: test basics of TermsEnum api on non-flex index
+  public void testNextIntoWrongField() throws Exception {
+    for(int i=0;i&lt;oldNames.length;i++) {
+      String dirName = "src/test/org/apache/lucene/index/index." + oldNames[i];
+      unzip(dirName, oldNames[i]);
+      String fullPath = fullDir(oldNames[i]);
+      Directory dir = FSDirectory.open(new File(fullPath));
+      IndexReader r = IndexReader.open(dir);
+      TermsEnum terms = r.fields().terms("content").iterator();
+      TermRef t = terms.next();
+      assertNotNull(t);
+
+      // content field only has term aaa:
+      assertEquals("aaa", t.toString());
+      assertNull(terms.next());
+
+      TermRef aaaTerm = new TermRef("aaa");
+
+      // should be found exactly
+      assertEquals(TermsEnum.SeekStatus.FOUND,
+                   terms.seek(aaaTerm));
+      assertEquals(35, countDocs(terms.docs(null)));
+      assertNull(terms.next());
+
+      // should hit end of field
+      assertEquals(TermsEnum.SeekStatus.END,
+                   terms.seek(new TermRef("bbb")));
+      assertNull(terms.next());
+
+      // should seek to aaa
+      assertEquals(TermsEnum.SeekStatus.NOT_FOUND,
+                   terms.seek(new TermRef("a")));
+      assertTrue(terms.term().termEquals(aaaTerm));
+      assertEquals(35, countDocs(terms.docs(null)));
+      assertNull(terms.next());
+
+      assertEquals(TermsEnum.SeekStatus.FOUND,
+                   terms.seek(aaaTerm));
+      assertEquals(35, countDocs(terms.docs(null)));
+      assertNull(terms.next());
+
+      r.close();
+      dir.close();
+      rmDir(oldNames[i]);
+    }
+  }
 }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887524 - in /lucene/java/trunk: contrib/ contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/ contrib/highlighter/src/test/org/apache/lucene/search/highlight/ contrib/instantiated/src/java/org/apache/lucene/store/instantiated/ co...</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091205094356.CA92323888E9@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205094356-CA92323888E9@eris-apache-org%3e</id>
<updated>2009-12-05T09:43:56Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Sat Dec  5 09:43:54 2009
New Revision: 887524

URL: http://svn.apache.org/viewvc?rev=887524&amp;view=rev
Log:
LUCENE-2115: cutover contrib tests to use generics

Modified:
    lucene/java/trunk/contrib/CHANGES.txt
    lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
    lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java
    lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
    lucene/java/trunk/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexReader.java
    lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
    lucene/java/trunk/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
    lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
    lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java
    lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
    lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java
    lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java
    lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
    lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
    lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
    lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
    lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
    lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java

Modified: lucene/java/trunk/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/CHANGES.txt?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/CHANGES.txt Sat Dec  5 09:43:54 2009
@@ -22,6 +22,11 @@
    
  * LUCENE-2062: Add a Bulgarian analyzer.  (Robert Muir, Simon Willnauer)
 
+Test Cases
+
+ * LUCENE-2115: Cutover contrib tests to use Java5 generics.  (Kay Kay
+   via Mike McCandless)
+
 ======================= Release 3.0.0 2009-11-25 =======================
 
 Changes in backwards compatibility policy

Modified: lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
Sat Dec  5 09:43:54 2009
@@ -444,12 +444,11 @@
     // Run algo
     Benchmark benchmark = execBenchmark(algLines1);
 
-    List stats = benchmark.getRunData().getPoints().taskStats();
+    List&lt;TaskStats&gt; stats = benchmark.getRunData().getPoints().taskStats();
 
     // Count how many tokens all ReadTokens saw
     int totalTokenCount1 = 0;
-    for (Iterator it = stats.iterator(); it.hasNext();) {
-      TaskStats stat = (TaskStats) it.next();
+    for (final TaskStats stat : stats) {
       if (stat.getTask().getName().equals("ReadTokens")) {
         totalTokenCount1 += stat.getCount();
       }
@@ -809,8 +808,7 @@
     // 3. test counters
     int n = disable ? 0 : 1;
     int nChecked = 0;
-    for (Iterator ts = benchmark.getRunData().getPoints().taskStats().iterator(); ts.hasNext();)
{
-      TaskStats stats = (TaskStats) ts.next();
+    for (final TaskStats stats : benchmark.getRunData().getPoints().taskStats()) {
       String taskName = stats.getTask().getName();
       if (taskName.equals("Rounds")) {
         assertEquals("Wrong total count!",20+2*n,stats.getCount());

Modified: lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java
Sat Dec  5 09:43:54 2009
@@ -49,10 +49,9 @@
     String parsedTasks = "[ "+taskStr+" ] : 1000";
     Benchmark benchmark = new Benchmark(new StringReader(propPart+parsedTasks));
     Algorithm alg = benchmark.getAlgorithm();
-    ArrayList algTasks = alg.extractTasks();
+    ArrayList&lt;PerfTask&gt; algTasks = alg.extractTasks();
     boolean foundAdd = false;
-    for (Iterator iter = algTasks.iterator(); iter.hasNext();) {
-       PerfTask task = (PerfTask) iter.next();
+    for (final PerfTask task : algTasks) {
        if (task.toString().indexOf(taskStr)&gt;=0) {
           foundAdd = true;
        }
@@ -70,10 +69,9 @@
     String parsedTasks = "{ "+taskStr+" } : 1000";
     Benchmark benchmark = new Benchmark(new StringReader(propPart+parsedTasks));
     Algorithm alg = benchmark.getAlgorithm();
-    ArrayList algTasks = alg.extractTasks();
+    ArrayList&lt;PerfTask&gt; algTasks = alg.extractTasks();
     boolean foundAdd = false;
-    for (Iterator iter = algTasks.iterator(); iter.hasNext();) {
-       PerfTask task = (PerfTask) iter.next();
+    for (final PerfTask task : algTasks) {
        if (task.toString().indexOf(taskStr)&gt;=0) {
           foundAdd = true;
        }

Modified: lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
(original)
+++ lucene/java/trunk/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
Sat Dec  5 09:43:54 2009
@@ -978,12 +978,12 @@
         WeightedSpanTerm[] wTerms = new WeightedSpanTerm[2];
         wTerms[0] = new WeightedSpanTerm(10f, "hello");
 
-        List positionSpans = new ArrayList();
+        List&lt;PositionSpan&gt; positionSpans = new ArrayList&lt;PositionSpan&gt;();
         positionSpans.add(new PositionSpan(0, 0));
         wTerms[0].addPositionSpans(positionSpans);
 
         wTerms[1] = new WeightedSpanTerm(1f, "kennedy");
-        positionSpans = new ArrayList();
+        positionSpans = new ArrayList&lt;PositionSpan&gt;();
         positionSpans.add(new PositionSpan(14, 14));
         wTerms[1].addPositionSpans(positionSpans);
 
@@ -1021,7 +1021,7 @@
 
       @Override
       public void run() throws Exception {
-        HashMap synonyms = new HashMap();
+        HashMap&lt;String,String&gt; synonyms = new HashMap&lt;String,String&gt;();
         synonyms.put("football", "soccer,footie");
         Analyzer analyzer = new SynonymAnalyzer(synonyms);
         String srchkey = "football";
@@ -1139,7 +1139,7 @@
       @Override
       public void run() throws Exception {
         String goodWord = "goodtoken";
-        Set stopWords = new HashSet(1);
+        Set&lt;String&gt; stopWords = new HashSet&lt;String&gt;(1);
         stopWords.add("stoppedtoken");
 
         TermQuery query = new TermQuery(new Term("data", goodWord));
@@ -1184,7 +1184,7 @@
     TestHighlightRunner helper = new TestHighlightRunner() {
       @Override
       public void run() throws Exception {
-        Set stopWords = new HashSet();
+        Set&lt;String&gt; stopWords = new HashSet&lt;String&gt;();
         stopWords.add("in");
         stopWords.add("it");
         TermQuery query = new TermQuery(new Term("text", "searchterm"));
@@ -1425,8 +1425,8 @@
   protected TokenStream getTS2() {
     // String s = "Hi-Speed10 foo";
     return new TokenStream() {
-      Iterator iter;
-      List lst;
+      Iterator&lt;Token&gt; iter;
+      List&lt;Token&gt; lst;
       private TermAttribute termAtt;
       private PositionIncrementAttribute posIncrAtt;
       private OffsetAttribute offsetAtt;
@@ -1434,7 +1434,7 @@
         termAtt = addAttribute(TermAttribute.class);
         posIncrAtt = addAttribute(PositionIncrementAttribute.class);
         offsetAtt = addAttribute(OffsetAttribute.class);
-        lst = new ArrayList();
+        lst = new ArrayList&lt;Token&gt;();
         Token t;
         t = createToken("hi", 0, 2);
         t.setPositionIncrement(1);
@@ -1457,7 +1457,7 @@
       @Override
       public boolean incrementToken() throws IOException {
         if(iter.hasNext()) {
-          Token token = (Token) iter.next();
+          Token token =  iter.next();
           termAtt.setTermBuffer(token.term());
           posIncrAtt.setPositionIncrement(token.getPositionIncrement());
           offsetAtt.setOffset(token.startOffset(), token.endOffset());
@@ -1473,8 +1473,8 @@
   protected TokenStream getTS2a() {
     // String s = "Hi-Speed10 foo";
     return new TokenStream() {
-      Iterator iter;
-      List lst;
+      Iterator&lt;Token&gt; iter;
+      List&lt;Token&gt; lst;
       private TermAttribute termAtt;
       private PositionIncrementAttribute posIncrAtt;
       private OffsetAttribute offsetAtt;
@@ -1482,7 +1482,7 @@
         termAtt = addAttribute(TermAttribute.class);
         posIncrAtt = addAttribute(PositionIncrementAttribute.class);
         offsetAtt = addAttribute(OffsetAttribute.class);
-        lst = new ArrayList();
+        lst = new ArrayList&lt;Token&gt;();
         Token t;
         t = createToken("hispeed", 0, 8);
         t.setPositionIncrement(1);
@@ -1505,7 +1505,7 @@
       @Override
       public boolean incrementToken() throws IOException {
         if(iter.hasNext()) {
-          Token token = (Token) iter.next();
+          Token token = iter.next();
           termAtt.setTermBuffer(token.term());
           posIncrAtt.setPositionIncrement(token.getPositionIncrement());
           offsetAtt.setOffset(token.startOffset(), token.endOffset());
@@ -1785,9 +1785,9 @@
 // ===================================================================
 
 class SynonymAnalyzer extends Analyzer {
-  private Map synonyms;
+  private Map&lt;String,String&gt; synonyms;
 
-  public SynonymAnalyzer(Map synonyms) {
+  public SynonymAnalyzer(Map&lt;String,String&gt; synonyms) {
     this.synonyms = synonyms;
   }
 
@@ -1815,7 +1815,7 @@
   private TokenStream realStream;
   private Token currentRealToken = null;
   private org.apache.lucene.analysis.Token cRealToken = null;
-  private Map synonyms;
+  private Map&lt;String,String&gt; synonyms;
   StringTokenizer st = null;
   private TermAttribute realTermAtt;
   private PositionIncrementAttribute realPosIncrAtt;
@@ -1824,7 +1824,7 @@
   private PositionIncrementAttribute posIncrAtt;
   private OffsetAttribute offsetAtt;
 
-  public SynonymTokenizer(TokenStream realStream, Map synonyms) {
+  public SynonymTokenizer(TokenStream realStream, Map&lt;String,String&gt; synonyms) {
     this.realStream = realStream;
     this.synonyms = synonyms;
     realTermAtt = realStream.addAttribute(TermAttribute.class);
@@ -1849,7 +1849,7 @@
       offsetAtt.setOffset(realOffsetAtt.startOffset(), realOffsetAtt.endOffset());
       posIncrAtt.setPositionIncrement(realPosIncrAtt.getPositionIncrement());
 
-      String expansions = (String) synonyms.get(realTermAtt.term());
+      String expansions =  synonyms.get(realTermAtt.term());
       if (expansions == null) {
         return true;
       }

Modified: lucene/java/trunk/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexReader.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexReader.java
(original)
+++ lucene/java/trunk/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexReader.java
Sat Dec  5 09:43:54 2009
@@ -195,7 +195,7 @@
   }
 
   @Override
-  public Collection getFieldNames(FieldOption fieldOption) {
+  public Collection&lt;String&gt; getFieldNames(FieldOption fieldOption) {
     Set&lt;String&gt; fieldSet = new HashSet&lt;String&gt;();
     for (FieldSetting fi : index.getFieldSettings().values()) {
       if (fieldOption == IndexReader.FieldOption.ALL) {

Modified: lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
(original)
+++ lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
Sat Dec  5 09:43:54 2009
@@ -197,8 +197,8 @@
    */
   private static final Comparator termComparator = new Comparator() {
     public int compare(Object o1, Object o2) {
-      if (o1 instanceof Map.Entry) o1 = ((Map.Entry) o1).getKey();
-      if (o2 instanceof Map.Entry) o2 = ((Map.Entry) o2).getKey();
+      if (o1 instanceof Map.Entry&lt;?,?&gt;) o1 = ((Map.Entry&lt;?,?&gt;) o1).getKey();
+      if (o2 instanceof Map.Entry&lt;?,?&gt;) o2 = ((Map.Entry&lt;?,?&gt;) o2).getKey();
       if (o1 == o2) return 0;
       return ((String) o1).compareTo((String) o2);
     }

Modified: lucene/java/trunk/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
(original)
+++ lucene/java/trunk/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
Sat Dec  5 09:43:54 2009
@@ -274,7 +274,7 @@
     boolean toLowerCase = true;
 //    boolean toLowerCase = false;
 //    Set stopWords = null;
-    Set stopWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
+    Set&lt;?&gt; stopWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
     
     Analyzer[] analyzers = new Analyzer[] { 
         new SimpleAnalyzer(),
@@ -380,7 +380,7 @@
   private String[] readLines(File file) throws Exception {
     BufferedReader reader = new BufferedReader(new InputStreamReader(
         new FileInputStream(file))); 
-    List lines = new ArrayList();
+    List&lt;String&gt; lines = new ArrayList&lt;String&gt;();
     String line;  
     while ((line = reader.readLine()) != null) {
       String t = line.trim(); 
@@ -493,7 +493,7 @@
   
   /** returns all files matching the given file name patterns (quick n'dirty) */
   static String[] listFiles(String[] fileNames) {
-    LinkedHashSet allFiles = new LinkedHashSet();
+    LinkedHashSet&lt;String&gt; allFiles = new LinkedHashSet&lt;String&gt;();
     for (int i=0; i &lt; fileNames.length; i++) {
       int k;
       if ((k = fileNames[i].indexOf("*")) &lt; 0) {

Modified: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
(original)
+++ lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
Sat Dec  5 09:43:54 2009
@@ -90,7 +90,7 @@
 
     Query q = qp.parse(qString);
 
-    HashSet expecteds = new HashSet();
+    HashSet&lt;String&gt; expecteds = new HashSet&lt;String&gt;();
     String[] vals = expectedVals.split(",");
     for (int i = 0; i &lt; vals.length; i++) {
       if (vals[i].length() &gt; 0)

Modified: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java
(original)
+++ lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java
Sat Dec  5 09:43:54 2009
@@ -49,7 +49,7 @@
 public class TestPrecedenceQueryParser extends LocalizedTestCase {
   
   public TestPrecedenceQueryParser(String name) {
-    super(name, new HashSet(Arrays.asList(new String[]{
+    super(name, new HashSet&lt;String&gt;(Arrays.asList(new String[]{
       "testDateRange", "testNumber"
     })));
   }

Modified: lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
(original)
+++ lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
Sat Dec  5 09:43:54 2009
@@ -81,7 +81,7 @@
 	public void testDefaultFilter() throws Throwable
 	{
 		DuplicateFilter df=new DuplicateFilter(KEY_FIELD);		
-		HashSet results=new HashSet();
+		HashSet&lt;String&gt; results=new HashSet&lt;String&gt;();
 		ScoreDoc[] hits = searcher.search(tq,df, 1000).scoreDocs;
 		for(int i=0;i&lt;hits.length;i++)
 		{
@@ -93,7 +93,7 @@
 	}
 	public void testNoFilter() throws Throwable
 	{
-		HashSet results=new HashSet();
+		HashSet&lt;String&gt; results=new HashSet&lt;String&gt;();
 		ScoreDoc[] hits = searcher.search(tq, null, 1000).scoreDocs;
 		assertTrue("Default searching should have found some matches",hits.length&gt;0);
 		boolean dupsFound=false;
@@ -112,7 +112,7 @@
 	{
 		DuplicateFilter df=new DuplicateFilter(KEY_FIELD);
 		df.setProcessingMode(DuplicateFilter.PM_FAST_INVALIDATION);
-		HashSet results=new HashSet();
+		HashSet&lt;String&gt; results=new HashSet&lt;String&gt;();
 		ScoreDoc[] hits = searcher.search(tq,df, 1000).scoreDocs;
 		assertTrue("Filtered searching should have found some matches",hits.length&gt;0);
 		for(int i=0;i&lt;hits.length;i++)

Modified: lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java
(original)
+++ lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java
Sat Dec  5 09:43:54 2009
@@ -70,7 +70,7 @@
 		FuzzyLikeThisQuery flt=new FuzzyLikeThisQuery(10,analyzer);
 		flt.addTerms("smith", "name", 0.3f, 1);
 		Query q=flt.rewrite(searcher.getIndexReader());
-		HashSet queryTerms=new HashSet();
+		HashSet&lt;Term&gt; queryTerms=new HashSet&lt;Term&gt;();
 		q.extractTerms(queryTerms);
 		assertTrue("Should have variant smythe",queryTerms.contains(new Term("name","smythe")));
 		assertTrue("Should have variant smith",queryTerms.contains(new Term("name","smith")));
@@ -87,7 +87,7 @@
 		FuzzyLikeThisQuery flt=new FuzzyLikeThisQuery(10,analyzer);
 		flt.addTerms("jonathin smoth", "name", 0.3f, 1);
 		Query q=flt.rewrite(searcher.getIndexReader());
-		HashSet queryTerms=new HashSet();
+		HashSet&lt;Term&gt; queryTerms=new HashSet&lt;Term&gt;();
 		q.extractTerms(queryTerms);
 		assertTrue("Should have variant jonathan",queryTerms.contains(new Term("name","jonathan")));
 		assertTrue("Should have variant smith",queryTerms.contains(new Term("name","smith")));
@@ -103,7 +103,7 @@
 		FuzzyLikeThisQuery flt=new FuzzyLikeThisQuery(10,analyzer);
 		flt.addTerms("fernando smith", "name", 0.3f, 1);
 		Query q=flt.rewrite(searcher.getIndexReader());
-		HashSet queryTerms=new HashSet();
+		HashSet&lt;Term&gt; queryTerms=new HashSet&lt;Term&gt;();
 		q.extractTerms(queryTerms);
 		assertTrue("Should have variant smith",queryTerms.contains(new Term("name","smith")));
 		TopDocs topDocs = searcher.search(flt, 1);

Modified: lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java
(original)
+++ lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java
Sat Dec  5 09:43:54 2009
@@ -38,7 +38,7 @@
 		TermsFilter a=new TermsFilter();
 		a.addTerm(new Term("field1","a"));
 		a.addTerm(new Term("field1","b"));
-		HashSet cachedFilters=new HashSet();
+		HashSet&lt;Filter&gt; cachedFilters=new HashSet&lt;Filter&gt;();
 		cachedFilters.add(a);
 		TermsFilter b=new TermsFilter();
 		b.addTerm(new Term("field1","a"));

Modified: lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
(original)
+++ lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
Sat Dec  5 09:43:54 2009
@@ -71,7 +71,7 @@
     }
 
     public void testBoostFactor() throws Throwable {
-	Map originalValues = getOriginalValues();
+	Map&lt;String,Float&gt; originalValues = getOriginalValues();
 
 	MoreLikeThis mlt = new MoreLikeThis(
 		reader);
@@ -88,13 +88,13 @@
 
 	BooleanQuery query = (BooleanQuery) mlt.like(new StringReader(
 		"lucene release"));
-	List clauses = query.clauses();
+	List&lt;BooleanClause&gt; clauses = query.clauses();
 
 	assertEquals("Expected " + originalValues.size() + " clauses.",
 		originalValues.size(), clauses.size());
 
 	for (int i = 0; i &lt; clauses.size(); i++) {
-	    BooleanClause clause = (BooleanClause) clauses.get(i);
+	    BooleanClause clause =  clauses.get(i);
 	    TermQuery tq = (TermQuery) clause.getQuery();
 	    Float termBoost = (Float) originalValues.get(tq.getTerm().text());
 	    assertNotNull("Expected term " + tq.getTerm().text(), termBoost);
@@ -106,8 +106,8 @@
 	}
     }
 
-    private Map getOriginalValues() throws IOException {
-	Map originalValues = new HashMap();
+    private Map&lt;String,Float&gt; getOriginalValues() throws IOException {
+	Map&lt;String,Float&gt; originalValues = new HashMap&lt;String,Float&gt;();
 	MoreLikeThis mlt = new MoreLikeThis(reader);
 	mlt.setMinDocFreq(1);
 	mlt.setMinTermFreq(1);
@@ -116,10 +116,10 @@
 	mlt.setBoost(true);
 	BooleanQuery query = (BooleanQuery) mlt.like(new StringReader(
 		"lucene release"));
-	List clauses = query.clauses();
+	List&lt;BooleanClause&gt; clauses = query.clauses();
 
 	for (int i = 0; i &lt; clauses.size(); i++) {
-	    BooleanClause clause = (BooleanClause) clauses.get(i);
+	    BooleanClause clause = clauses.get(i);
 	    TermQuery tq = (TermQuery) clause.getQuery();
 	    originalValues.put(tq.getTerm().text(), Float.valueOf(tq.getBoost()));
 	}

Modified: lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
(original)
+++ lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
Sat Dec  5 09:43:54 2009
@@ -146,7 +146,7 @@
   }
 
   public void testBoostsSimple() throws Exception {
-    Map boosts = new HashMap();
+    Map&lt;CharSequence,Float&gt; boosts = new HashMap&lt;CharSequence,Float&gt;();
     boosts.put("b", Float.valueOf(5));
     boosts.put("t", Float.valueOf(10));
     String[] fields = { "b", "t" };

Modified: lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
(original)
+++ lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
Sat Dec  5 09:43:54 2009
@@ -141,7 +141,7 @@
   }
 
   public void testBoostsSimple() throws Exception {
-    Map boosts = new HashMap();
+    Map&lt;CharSequence,Float&gt; boosts = new HashMap&lt;CharSequence,Float&gt;();
     boosts.put("b", Float.valueOf(5));
     boosts.put("t", Float.valueOf(10));
     String[] fields = { "b", "t" };

Modified: lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
(original)
+++ lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
Sat Dec  5 09:43:54 2009
@@ -89,7 +89,7 @@
 public class TestQPHelper extends LocalizedTestCase {
 
   public TestQPHelper(String name) {
-    super(name, new HashSet(Arrays.asList(new String[]{
+    super(name, new HashSet&lt;String&gt;(Arrays.asList(new String[]{
       "testLegacyDateRange", "testDateRange",
       "testCJK", "testNumber", "testFarsiRangeCollating",
       "testLocalDateFormat"

Modified: lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
(original)
+++ lucene/java/trunk/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
Sat Dec  5 09:43:54 2009
@@ -84,7 +84,7 @@
 public class TestQueryParserWrapper extends LocalizedTestCase {
 
   public TestQueryParserWrapper(String name) {
-    super(name, new HashSet(Arrays.asList(new String[]{
+    super(name, new HashSet&lt;String&gt;(Arrays.asList(new String[]{
       "testLegacyDateRange", "testDateRange",
       "testCJK", "testNumber", "testFarsiRangeCollating",
       "testLocalDateFormat"

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java Sat
Dec  5 09:43:54 2009
@@ -256,8 +256,8 @@
     // System.out.println("modifyNormsForF1 maxDoc: "+n);
     for (int i = 0; i &lt; n; i += 3) { // modify for every third doc
       int k = (i * 3) % modifiedNorms.size();
-      float origNorm = ((Float) modifiedNorms.get(i)).floatValue();
-      float newNorm = ((Float) modifiedNorms.get(k)).floatValue();
+      float origNorm =  modifiedNorms.get(i).floatValue();
+      float newNorm =  modifiedNorms.get(k).floatValue();
       // System.out.println("Modifying: for "+i+" from "+origNorm+" to
       // "+newNorm);
       // System.out.println(" and: for "+k+" from "+newNorm+" to "+origNorm);

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java?rev=887524&amp;r1=887523&amp;r2=887524&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java Sat Dec  5 09:43:54
2009
@@ -229,7 +229,7 @@
       throw new FileNotFoundException(name);
     else {
       if (openFiles.containsKey(name)) {
-        Integer v = (Integer) openFiles.get(name);
+        Integer v =  openFiles.get(name);
         v = Integer.valueOf(v.intValue()+1);
         openFiles.put(name, v);
       } else {
@@ -331,7 +331,7 @@
   synchronized void maybeThrowDeterministicException() throws IOException {
     if (failures != null) {
       for(int i = 0; i &lt; failures.size(); i++) {
-        ((Failure)failures.get(i)).eval(this);
+        failures.get(i).eval(this);
       }
     }
   }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887509 - in /lucene/java/branches/flex_1458: contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/ contrib/misc/src/java/org/apache/lucene/index/ contrib/queries/src/java/org/apache/lucene/search/ src/java/org/apache/lucene/index/...</title>
<author><name>uschindler@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091205072950.E0A2D238898B@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091205072950-E0A2D238898B@eris-apache-org%3e</id>
<updated>2009-12-05T07:29:50Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: uschindler
Date: Sat Dec  5 07:29:49 2009
New Revision: 887509

URL: http://svn.apache.org/viewvc?rev=887509&amp;view=rev
Log:
LUCENE-2109: Make DocsEnum subclass of DocIdSetIterator

Modified:
    lucene/java/branches/flex_1458/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
    lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/index/FieldNormModifier.java
    lucene/java/branches/flex_1458/contrib/queries/src/java/org/apache/lucene/search/DuplicateFilter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/AllDocsEnum.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocsEnum.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsEnum.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/PositionsEnum.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermsEnum.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/DocsConsumer.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhrasePositions.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/TermSpans.java
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCodecs.java

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
(original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
Sat Dec  5 07:29:49 2009
@@ -467,7 +467,7 @@
       TermsEnum terms = fields.terms();
       while(terms.next() != null) {
         DocsEnum docs = terms.docs(reader.getDeletedDocs());
-        while(docs.next() != docs.NO_MORE_DOCS) {
+        while(docs.nextDoc() != docs.NO_MORE_DOCS) {
           totalTokenCount2 += docs.freq();
         }
       }

Modified: lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/index/FieldNormModifier.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/index/FieldNormModifier.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/index/FieldNormModifier.java
(original)
+++ lucene/java/branches/flex_1458/contrib/misc/src/java/org/apache/lucene/index/FieldNormModifier.java
Sat Dec  5 07:29:49 2009
@@ -120,7 +120,7 @@
           while(termsEnum.next() != null) {
             DocsEnum docs = termsEnum.docs(delDocs);
             while(true) {
-              int docID = docs.next();
+              int docID = docs.nextDoc();
               if (docID != docs.NO_MORE_DOCS) {
                 termCounts[docID] += docs.freq();
               } else {

Modified: lucene/java/branches/flex_1458/contrib/queries/src/java/org/apache/lucene/search/DuplicateFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/queries/src/java/org/apache/lucene/search/DuplicateFilter.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/queries/src/java/org/apache/lucene/search/DuplicateFilter.java
(original)
+++ lucene/java/branches/flex_1458/contrib/queries/src/java/org/apache/lucene/search/DuplicateFilter.java
Sat Dec  5 07:29:49 2009
@@ -95,7 +95,7 @@
           break;
         } else {
           DocsEnum docs = termsEnum.docs(delDocs);
-          int doc = docs.next();
+          int doc = docs.nextDoc();
           if (doc != docs.NO_MORE_DOCS) {
             if (keepMode == KM_USE_FIRST_OCCURRENCE) {
               bits.set(doc);
@@ -103,7 +103,7 @@
               int lastDoc = doc;
               while (true) {
                 lastDoc = doc;
-                doc = docs.next();
+                doc = docs.nextDoc();
                 if (doc == docs.NO_MORE_DOCS) {
                   break;
                 }
@@ -134,10 +134,10 @@
           if (termsEnum.docFreq() &gt; 1) {
             // unset potential duplicates
             DocsEnum docs = termsEnum.docs(delDocs);
-            int doc = docs.next();
+            int doc = docs.nextDoc();
             if (doc != docs.NO_MORE_DOCS) {
               if (keepMode == KM_USE_FIRST_OCCURRENCE) {
-                doc = docs.next();
+                doc = docs.nextDoc();
               }
             }
             
@@ -145,7 +145,7 @@
             while (true) {
               lastDoc = doc;
               bits.clear(lastDoc);
-              doc = docs.next();
+              doc = docs.nextDoc();
               if (doc == docs.NO_MORE_DOCS) {
                 break;
               }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/AllDocsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/AllDocsEnum.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/AllDocsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/AllDocsEnum.java Sat Dec
 5 07:29:49 2009
@@ -38,7 +38,12 @@
   }
 
   @Override
-  public int next() throws IOException {
+  public int docID() {
+    return doc;
+  }
+
+  @Override
+  public int nextDoc() throws IOException {
     return advance(doc+1);
   }
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java Sat Dec
 5 07:29:49 2009
@@ -611,7 +611,7 @@
 
           int lastDoc = -1;
           while(true) {
-            final int doc = docs.next();
+            final int doc = docs.nextDoc();
             if (doc == DocsEnum.NO_MORE_DOCS) {
               break;
             }
@@ -652,7 +652,7 @@
           if (reader.hasDeletions()) {
             final DocsEnum docsNoDel = terms.docs(null);
             int count = 0;
-            while(docsNoDel.next() != DocsEnum.NO_MORE_DOCS) {
+            while(docsNoDel.nextDoc() != DocsEnum.NO_MORE_DOCS) {
               count++;
             }
             if (count != docFreq) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java Sat
Dec  5 07:29:49 2009
@@ -1513,6 +1513,7 @@
     DocsEnum currentDocs;
     int currentBase;
     Bits skipDocs;
+    int doc = -1;
 
     MultiDocsEnum(int count) {
       subs = new DocsEnumWithBase[count];
@@ -1564,6 +1565,11 @@
     }
 
     @Override
+    public int docID() {
+      return doc;
+    }
+
+    @Override
     public int read(final int docs[], final int freqs[]) throws IOException {
       while (true) {
         while (currentDocs == null) {
@@ -1595,10 +1601,10 @@
           if (doc == NO_MORE_DOCS) {
             currentDocs = null;
           } else {
-            return doc + currentBase;
+            return this.doc = doc + currentBase;
           }
         } else if (upto == numSubs-1) {
-          return NO_MORE_DOCS;
+          return this.doc = NO_MORE_DOCS;
         } else {
           upto++;
           currentDocs = subs[upto].docs;
@@ -1608,11 +1614,11 @@
     }
 
     @Override
-    public int next() throws IOException {
+    public int nextDoc() throws IOException {
       while(true) {
         if (currentDocs == null) {
           if (upto == numSubs-1) {
-            return NO_MORE_DOCS;
+            return this.doc = NO_MORE_DOCS;
           } else {
             upto++;
             currentDocs = subs[upto].docs;
@@ -1620,9 +1626,9 @@
           }
         }
 
-        final int doc = currentDocs.next();
+        final int doc = currentDocs.nextDoc();
         if (doc != NO_MORE_DOCS) {
-          return currentBase + doc;
+          return this.doc = currentBase + doc;
         } else {
           currentDocs = null;
         }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocsEnum.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocsEnum.java Sat Dec
 5 07:29:49 2009
@@ -19,24 +19,28 @@
 
 import java.io.IOException;
 
+import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.util.AttributeSource;
 
 /** On obtaining a DocsEnum, you must first call next() */
 
-public abstract class DocsEnum extends AttributeSource {
-  // nocommit
-  public String desc;
+public abstract class DocsEnum extends DocIdSetIterator {
 
-  public final static int NO_MORE_DOCS = Integer.MAX_VALUE;
+  private AttributeSource atts = null;
 
-  /** Moves forward to the doc id &gt;= target */
-  public abstract int advance(int target) throws IOException;
-
-  /** Returns the next docID, {@link #NO_MORE_DOCS} at the end. */
-  public abstract int next() throws IOException;
+  // nocommit
+  public String desc;
 
   public abstract int freq();
   
+  /**
+   * Returns the related attributes.
+   */
+  public AttributeSource attributes() {
+    if (atts == null) atts = new AttributeSource();
+    return atts;
+  }
+  
   // nocommit -- fix this API so that intblock codecs are
   // able to return their own int arrays, to save a copy
   /** Bulk read: returns number of docs read.  Subclass may
@@ -44,7 +48,7 @@
   public int read(int[] docs, int[] freqs) throws IOException {
     int count = 0;
     while(count &lt; docs.length) {
-      final int doc = next();
+      final int doc = nextDoc();
       if (doc != NO_MORE_DOCS) {
         docs[count] = doc;
         freqs[count] = freq();

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java Sat
Dec  5 07:29:49 2009
@@ -1030,7 +1030,7 @@
           if (docs != null) {
             int limit = entry.getValue().getNum();
             while (true) {
-              final int docID = docs.next();
+              final int docID = docs.nextDoc();
               if (docID == DocsEnum.NO_MORE_DOCS || docIDStart+docID &gt;= limit) {
                 break;
               }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsEnum.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsEnum.java Sat Dec
 5 07:29:49 2009
@@ -25,8 +25,18 @@
  *
  * NOTE: this API is experimental and will likely change */
 
-public abstract class FieldsEnum extends AttributeSource {
+public abstract class FieldsEnum {
 
+  private AttributeSource atts = null;
+
+  /**
+   * Returns the related attributes.
+   */
+  public AttributeSource attributes() {
+    if (atts == null) atts = new AttributeSource();
+    return atts;
+  }
+  
   // nocommit -- do we need seek?
 
   /** Increments the enumeration to the next field.

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexReader.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexReader.java Sat Dec
 5 07:29:49 2009
@@ -850,10 +850,14 @@
       return NO_MORE_DOCS;
     }
     @Override
-    public int next() {
+    public int nextDoc() {
       return NO_MORE_DOCS;
     }
     @Override
+    public int docID() {
+      return -1;
+    }
+    @Override
     public int freq() {
       return 1;
     }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
Sat Dec  5 07:29:49 2009
@@ -171,6 +171,7 @@
     final Bits skipDocs;
 
     TermPositions tp;
+    int doc = -1;
 
     LegacyDocsEnum(IndexReader r, String field, Term term, Bits skipDocs) throws IOException
{
       this.r = r;
@@ -184,20 +185,20 @@
     // always secretly skip deleted docs, and we can't work
     // around that for external readers?
     @Override
-    public int next() throws IOException {
+    public int nextDoc() throws IOException {
       if (td.next()) {
-        return td.doc();
+        return doc = td.doc();
       } else {
-        return NO_MORE_DOCS;
+        return doc = NO_MORE_DOCS;
       }
     }
 
     @Override
     public int advance(int target) throws IOException {
       if (td.skipTo(target)) {
-        return td.doc();
+        return doc = td.doc();
       } else {
-        return NO_MORE_DOCS;
+        return doc = NO_MORE_DOCS;
       }
     }
 
@@ -207,6 +208,11 @@
     }
 
     @Override
+    public int docID() {
+      return doc;
+    }
+
+    @Override
     public int read(int[] docs, int[] freqs) throws IOException {
       return td.read(docs, freqs);
     }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/PositionsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/PositionsEnum.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/PositionsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/PositionsEnum.java Sat
Dec  5 07:29:49 2009
@@ -21,8 +21,18 @@
 
 import org.apache.lucene.util.AttributeSource;
 
-public abstract class PositionsEnum extends AttributeSource {
+public abstract class PositionsEnum {
 
+  private AttributeSource atts = null;
+
+  /**
+   * Returns the related attributes.
+   */
+  public AttributeSource attributes() {
+    if (atts == null) atts = new AttributeSource();
+    return atts;
+  }
+  
   // nocommit
   public String desc;
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java Sat
Dec  5 07:29:49 2009
@@ -1546,7 +1546,7 @@
 
     public boolean next() throws IOException {
       if (docs == null) return false;
-      doc = docs.next();
+      doc = docs.nextDoc();
       return doc != DocsEnum.NO_MORE_DOCS;
     }
   }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermsEnum.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermsEnum.java Sat Dec
 5 07:29:49 2009
@@ -31,10 +31,24 @@
  * #docFreq}), and obtain a {@link DocsEnum} for the current
  * term ({@link #docs)}.
  * 
+ * &lt;p&gt;Term enumerations are always ordered by
+ * {@link #getTermComparator}.  Each term in the enumeration is
+ * greater than all that precede it.&lt;/p&gt;
+ *
  * &lt;p&gt;On obtaining a TermsEnum, you must first call
  * {@link #next} or {@link #seek}. */
-public abstract class TermsEnum extends AttributeSource {
+public abstract class TermsEnum {
 
+  private AttributeSource atts = null;
+
+  /**
+   * Returns the related attributes.
+   */
+  public AttributeSource attributes() {
+    if (atts == null) atts = new AttributeSource();
+    return atts;
+  }
+  
   /** Represents returned result from {@link TermsEnum.seek}.
    *  If status is FOUND, then the precise term was found.
    *  If status is NOT_FOUND, then a different term was

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/DocsConsumer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/DocsConsumer.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/DocsConsumer.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/DocsConsumer.java
Sat Dec  5 07:29:49 2009
@@ -59,7 +59,7 @@
       final int base = toMerge[i].docBase;
 
       while(true) {
-        final int startDoc = docs.next();
+        final int startDoc = docs.nextDoc();
         if (startDoc == DocsEnum.NO_MORE_DOCS) {
           break;
         }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
Sat Dec  5 07:29:49 2009
@@ -314,7 +314,7 @@
     }
 
     @Override
-    public int next() throws IOException {
+    public int nextDoc() throws IOException {
       if (Codec.DEBUG) {
         System.out.println("pff.docs.next");
       }
@@ -340,6 +340,11 @@
     }
 
     @Override
+    public int docID() {
+      return current.doc();
+    }
+
+    @Override
     public int read(int[] docIDs, int[] freqs) throws IOException {
       if (current != docs) {
         docs.skipTo(current.doc());

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
Sat Dec  5 07:29:49 2009
@@ -203,7 +203,7 @@
       }
 
       @Override
-      public int next() {
+      public int nextDoc() {
         while(true) {
           if (nextRead &gt;= docFreq) {
             return NO_MORE_DOCS;
@@ -244,6 +244,11 @@
         return doc.numPositions;
       }
 
+      @Override
+      public int docID() {
+        return doc.docID;
+      }
+
       class PulsingPositionsEnum extends PositionsEnum {
         int nextRead;
         PulsingDocsWriter.Position pos;
@@ -301,7 +306,7 @@
       @Override
       public int advance(int target) throws IOException {
         int doc;
-        while((doc=next()) != NO_MORE_DOCS) {
+        while((doc=nextDoc()) != NO_MORE_DOCS) {
           if (doc &gt;= target)
             return doc;
         }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
Sat Dec  5 07:29:49 2009
@@ -280,7 +280,7 @@
       }
 
       @Override
-      public int next() throws IOException {
+      public int nextDoc() throws IOException {
 
         if (Codec.DEBUG) {
           if (!omitTF) {
@@ -292,7 +292,7 @@
 
         while(true) {
           if (count == docFreq) {
-            return NO_MORE_DOCS;
+            return doc = NO_MORE_DOCS;
           }
 
           count++;
@@ -363,6 +363,11 @@
         return freq;
       }
 
+      @Override
+      public int docID() {
+        return doc;
+      }
+
       // Holds pending seek data for positions:
       IntIndexInput.Index posIndex;
       long payloadOffset;
@@ -522,7 +527,7 @@
         
         // Now, linear scan for the rest:
         do {
-          if (next() == NO_MORE_DOCS) {
+          if (nextDoc() == NO_MORE_DOCS) {
             return NO_MORE_DOCS;
           }
         } while (target &gt; doc);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
Sat Dec  5 07:29:49 2009
@@ -289,7 +289,7 @@
       }
 
       @Override
-      public int next() throws IOException {
+      public int nextDoc() throws IOException {
         if (Codec.DEBUG) {
           System.out.println("sdr.next [" + desc + "] count=" + count + " vs df=" + docFreq
+ " freq pointer=" + freqIn.getFilePointer() + " (in=" + freqIn + "; this=" + this + ") +
has skip docs=" + (skipDocs != null));
         }
@@ -379,7 +379,8 @@
         return i;
       }
 
-      public int doc() {
+      @Override
+      public int docID() {
         return doc;
       }
 
@@ -498,7 +499,7 @@
         
         // Now, linear scan for the rest:
         do {
-          if (next() == NO_MORE_DOCS)
+          if (nextDoc() == NO_MORE_DOCS)
             return NO_MORE_DOCS;
         } while (target &gt; doc);
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java Sat
Dec  5 07:29:49 2009
@@ -281,7 +281,7 @@
             final byte termval = parser.parseByte(term);
             final DocsEnum docs = termsEnum.docs(delDocs);
             while (true) {
-              final int docID = docs.next();
+              final int docID = docs.nextDoc();
               if (docID == DocsEnum.NO_MORE_DOCS) {
                 break;
               }
@@ -334,7 +334,7 @@
             final short termval = parser.parseShort(term);
             final DocsEnum docs = termsEnum.docs(delDocs);
             while (true) {
-              final int docID = docs.next();
+              final int docID = docs.nextDoc();
               if (docID == DocsEnum.NO_MORE_DOCS) {
                 break;
               }
@@ -397,7 +397,7 @@
 
             final DocsEnum docs = termsEnum.docs(delDocs);
             while (true) {
-              final int docID = docs.next();
+              final int docID = docs.nextDoc();
               if (docID == DocsEnum.NO_MORE_DOCS) {
                 break;
               }
@@ -468,7 +468,7 @@
 
             final DocsEnum docs = termsEnum.docs(delDocs);
             while (true) {
-              final int docID = docs.next();
+              final int docID = docs.nextDoc();
               if (docID == DocsEnum.NO_MORE_DOCS) {
                 break;
               }
@@ -534,7 +534,7 @@
 
             final DocsEnum docs = termsEnum.docs(delDocs);
             while (true) {
-              final int docID = docs.next();
+              final int docID = docs.nextDoc();
               if (docID == DocsEnum.NO_MORE_DOCS) {
                 break;
               }
@@ -602,7 +602,7 @@
 
             final DocsEnum docs = termsEnum.docs(delDocs);
             while (true) {
-              final int docID = docs.next();
+              final int docID = docs.nextDoc();
               if (docID == DocsEnum.NO_MORE_DOCS) {
                 break;
               }
@@ -647,7 +647,7 @@
           final DocsEnum docs = termsEnum.docs(delDocs);
           final String termval = term.toString();
           while (true) {
-            final int docID = docs.next();
+            final int docID = docs.nextDoc();
             if (docID == DocsEnum.NO_MORE_DOCS) {
               break;
             }
@@ -707,7 +707,7 @@
 
           final DocsEnum docs = termsEnum.docs(delDocs);
           while (true) {
-            final int docID = docs.next();
+            final int docID = docs.nextDoc();
             if (docID == DocsEnum.NO_MORE_DOCS) {
               break;
             }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java
Sat Dec  5 07:29:49 2009
@@ -399,7 +399,7 @@
       Iterator i = docsEnums.iterator();
       while (i.hasNext()) {
         DocsEnumWrapper docs = (DocsEnumWrapper) i.next();
-        docs.doc = docs.docsEnum.next();
+        docs.doc = docs.docsEnum.nextDoc();
         if (docs.doc != DocsEnum.NO_MORE_DOCS) {
           add(docs);
         }
@@ -485,7 +485,7 @@
   }
 
   @Override
-  public final int next() throws IOException {
+  public final int nextDoc() throws IOException {
     if (_queue.size() == 0) {
       return NO_MORE_DOCS;
     }
@@ -507,7 +507,7 @@
         _posList.add(positions.next());
       }
 
-      docs.doc = docs.docsEnum.next();
+      docs.doc = docs.docsEnum.nextDoc();
 
       if (docs.doc != NO_MORE_DOCS) {
         _queue.updateTop();
@@ -554,7 +554,7 @@
         _queue.add(docs);
       }
     }
-    return next();
+    return nextDoc();
   }
 
   @Override
@@ -562,6 +562,11 @@
     return _freq;
   }
 
+  @Override
+  public final int docID() {
+    return _doc;
+  }
+
   /**
    * Not implemented.
    * @throws UnsupportedOperationException

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhrasePositions.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhrasePositions.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhrasePositions.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhrasePositions.java
Sat Dec  5 07:29:49 2009
@@ -39,7 +39,7 @@
   }
 
   final boolean next() throws IOException {	  // increments to next doc
-    doc = docs.next();
+    doc = docs.nextDoc();
     if (doc == docs.NO_MORE_DOCS) {
       return false;
     }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/TermSpans.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/TermSpans.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/TermSpans.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/TermSpans.java
Sat Dec  5 07:29:49 2009
@@ -46,7 +46,7 @@
   @Override
   public boolean next() throws IOException {
     if (count == freq) {
-      doc = docs.next();
+      doc = docs.nextDoc();
       if (doc == DocsEnum.NO_MORE_DOCS) {
         return false;
       }

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestExternalCodecs.java Sat
Dec  5 07:29:49 2009
@@ -346,9 +346,10 @@
       }
 
       @Override
+      // nocommit: Is this ok? it always return NO_MORE_DOCS
       public int advance(int targetDocID) {
         do {
-          next();
+          nextDoc();
         } while (upto &lt; ramTerm.docs.size() &amp;&amp; current.docID &lt; targetDocID);
         return NO_MORE_DOCS;
       }
@@ -356,7 +357,7 @@
       // TODO: override bulk read, for better perf
 
       @Override
-      public int next() {
+      public int nextDoc() {
         while(true) {
           upto++;
           if (upto &lt; ramTerm.docs.size()) {
@@ -376,6 +377,11 @@
       }
 
       @Override
+      public int docID() {
+        return current.docID;
+      }
+
+      @Override
       public PositionsEnum positions() {
         positions.reset(current);
         return positions;

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCodecs.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCodecs.java?rev=887509&amp;r1=887508&amp;r2=887509&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCodecs.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCodecs.java Sat Dec
 5 07:29:49 2009
@@ -359,14 +359,14 @@
 
     private void verifyDocs(int[] docs, PositionData[][] positions, DocsEnum docsEnum, boolean
doPos) throws Throwable {
       for(int i=0;i&lt;docs.length;i++) {
-        int doc = docsEnum.next();
+        int doc = docsEnum.nextDoc();
         assertTrue(doc != DocsEnum.NO_MORE_DOCS);
         assertEquals(docs[i], doc);
         if (doPos) {
           verifyPositions(positions[i], docsEnum.positions());
         }
       }
-      assertEquals(DocsEnum.NO_MORE_DOCS, docsEnum.next());
+      assertEquals(DocsEnum.NO_MORE_DOCS, docsEnum.nextDoc());
     }
 
     byte[] data = new byte[10];
@@ -524,7 +524,7 @@
                 // nocommit -- test skipping to non-existent doc
                 assertEquals(term.docs[upto2], doc);
               } else {
-                doc = docs.next();
+                doc = docs.nextDoc();
                 assertTrue(doc != -1);
                 if (Codec.DEBUG) {
                   System.out.println("TEST [" + getDesc(field, term) + "]: got next doc...");
@@ -547,7 +547,7 @@
               }
             }
 
-            assertEquals(DocsEnum.NO_MORE_DOCS, docs.next());
+            assertEquals(DocsEnum.NO_MORE_DOCS, docs.nextDoc());
 
           } else if (Codec.DEBUG) {
             System.out.println("\nTEST [" + getDesc(field, term) + "]: skip docs");




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887347 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/search/Filter.java src/test/org/apache/lucene/search/TestFilteredSearch.java</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091204203145.34F862388978@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204203145-34F862388978@eris-apache-org%3e</id>
<updated>2009-12-04T20:31:44Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Fri Dec  4 20:31:44 2009
New Revision: 887347

URL: http://svn.apache.org/viewvc?rev=887347&amp;view=rev
Log:
LUCENE-2114: TestFilteredSearch tests on multi-segment index; fix Filter javadocs to call
out that reader is per-segment

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/search/Filter.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredSearch.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=887347&amp;r1=887346&amp;r2=887347&amp;view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Fri Dec  4 20:31:44 2009
@@ -69,6 +69,10 @@
 * LUCENE-2065: Use Java 5 generics throughout our unit tests.  (Kay
   Kay via Mike McCandless)
 
+* LUCENE-2114: Change TestFilteredSearch to test on multi-segment
+  index as well; improve javadocs of Filter to call out that the
+  provided reader is per-segment (Simon Willnauer via Mike McCandless)
+
 ======================= Release 3.0.0 2009-11-25 =======================
 
 Changes in backwards compatibility policy

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/Filter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/Filter.java?rev=887347&amp;r1=887346&amp;r2=887347&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/Filter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/Filter.java Fri Dec  4 20:31:44 2009
@@ -22,12 +22,28 @@
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.util.DocIdBitSet;
 
-/** Abstract base class providing a mechanism to use a subset of an index
+/** 
+ *  Abstract base class providing a mechanism to use a subset of an index
  *  for restriction or permission of index search results.
  *  &lt;p&gt;
  */
 public abstract class Filter implements java.io.Serializable {
+  
   /**
+   * Creates a {@link DocIdSet} that provides the documents which should be
+   * permitted or prohibited in search results. &lt;b&gt;NOTE:&lt;/b&gt; null can be
+   * returned if no documents will be accepted by this Filter.
+   * &lt;p&gt;
+   * Note: This method might be called more than once during a search if the
+   * index has more than one segment. In such a case the {@link DocIdSet}
+   * must be relative to the document base of the given reader. Yet, the
+   * segment readers are passed in increasing document base order.
+   * 
+   * @param reader a {@link IndexReader} instance opened on the index currently
+   *         searched on. Note, it is likely that the provided reader does not
+   *         represent the whole underlying index i.e. if the index has more than
+   *         one segment the given reader only represents a single segment.
+   *          
    * @return a DocIdSet that provides the documents which should be permitted or
    *         prohibited in search results. &lt;b&gt;NOTE:&lt;/b&gt; null can be returned
if
    *         no documents will be accepted by this Filter.

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredSearch.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredSearch.java?rev=887347&amp;r1=887346&amp;r2=887347&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredSearch.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredSearch.java Fri Dec  4
20:31:44 2009
@@ -24,9 +24,12 @@
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.OpenBitSet;
 
@@ -42,19 +45,32 @@
 
   private static final String FIELD = "category";
   
-  public void testFilteredSearch() {
+  public void testFilteredSearch() throws CorruptIndexException, LockObtainFailedException,
IOException {
+    boolean enforceSingleSegment = true;
     RAMDirectory directory = new RAMDirectory();
     int[] filterBits = {1, 36};
-    Filter filter = new SimpleDocIdSetFilter(filterBits);
-    
+    SimpleDocIdSetFilter filter = new SimpleDocIdSetFilter(filterBits);
+    IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+    searchFiltered(writer, directory, filter, enforceSingleSegment);
+    // run the test on more than one segment
+    enforceSingleSegment = false;
+    // reset - it is stateful
+    filter.reset();
+    writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+    // we index 60 docs - this will create 6 segments
+    writer.setMaxBufferedDocs(10);
+    searchFiltered(writer, directory, filter, enforceSingleSegment);
+  }
 
+  public void searchFiltered(IndexWriter writer, Directory directory, Filter filter, boolean
optimize) {
     try {
-      IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
       for (int i = 0; i &lt; 60; i++) {//Simple docs
         Document doc = new Document();
         doc.add(new Field(FIELD, Integer.toString(i), Field.Store.YES, Field.Index.NOT_ANALYZED));
         writer.addDocument(doc);
       }
+      if(optimize)
+        writer.optimize();
       writer.close();
 
       BooleanQuery booleanQuery = new BooleanQuery();
@@ -69,24 +85,33 @@
     catch (IOException e) {
       fail(e.getMessage());
     }
-
+    
   }
-  
-
+ 
   public static final class SimpleDocIdSetFilter extends Filter {
-    private OpenBitSet bits;
-
+    private int docBase;
+    private final int[] docs;
+    private int index;
     public SimpleDocIdSetFilter(int[] docs) {
-      bits = new OpenBitSet();
-      for(int i = 0; i &lt; docs.length; i++){
-    	  bits.set(docs[i]);
-      }
-      
+      this.docs = docs;
     }
-
     @Override
     public DocIdSet getDocIdSet(IndexReader reader) {
-      return bits;
+      final OpenBitSet set = new OpenBitSet();
+      final int limit = docBase+reader.maxDoc();
+      for (;index &lt; docs.length; index++) {
+        final int docId = docs[index];
+        if(docId &gt; limit)
+          break;
+        set.set(docId-docBase);
+      }
+      docBase = limit;
+      return set.isEmpty()?null:set;
+    }
+    
+    public void reset(){
+      index = 0;
+      docBase = 0;
     }
   }
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887339 - /lucene/java/trunk/contrib/fast-vector-highlighter/pom.xml.template</title>
<author><name>simonw@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091204201609.D0DC623888DC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204201609-D0DC623888DC@eris-apache-org%3e</id>
<updated>2009-12-04T20:16:09Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: simonw
Date: Fri Dec  4 20:16:09 2009
New Revision: 887339

URL: http://svn.apache.org/viewvc?rev=887339&amp;view=rev
Log:
LUCENE-2107: Added a pom.xml.template to contrib/fast-vector-highlighter

Added:
    lucene/java/trunk/contrib/fast-vector-highlighter/pom.xml.template

Added: lucene/java/trunk/contrib/fast-vector-highlighter/pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/fast-vector-highlighter/pom.xml.template?rev=887339&amp;view=auto
==============================================================================
--- lucene/java/trunk/contrib/fast-vector-highlighter/pom.xml.template (added)
+++ lucene/java/trunk/contrib/fast-vector-highlighter/pom.xml.template Fri Dec  4 20:16:09
2009
@@ -0,0 +1,45 @@
+&lt;project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
+
+  &lt;!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+  --&gt;
+
+  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
+  &lt;parent&gt;
+    &lt;groupId&gt;org.apache.lucene&lt;/groupId&gt;
+    &lt;artifactId&gt;lucene-contrib&lt;/artifactId&gt;
+    &lt;version&gt;@version@&lt;/version&gt;
+  &lt;/parent&gt;
+  &lt;groupId&gt;org.apache.lucene&lt;/groupId&gt;
+  &lt;artifactId&gt;lucene-fast-vector-highlighter&lt;/artifactId&gt;
+  &lt;name&gt;Lucene Fast-Vector-Highlighter&lt;/name&gt;
+  &lt;version&gt;@version@&lt;/version&gt;
+  &lt;description&gt;
+    This is a Term-Vector based highlighter for Apache Lucene Java
+  &lt;/description&gt;
+  &lt;packaging&gt;jar&lt;/packaging&gt;
+  &lt;dependencies&gt;
+    &lt;dependency&gt;
+      &lt;groupId&gt;org.apache.lucene&lt;/groupId&gt;
+      &lt;artifactId&gt;lucene-analyzers&lt;/artifactId&gt;
+      &lt;version&gt;@version@&lt;/version&gt;
+    &lt;/dependency&gt;
+  &lt;/dependencies&gt;
+&lt;/project&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887283 - in /lucene/java/branches/flex_1458/src/java/org/apache/lucene/search: SingleTermsEnum.java WildcardQuery.java</title>
<author><name>rmuir@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091204173059.9573023888E9@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204173059-9573023888E9@eris-apache-org%3e</id>
<updated>2009-12-04T17:30:58Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: rmuir
Date: Fri Dec  4 17:30:57 2009
New Revision: 887283

URL: http://svn.apache.org/viewvc?rev=887283&amp;view=rev
Log:
LUCENE-2113: Add SingleTermsEnum

Added:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SingleTermsEnum.java
  (with props)
Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/WildcardQuery.java

Added: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SingleTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SingleTermsEnum.java?rev=887283&amp;view=auto
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SingleTermsEnum.java
(added)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SingleTermsEnum.java
Fri Dec  4 17:30:57 2009
@@ -0,0 +1,80 @@
+package org.apache.lucene.search;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermRef;
+import org.apache.lucene.index.Terms;
+
+/**
+ * Subclass of FilteredTermsEnum for enumerating a single term.
+ * &lt;p&gt;
+ * This can be used by {@link MultiTermQuery}s that need only visit one term,
+ * but want to preserve MultiTermQuery semantics such as
+ * {@link MultiTermQuery#rewriteMethod}.
+ */
+public class SingleTermsEnum extends FilteredTermsEnum {
+  private final Term singleTerm;
+  private final TermRef singleRef;
+  private final boolean empty;
+  
+  /**
+   * Creates a new &lt;code&gt;SingleTermsEnum&lt;/code&gt;.
+   * &lt;p&gt;
+   * After calling the constructor the enumeration is already pointing to the term,
+   * if it exists.
+   */
+  public SingleTermsEnum(IndexReader reader, Term singleTerm) throws IOException {
+    this.singleTerm = singleTerm;
+    Terms terms = reader.fields().terms(singleTerm.field());
+    if (terms != null) {
+      singleRef = new TermRef(singleTerm.text());
+      empty = setEnum(terms.iterator(), singleRef) == null;
+    } else {
+      empty = true;
+      singleRef = null;
+    }
+  }
+
+  @Override
+  protected AcceptStatus accept(TermRef term) {
+    if (term.equals(singleRef)) {
+      return AcceptStatus.YES;
+    } else {
+      return AcceptStatus.END;
+    }
+  }
+
+  @Override
+  public float difference() {
+    return 1.0F;
+  }
+
+  @Override
+  public boolean empty() {
+    return empty;
+  }
+
+  @Override
+  public String field() {
+    return singleTerm.field();
+  }
+}

Propchange: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SingleTermsEnum.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/WildcardQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/WildcardQuery.java?rev=887283&amp;r1=887282&amp;r2=887283&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/WildcardQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/WildcardQuery.java Fri
Dec  4 17:30:57 2009
@@ -50,11 +50,12 @@
         &amp;&amp; (text.indexOf('*') == text.length() - 1);
   }
   
-  // nocommit: needs singletermenum stuff
   @Override
   protected FilteredTermsEnum getTermsEnum(IndexReader reader) throws IOException {
-    //nocommit: handle singletermenum
-    return new WildcardTermsEnum(reader, getTerm());
+    if (termContainsWildcard)
+      return new WildcardTermsEnum(reader, getTerm());
+    else
+      return new SingleTermsEnum(reader, getTerm());
   }
   
   // @deprecated see getTermsEnum




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887276 - /lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexReader.java</title>
<author><name>markrmiller@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091204171705.4B44123888DC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204171705-4B44123888DC@eris-apache-org%3e</id>
<updated>2009-12-04T17:17:04Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: markrmiller
Date: Fri Dec  4 17:17:02 2009
New Revision: 887276

URL: http://svn.apache.org/viewvc?rev=887276&amp;view=rev
Log:
LUCENE-1458: (flex branch) Fix missing merges in IndexReader

Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexReader.java

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexReader.java?rev=887276&amp;r1=887275&amp;r2=887276&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexReader.java Fri Dec
 4 17:17:02 2009
@@ -39,7 +39,7 @@
 
  &lt;p&gt; Concrete subclasses of IndexReader are usually constructed with a call to
  one of the static &lt;code&gt;open()&lt;/code&gt; methods, e.g. {@link
- #open(String, boolean)}.
+ #open(Directory, boolean)}.
 
  &lt;p&gt; For efficiency, in this API documents are often referred to via
  &lt;i&gt;document numbers&lt;/i&gt;, non-negative integers which each name a unique
@@ -61,14 +61,11 @@
  &lt;p&gt;
 
  &lt;b&gt;NOTE&lt;/b&gt;: as of 2.4, it's possible to open a read-only
- IndexReader using one of the static open methods that
- accepts the boolean readOnly parameter.  Such a reader has
- better concurrency as it's not necessary to synchronize on
- the isDeleted method.  Currently the default for readOnly
- is false, meaning if not specified you will get a
- read/write IndexReader.  But in 3.0 this default will
- change to true, meaning you must explicitly specify false
- if you want to make changes with the resulting IndexReader.
+ IndexReader using the static open methods that accept the 
+ boolean readOnly parameter.  Such a reader has better 
+ concurrency as it's not necessary to synchronize on the 
+ isDeleted method.  You must specify false if you want to 
+ make changes with the resulting IndexReader.
  &lt;/p&gt;
 
  &lt;a name="thread-safety"&gt;&lt;/a&gt;&lt;p&gt;&lt;b&gt;NOTE&lt;/b&gt;: {@link
@@ -183,6 +180,16 @@
       throw new AlreadyClosedException("this IndexReader is closed");
     }
   }
+  
+  /** Returns a IndexReader reading the index in the given
+   *  Directory, with readOnly=true.
+   * @param directory the index directory
+   * @throws CorruptIndexException if the index is corrupt
+   * @throws IOException if there is a low-level IO error
+   */
+  public static IndexReader open(final Directory directory) throws CorruptIndexException,
IOException {
+    return open(directory, null, null, true, DEFAULT_TERMS_INDEX_DIVISOR, null);
+  }
 
   /** Returns an IndexReader reading the index in the given
    *  Directory.  You should pass readOnly=true, since it
@@ -212,22 +219,6 @@
     return open(commit.getDirectory(), null, commit, readOnly, DEFAULT_TERMS_INDEX_DIVISOR,
null);
   }
 
-  /** Expert: returns a read/write IndexReader reading the index in the given
-   *  Directory, with a custom {@link IndexDeletionPolicy}.
-   * @param directory the index directory
-   * @param deletionPolicy a custom deletion policy (only used
-   *  if you use this reader to perform deletes or to set
-   *  norms); see {@link IndexWriter} for details.
-   * @deprecated Use {@link #open(Directory, IndexDeletionPolicy, boolean)} instead.
-   *             This method will be removed in the 3.0 release.
-   * 
-   * @throws CorruptIndexException if the index is corrupt
-   * @throws IOException if there is a low-level IO error
-   */
-  public static IndexReader open(final Directory directory, IndexDeletionPolicy deletionPolicy)
throws CorruptIndexException, IOException {
-    return open(directory, deletionPolicy, null, false, DEFAULT_TERMS_INDEX_DIVISOR, null);
-  }
-
   /** Expert: returns an IndexReader reading the index in
    *  the given Directory, with a custom {@link
    *  IndexDeletionPolicy}.  You should pass readOnly=true,
@@ -274,25 +265,6 @@
     return open(directory, deletionPolicy, null, readOnly, termInfosIndexDivisor, null);
   }
 
-  /** Expert: returns a read/write IndexReader reading the index in the given
-   * Directory, using a specific commit and with a custom
-   * {@link IndexDeletionPolicy}.
-   * @param commit the specific {@link IndexCommit} to open;
-   * see {@link IndexReader#listCommits} to list all commits
-   * in a directory
-   * @param deletionPolicy a custom deletion policy (only used
-   *  if you use this reader to perform deletes or to set
-   *  norms); see {@link IndexWriter} for details.
-   * @deprecated Use {@link #open(IndexCommit, IndexDeletionPolicy, boolean)} instead.
-   *             This method will be removed in the 3.0 release.
-   * 
-   * @throws CorruptIndexException if the index is corrupt
-   * @throws IOException if there is a low-level IO error
-   */
-  public static IndexReader open(final IndexCommit commit, IndexDeletionPolicy deletionPolicy)
throws CorruptIndexException, IOException {
-    return open(commit.getDirectory(), deletionPolicy, commit, false, DEFAULT_TERMS_INDEX_DIVISOR,
null);
-  }
-
   /** Expert: returns an IndexReader reading the index in
    *  the given Directory, using a specific commit and with
    *  a custom {@link IndexDeletionPolicy}.  You should pass
@@ -466,38 +438,6 @@
   }
 
   /**
-   * Returns the time the index in the named directory was last modified.
-   * Do not use this to check whether the reader is still up-to-date, use
-   * {@link #isCurrent()} instead. 
-   * @throws CorruptIndexException if the index is corrupt
-   * @throws IOException if there is a low-level IO error
-   * @deprecated Use {@link #lastModified(Directory)} instead.
-   *             This method will be removed in the 3.0 release.
-   */
-  public static long lastModified(String directory) throws CorruptIndexException, IOException
{
-    return lastModified(new File(directory));
-  }
-
-  /**
-   * Returns the time the index in the named directory was last modified. 
-   * Do not use this to check whether the reader is still up-to-date, use
-   * {@link #isCurrent()} instead. 
-   * @throws CorruptIndexException if the index is corrupt
-   * @throws IOException if there is a low-level IO error
-   * @deprecated Use {@link #lastModified(Directory)} instead.
-   *             This method will be removed in the 3.0 release.
-   * 
-   */
-  public static long lastModified(File fileDirectory) throws CorruptIndexException, IOException
{
-    Directory dir = FSDirectory.open(fileDirectory); // use new static method here
-    try {
-      return lastModified(dir);
-    } finally {
-      dir.close();
-    }
-  }
-
-  /**
    * Returns the time the index in the named directory was last modified. 
    * Do not use this to check whether the reader is still up-to-date, use
    * {@link #isCurrent()} instead. 
@@ -585,6 +525,7 @@
     throw new UnsupportedOperationException("This reader does not support this method.");
   }
 
+
   /**
    * Check whether any new changes have occurred to the
    * index since this reader was opened.
@@ -609,7 +550,7 @@
    * changes.&lt;/p&gt;
    *
    * @throws CorruptIndexException if the index is corrupt
-   * @throws IOException if there is a low-level IO error
+   * @throws IOException           if there is a low-level IO error
    * @throws UnsupportedOperationException unless overridden in subclass
    */
   public boolean isCurrent() throws CorruptIndexException, IOException {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887209 - in /lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs: pulsing/ sep/ standard/</title>
<author><name>markrmiller@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091204143058.8B71A2388962@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204143058-8B71A2388962@eris-apache-org%3e</id>
<updated>2009-12-04T14:30:56Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: markrmiller
Date: Fri Dec  4 14:30:54 2009
New Revision: 887209

URL: http://svn.apache.org/viewvc?rev=887209&amp;view=rev
Log:
LUCENE-1458: (flex branch) update term cache to use shared double barrel LRU

Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsProducer.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java?rev=887209&amp;r1=887208&amp;r2=887209&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
Fri Dec  4 14:30:54 2009
@@ -310,8 +310,8 @@
     }
 
     @Override
-    public CacheEntry captureState(CacheEntry reusableState) throws IOException {
-      CacheEntry cacheEntry = wrappedReader.captureState(reusableState);
+    public CacheEntry captureState() throws IOException {
+      CacheEntry cacheEntry = wrappedReader.captureState();
       cacheEntry.docs = new Document[docs.length];
       for(int i = 0; i &lt; docs.length; i++) {
         cacheEntry.docs[i] = (Document) docs[i].clone();

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java?rev=887209&amp;r1=887208&amp;r2=887209&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
Fri Dec  4 14:30:54 2009
@@ -547,13 +547,8 @@
 
     // nocommit: rought start
     @Override
-      public CacheEntry captureState(CacheEntry reusableState) throws IOException {
-      TermDictsReaderState state;
-      if (reusableState == null) {
-        state = new TermDictsReaderState();
-      } else {
-        state = (TermDictsReaderState) reusableState;
-      }
+    public CacheEntry captureState() throws IOException {
+      TermDictsReaderState state = new TermDictsReaderState();
       if (posReader != null) {
         state.posIndexState = posReader.posIndex.captureState();
         state.payloadOffset = posReader.payloadOffset;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsProducer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsProducer.java?rev=887209&amp;r1=887208&amp;r2=887209&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsProducer.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsProducer.java
Fri Dec  4 14:30:54 2009
@@ -42,8 +42,7 @@
     /** Returns a docs enum for the last term read */
     public abstract DocsEnum docs(Bits deletedDocs) throws IOException;
     
-    // nocommit: fooling around with reusable
-    public abstract CacheEntry captureState(CacheEntry reusableState) throws IOException;
+    public abstract CacheEntry captureState() throws IOException;
     
     public abstract void setState(CacheEntry state, int docFreq) throws IOException;
     

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java?rev=887209&amp;r1=887208&amp;r2=887209&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardDocsReader.java
Fri Dec  4 14:30:54 2009
@@ -177,13 +177,8 @@
     }
     
     @Override
-    public CacheEntry captureState(CacheEntry reusableState) {
-      TermDictsReaderState state;
-      if (reusableState == null) {
-        state = new TermDictsReaderState();
-      } else {
-        state = (TermDictsReaderState) reusableState;
-      }
+    public CacheEntry captureState() {
+      TermDictsReaderState state = new TermDictsReaderState();
       if (posReader != null) {
         state.proxOffset = posReader.proxOffset;
       } else {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java?rev=887209&amp;r1=887208&amp;r2=887209&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
Fri Dec  4 14:30:54 2009
@@ -20,8 +20,6 @@
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
 import java.util.TreeMap;
 
 import org.apache.lucene.index.DocsEnum;
@@ -40,6 +38,8 @@
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.CloseableThreadLocal;
+import org.apache.lucene.util.cache.Cache;
+import org.apache.lucene.util.cache.DoubleBarrelLRUCache;
 
 /** Handles a terms dict, but defers all details of postings
  *  reading to an instance of {@TermsDictDocsReader}. This
@@ -58,7 +58,7 @@
   private StandardTermsIndexReader indexReader;
 
   private final TermRef.Comparator termComp;
-
+  
   public StandardTermsDictReader(StandardTermsIndexReader indexReader, Directory dir, FieldInfos
fieldInfos, String segment, StandardDocsProducer docs, int readBufferSize,
                                  TermRef.Comparator termComp)
     throws IOException {
@@ -216,6 +216,9 @@
     final FieldInfo fieldInfo;
     final long termsStartPointer;
     final StandardTermsIndexReader.FieldReader indexReader;
+    private final static int DEFAULT_CACHE_SIZE = 1024;
+    // Used for caching the least recently looked-up Terms
+    private final Cache&lt;TermRef,CacheEntry&gt; termsCache = new DoubleBarrelLRUCache&lt;TermRef,CacheEntry&gt;(DEFAULT_CACHE_SIZE);
 
     FieldReader(StandardTermsIndexReader.FieldReader fieldIndexReader, FieldInfo fieldInfo,
long numTerms, long termsStartPointer) {
       assert numTerms &gt; 0;
@@ -266,7 +269,7 @@
       ThreadResources resources = (ThreadResources) threadResources.get();
       if (resources == null) {
         // Cache does not have to be thread-safe, it is only used by one thread at the same
time
-        resources = new ThreadResources(new SegmentTermsEnum(), numTerms);
+        resources = new ThreadResources(new SegmentTermsEnum());
         threadResources.set(resources);
       }
       return resources;
@@ -317,15 +320,11 @@
       @Override
       public SeekStatus seek(TermRef term) throws IOException {
 
-        ReuseLRUCache&lt;TermRef, CacheEntry&gt; cache = null;
         CacheEntry entry = null;
         TermRef entryKey = null;
 
         if (docs.canCaptureState()) {
-          final ThreadResources resources = getThreadResources();
-          cache = resources.cache;
-
-          entry = cache.get(term);
+          entry = termsCache.get(term);
           if (entry != null) {
             docFreq = entry.freq;
             bytesReader.term.copy(term);
@@ -412,21 +411,13 @@
             // does 
             if (docs.canCaptureState()) {
               // Store in cache
-              if (cache.eldest != null) {
-                entry = cache.eldest;
-                cache.eldest = null;
-                docs.captureState(entry);
-                entryKey = cache.eldestKey;
-                entryKey.copy(bytesReader.term);
-              } else {
-                entry = docs.captureState(null);
-                entryKey = (TermRef) bytesReader.term.clone();
-              }
+              entry = docs.captureState();
+              entryKey = (TermRef) bytesReader.term.clone();
               entry.freq = docFreq;
               entry.termUpTo = termUpto;
               entry.filePointer = in.getFilePointer();
             
-              cache.put(entryKey, entry);
+              termsCache.put(entryKey, entry);
             }
             return SeekStatus.FOUND;
           } else if (cmp &gt; 0) {
@@ -558,64 +549,15 @@
     public Document docs[];
     public boolean pendingIndexTerm;
   }
-
-  private static final int MAX_CACHE_SIZE = 1024;
   
   /**
    * Per-thread resources managed by ThreadLocal
    */
   private static final class ThreadResources {
-    // Used for caching the least recently looked-up Terms
-    final ReuseLRUCache&lt;TermRef, CacheEntry&gt; cache;
     final TermsEnum termsEnum;
 
-    ThreadResources(TermsEnum termsEnum, long numTerms) {
-      final int cacheSize;
-      if (numTerms &gt;= MAX_CACHE_SIZE) {
-        cacheSize = MAX_CACHE_SIZE;
-      } else if (numTerms &lt; 1) {
-        cacheSize = 1;
-      } else {
-        cacheSize = (int) numTerms;
-      }
-
-      cache = new ReuseLRUCache&lt;TermRef, CacheEntry&gt;(cacheSize);
+    ThreadResources(TermsEnum termsEnum) {
       this.termsEnum = termsEnum;
     }
   }
-
-  // nocommit -- must cutover to DBLRU
-  private static class ReuseLRUCache&lt;K,V&gt; extends LinkedHashMap&lt;K, V&gt; {
-
-    /**
-     * 
-     */
-    private static final long serialVersionUID = 1L;
-    private final static float LOADFACTOR = 0.75f;
-    private int cacheSize;
-    V eldest;
-    K eldestKey;
-
-    /**
-     * Creates a last-recently-used cache with the specified size.
-     */
-    public ReuseLRUCache(int cacheSize) {
-      // TODO: -- we should not init cache w/ full
-      // capacity? init it at 0, and only start evicting
-      // once #entries is over our max
-      super((int) Math.ceil(cacheSize / LOADFACTOR) + 1, LOADFACTOR, true);
-      this.cacheSize = cacheSize;
-    }
-
-    @Override
-    protected boolean removeEldestEntry(Map.Entry&lt;K, V&gt; eldest) {
-      boolean remove = size() &gt; ReuseLRUCache.this.cacheSize;
-      if (remove) {
-        this.eldest = eldest.getValue();
-        this.eldestKey = eldest.getKey();
-      }
-      return remove;
-    }
-  }
-
 }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887191 - in /lucene/java/branches/flex_1458: contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/ contrib/collation/src/test/org/apache/lucene/collation/ src/test/org/apache/lucene/index/</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091204134220.4A8202388893@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204134220-4A8202388893@eris-apache-org%3e</id>
<updated>2009-12-04T13:42:20Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Fri Dec  4 13:42:19 2009
New Revision: 887191

URL: http://svn.apache.org/viewvc?rev=887191&amp;view=rev
Log:
LUCENE-2111: re-enable tests I had accidentally xxx'd

Modified:
    lucene/java/branches/flex_1458/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
    lucene/java/branches/flex_1458/contrib/collation/src/test/org/apache/lucene/collation/TestICUCollationKeyAnalyzer.java
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestLazyProxSkipping.java

Modified: lucene/java/branches/flex_1458/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java?rev=887191&amp;r1=887190&amp;r2=887191&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
(original)
+++ lucene/java/branches/flex_1458/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
Fri Dec  4 13:42:19 2009
@@ -65,7 +65,7 @@
   /**
    * Test index creation logic
    */
-  public void xxxtestIndexAndSearchTasks() throws Exception {
+  public void testIndexAndSearchTasks() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "ResetSystemErase",
@@ -100,7 +100,7 @@
   /**
    * Test timed sequence task.
    */
-  public void xxxtestTimedSearchTask() throws Exception {
+  public void testTimedSearchTask() throws Exception {
     String algLines[] = {
         "log.step=100000",
         "ResetSystemErase",
@@ -181,7 +181,7 @@
     ir.close();
   }
 
-  public void xxxtestHighlightingTV() throws Exception {
+  public void testHighlightingTV() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "doc.stored=true",//doc storage is required in order to have text to highlight
@@ -220,7 +220,7 @@
     ir.close();
   }
 
-  public void xxxtestHighlightingNoTvNoStore() throws Exception {
+  public void testHighlightingNoTvNoStore() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "doc.stored=false",
@@ -253,7 +253,7 @@
   /**
    * Test Exhasting Doc Maker logic
    */
-  public void xxxtestExhaustContentSource() throws Exception {
+  public void testExhaustContentSource() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "# ----- properties ",
@@ -332,7 +332,7 @@
   /**
    * Test Parallel Doc Maker logic (for LUCENE-940)
    */
-  public void xxxtestParallelDocMaker() throws Exception {
+  public void testParallelDocMaker() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "# ----- properties ",
@@ -363,7 +363,7 @@
   /**
    * Test WriteLineDoc and LineDocSource.
    */
-  public void xxxtestLineDocFile() throws Exception {
+  public void testLineDocFile() throws Exception {
     File lineFile = new File(System.getProperty("tempDir"), "test.reuters.lines.txt");
 
     // We will call WriteLineDocs this many times
@@ -422,7 +422,7 @@
   /**
    * Test ReadTokensTask
    */
-  public void xxxtestReadTokens() throws Exception {
+  public void testReadTokens() throws Exception {
 
     // We will call ReadTokens on this many docs
     final int NUM_DOCS = 20;
@@ -481,7 +481,7 @@
   /**
    * Test that " {[AddDoc(4000)]: 4} : * " works corrcetly (for LUCENE-941)
    */
-  public void xxxtestParallelExhausted() throws Exception {
+  public void testParallelExhausted() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "# ----- properties ",
@@ -544,7 +544,7 @@
   /**
    * Test that exhaust in loop works as expected (LUCENE-1115).
    */
-  public void xxxtestExhaustedLooped() throws Exception {
+  public void testExhaustedLooped() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "# ----- properties ",
@@ -579,7 +579,7 @@
   /**
    * Test that we can close IndexWriter with argument "false".
    */
-  public void xxxtestCloseIndexFalse() throws Exception {
+  public void testCloseIndexFalse() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "# ----- properties ",
@@ -624,7 +624,7 @@
   /**
    * Test that we can set merge scheduler".
    */
-  public void xxxtestMergeScheduler() throws Exception {
+  public void testMergeScheduler() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "# ----- properties ",
@@ -668,7 +668,7 @@
   /**
    * Test that we can set merge policy".
    */
-  public void xxxtestMergePolicy() throws Exception {
+  public void testMergePolicy() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "# ----- properties ",
@@ -707,7 +707,7 @@
   /**
    * Test that IndexWriter settings stick.
    */
-  public void xxxtestIndexWriterSettings() throws Exception {
+  public void testIndexWriterSettings() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "# ----- properties ",
@@ -752,7 +752,7 @@
   /**
    * Test that we can call optimize(maxNumSegments).
    */
-  public void xxxtestOptimizeMaxNumSegments() throws Exception {
+  public void testOptimizeMaxNumSegments() throws Exception {
     // 1. alg definition (required in every "logic" test)
     String algLines[] = {
         "# ----- properties ",
@@ -799,7 +799,7 @@
   /**
    * Test disabling task count (LUCENE-1136).
    */
-  public void xxxtestDisableCounting() throws Exception {
+  public void testDisableCounting() throws Exception {
     doTestDisableCounting(true);
     doTestDisableCounting(false);
   }

Modified: lucene/java/branches/flex_1458/contrib/collation/src/test/org/apache/lucene/collation/TestICUCollationKeyAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/collation/src/test/org/apache/lucene/collation/TestICUCollationKeyAnalyzer.java?rev=887191&amp;r1=887190&amp;r2=887191&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/collation/src/test/org/apache/lucene/collation/TestICUCollationKeyAnalyzer.java
(original)
+++ lucene/java/branches/flex_1458/contrib/collation/src/test/org/apache/lucene/collation/TestICUCollationKeyAnalyzer.java
Fri Dec  4 13:42:19 2009
@@ -43,17 +43,17 @@
     testFarsiQueryParserCollating(analyzer);
   }
   
-  public void xxxtestFarsiRangeFilterCollating() throws Exception {
+  public void testFarsiRangeFilterCollating() throws Exception {
     testFarsiRangeFilterCollating(analyzer, firstRangeBeginning, firstRangeEnd, 
                                   secondRangeBeginning, secondRangeEnd);
   }
  
-  public void xxxtestFarsiRangeQueryCollating() throws Exception {
+  public void testFarsiRangeQueryCollating() throws Exception {
     testFarsiRangeQueryCollating(analyzer, firstRangeBeginning, firstRangeEnd, 
                                  secondRangeBeginning, secondRangeEnd);
   }
 
-  public void xxxtestFarsiTermRangeQuery() throws Exception {
+  public void testFarsiTermRangeQuery() throws Exception {
     testFarsiTermRangeQuery
       (analyzer, firstRangeBeginning, firstRangeEnd, 
        secondRangeBeginning, secondRangeEnd);
@@ -65,7 +65,7 @@
   // Copied (and slightly modified) from 
   // org.apache.lucene.search.TestSort.testInternationalSort()
   //  
-  public void xxxtestCollationKeySort() throws Exception {
+  public void testCollationKeySort() throws Exception {
     Analyzer usAnalyzer = new ICUCollationKeyAnalyzer
       (Collator.getInstance(Locale.US));
     Analyzer franceAnalyzer = new ICUCollationKeyAnalyzer

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestLazyProxSkipping.java?rev=887191&amp;r1=887190&amp;r2=887191&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
(original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
Fri Dec  4 13:42:19 2009
@@ -117,7 +117,7 @@
         performTest(10);
     }
     
-    public void xxxtestSeek() throws IOException {
+    public void testSeek() throws IOException {
         Directory directory = new RAMDirectory();
         IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
         for (int i = 0; i &lt; 10; i++) {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887181 [2/2] - in /lucene/java/trunk: ./ src/java/org/apache/lucene/index/ src/java/org/apache/lucene/search/ src/java/org/apache/lucene/util/ src/test/org/apache/lucene/ src/test/org/apache/lucene/analysis/ src/test/org/apache/lucene/anal...</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091204130809.7905323889DA@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204130809-7905323889DA@eris-apache-org%3e</id>
<updated>2009-12-04T13:08:04Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java Fri Dec  4 13:07:47 2009
@@ -25,7 +25,6 @@
 import java.util.SortedSet;
 
 import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
@@ -258,13 +257,13 @@
     assertTrue(reader != null);
     SortedTermVectorMapper mapper = new SortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
     reader.get(0, mapper);
-    SortedSet set = mapper.getTermVectorEntrySet();
+    SortedSet&lt;TermVectorEntry&gt; set = mapper.getTermVectorEntrySet();
     assertTrue("set is null and it shouldn't be", set != null);
     //three fields, 4 terms, all terms are the same
     assertTrue("set Size: " + set.size() + " is not: " + 4, set.size() == 4);
     //Check offsets and positions
-    for (Iterator iterator = set.iterator(); iterator.hasNext();) {
-      TermVectorEntry tve = (TermVectorEntry) iterator.next();
+    for (Iterator&lt;TermVectorEntry&gt; iterator = set.iterator(); iterator.hasNext();) {
+      TermVectorEntry tve =  iterator.next();
       assertTrue("tve is null and it shouldn't be", tve != null);
       assertTrue("tve.getOffsets() is null and it shouldn't be", tve.getOffsets() != null);
       assertTrue("tve.getPositions() is null and it shouldn't be", tve.getPositions() != null);
@@ -278,8 +277,8 @@
     //three fields, 4 terms, all terms are the same
     assertTrue("set Size: " + set.size() + " is not: " + 4, set.size() == 4);
     //Should have offsets and positions b/c we are munging all the fields together
-    for (Iterator iterator = set.iterator(); iterator.hasNext();) {
-      TermVectorEntry tve = (TermVectorEntry) iterator.next();
+    for (Iterator&lt;TermVectorEntry&gt; iterator = set.iterator(); iterator.hasNext();) {
+      TermVectorEntry tve = iterator.next();
       assertTrue("tve is null and it shouldn't be", tve != null);
       assertTrue("tve.getOffsets() is null and it shouldn't be", tve.getOffsets() != null);
       assertTrue("tve.getPositions() is null and it shouldn't be", tve.getPositions() != null);
@@ -289,14 +288,12 @@
 
     FieldSortedTermVectorMapper fsMapper = new FieldSortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
     reader.get(0, fsMapper);
-    Map map = fsMapper.getFieldToTerms();
+    Map&lt;String,SortedSet&lt;TermVectorEntry&gt;&gt; map = fsMapper.getFieldToTerms();
     assertTrue("map Size: " + map.size() + " is not: " + testFields.length, map.size() == testFields.length);
-    for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
-      Map.Entry entry = (Map.Entry) iterator.next();
-      SortedSet sortedSet = (SortedSet) entry.getValue();
+    for (Map.Entry&lt;String,SortedSet&lt;TermVectorEntry&gt;&gt; entry : map.entrySet()) {
+      SortedSet&lt;TermVectorEntry&gt; sortedSet =  entry.getValue();
       assertTrue("sortedSet Size: " + sortedSet.size() + " is not: " + 4, sortedSet.size() == 4);
-      for (Iterator inner = sortedSet.iterator(); inner.hasNext();) {
-        TermVectorEntry tve = (TermVectorEntry) inner.next();
+      for (final TermVectorEntry tve : sortedSet) {
         assertTrue("tve is null and it shouldn't be", tve != null);
         //Check offsets and positions.
         assertTrue("tve is null and it shouldn't be", tve != null);
@@ -320,12 +317,10 @@
     reader.get(0, fsMapper);
     map = fsMapper.getFieldToTerms();
     assertTrue("map Size: " + map.size() + " is not: " + testFields.length, map.size() == testFields.length);
-    for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
-      Map.Entry entry = (Map.Entry) iterator.next();
-      SortedSet sortedSet = (SortedSet) entry.getValue();
+    for (final Map.Entry&lt;String,SortedSet&lt;TermVectorEntry&gt;&gt; entry : map.entrySet()) {
+      SortedSet&lt;TermVectorEntry&gt; sortedSet =  entry.getValue();
       assertTrue("sortedSet Size: " + sortedSet.size() + " is not: " + 4, sortedSet.size() == 4);
-      for (Iterator inner = sortedSet.iterator(); inner.hasNext();) {
-        TermVectorEntry tve = (TermVectorEntry) inner.next();
+      for (final TermVectorEntry tve : sortedSet) {
         assertTrue("tve is null and it shouldn't be", tve != null);
         //Check offsets and positions.
         assertTrue("tve is null and it shouldn't be", tve != null);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactionRollback.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactionRollback.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactionRollback.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactionRollback.java Fri Dec  4 13:07:47 2009
@@ -54,12 +54,12 @@
     // System.out.println("Attempting to rollback to "+id);
     String ids="-"+id;
     IndexCommit last=null;
-    Collection commits = IndexReader.listCommits(dir);
-    for (Iterator iterator = commits.iterator(); iterator.hasNext();) {
-      IndexCommit commit = (IndexCommit) iterator.next();
-      Map ud=commit.getUserData();
+    Collection&lt;IndexCommit&gt; commits = IndexReader.listCommits(dir);
+    for (Iterator&lt;IndexCommit&gt; iterator = commits.iterator(); iterator.hasNext();) {
+      IndexCommit commit =  iterator.next();
+      Map&lt;String,String&gt; ud=commit.getUserData();
       if (ud.size() &gt; 0)
-        if (((String) ud.get("index")).endsWith(ids))
+        if (ud.get("index").endsWith(ids))
           last=commit;
     }
 
@@ -68,7 +68,7 @@
 		
     IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(),
                                     new RollbackDeletionPolicy(id), MaxFieldLength.UNLIMITED, last);
-    Map data = new HashMap();
+    Map&lt;String,String&gt; data = new HashMap&lt;String,String&gt;();
     data.put("index", "Rolled back to 1-"+id);
     w.commit(data);
     w.close();
@@ -135,7 +135,7 @@
       w.addDocument(doc);
 			
       if (currentRecordId%10 == 0) {
-        Map data = new HashMap();
+        Map&lt;String,String&gt; data = new HashMap&lt;String,String&gt;();
         data.put("index", "records 1-"+currentRecordId);
         w.commit(data);
       }
@@ -152,18 +152,17 @@
       this.rollbackPoint = rollbackPoint;
     }
 
-    public void onCommit(List commits) throws IOException {
+    public void onCommit(List&lt;? extends IndexCommit&gt; commits) throws IOException {
     }
 
-    public void onInit(List commits) throws IOException {
-      for (Iterator iterator = commits.iterator(); iterator.hasNext();) {
-        IndexCommit commit = (IndexCommit) iterator.next();
-        Map userData=commit.getUserData();
+    public void onInit(List&lt;? extends IndexCommit&gt; commits) throws IOException {
+      for (final IndexCommit commit : commits) {
+        Map&lt;String,String&gt; userData=commit.getUserData();
         if (userData.size() &gt; 0) {
           // Label for a commit point is "Records 1-30"
           // This code reads the last id ("30" in this example) and deletes it
           // if it is after the desired rollback point
-          String x = (String) userData.get("index");
+          String x = userData.get("index");
           String lastVal = x.substring(x.lastIndexOf("-")+1);
           int last = Integer.parseInt(lastVal);
           if (last&gt;rollbackPoint) {
@@ -186,10 +185,10 @@
 
   class DeleteLastCommitPolicy implements IndexDeletionPolicy {
 
-    public void onCommit(List commits) throws IOException {}
+    public void onCommit(List&lt;? extends IndexCommit&gt; commits) throws IOException {}
 
-    public void onInit(List commits) throws IOException {
-      ((IndexCommit) commits.get(commits.size()-1)).delete();
+    public void onInit(List&lt;? extends IndexCommit&gt; commits) throws IOException {
+      commits.get(commits.size()-1).delete();
     }
   }
 
@@ -208,7 +207,7 @@
 	
   // Keeps all commit points (used to build index)
   class KeepAllDeletionPolicy implements IndexDeletionPolicy {
-    public void onCommit(List commits) throws IOException {}
-    public void onInit(List commits) throws IOException {}
+    public void onCommit(List&lt;? extends IndexCommit&gt; commits) throws IOException {}
+    public void onInit(List&lt;? extends IndexCommit&gt; commits) throws IOException {}
   }
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactions.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactions.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactions.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactions.java Fri Dec  4 13:07:47 2009
@@ -217,6 +217,6 @@
       threads[i].join();
 
     for(int i=0;i&lt;numThread;i++)
-      assertTrue(!((TimedThread) threads[i]).failed);
+      assertTrue(!threads[i].failed);
   }
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestWordlistLoader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestWordlistLoader.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestWordlistLoader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestWordlistLoader.java Fri Dec  4 13:07:47 2009
@@ -30,22 +30,22 @@
 
   public void testWordlistLoading() throws IOException {
     String s = "ONE\n  two \nthree";
-    HashSet wordSet1 = WordlistLoader.getWordSet(new StringReader(s));
+    HashSet&lt;String&gt; wordSet1 = WordlistLoader.getWordSet(new StringReader(s));
     checkSet(wordSet1);
-    HashSet wordSet2 = WordlistLoader.getWordSet(new BufferedReader(new StringReader(s)));
+    HashSet&lt;String&gt; wordSet2 = WordlistLoader.getWordSet(new BufferedReader(new StringReader(s)));
     checkSet(wordSet2);
   }
 
   public void testComments() throws Exception {
     String s = "ONE\n  two \nthree\n#comment";
-    HashSet wordSet1 = WordlistLoader.getWordSet(new StringReader(s), "#");
+    HashSet&lt;String&gt; wordSet1 = WordlistLoader.getWordSet(new StringReader(s), "#");
     checkSet(wordSet1);
     assertFalse(wordSet1.contains("#comment"));
     assertFalse(wordSet1.contains("comment"));
   }
 
 
-  private void checkSet(HashSet wordset) {
+  private void checkSet(HashSet&lt;String&gt; wordset) {
     assertEquals(3, wordset.size());
     assertTrue(wordset.contains("ONE"));		// case is not modified
     assertTrue(wordset.contains("two"));		// surrounding whitespace is removed

Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java Fri Dec  4 13:07:47 2009
@@ -17,7 +17,6 @@
  * limitations under the License.
  */
 
-import java.io.IOException;
 import java.io.Reader;
 
 import org.apache.lucene.analysis.Analyzer;

Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java Fri Dec  4 13:07:47 2009
@@ -130,7 +130,7 @@
   }
   
   public void testBoostsSimple() throws Exception {
-      Map boosts = new HashMap();
+      Map&lt;String,Float&gt; boosts = new HashMap&lt;String,Float&gt;();
       boosts.put("b", Float.valueOf(5));
       boosts.put("t", Float.valueOf(10));
       String[] fields = {"b", "t"};
@@ -218,7 +218,6 @@
     String[] fields = {"b", "t"};
     //int[] flags = {MultiFieldQueryParser.REQUIRED_FIELD, MultiFieldQueryParser.PROHIBITED_FIELD};
       BooleanClause.Occur[] flags = {BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
-      MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_CURRENT, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
 
     Query q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, "one", fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));//, fields, flags, new StandardAnalyzer());
     assertEquals("+b:one -t:one", q.toString());

Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java Fri Dec  4 13:07:47 2009
@@ -72,7 +72,7 @@
 public class TestQueryParser extends LocalizedTestCase {
 
   public TestQueryParser(String name) {
-    super(name, new HashSet(Arrays.asList(
+    super(name, new HashSet&lt;String&gt;(Arrays.asList(
       "testLegacyDateRange", "testDateRange",
       "testCJK", "testNumber", "testFarsiRangeCollating",
       "testLocalDateFormat"
@@ -798,7 +798,7 @@
 
   public void testBoost()
     throws Exception {
-    Set stopWords = new HashSet(1);
+    Set&lt;Object&gt; stopWords = new HashSet&lt;Object&gt;(1);
     stopWords.add("on");
     StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT, stopWords);
     QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", oneStopAnalyzer);

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/CachingWrapperFilterHelper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/CachingWrapperFilterHelper.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/CachingWrapperFilterHelper.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/CachingWrapperFilterHelper.java Fri Dec  4 13:07:47 2009
@@ -18,7 +18,6 @@
  */
 
 import java.io.IOException;
-import java.util.BitSet;
 import java.util.WeakHashMap;
 
 import junit.framework.TestCase;
@@ -46,11 +45,11 @@
   @Override
   public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
     if (cache == null) {
-      cache = new WeakHashMap();
+      cache = new WeakHashMap&lt;IndexReader,DocIdSet&gt;();
     }
     
     synchronized (cache) {  // check cache
-      DocIdSet cached = (DocIdSet) cache.get(reader);
+      DocIdSet cached = cache.get(reader);
       if (shouldHaveCache) {
         TestCase.assertNotNull("Cache should have data ", cached);
       } else {

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java Fri Dec  4 13:07:47 2009
@@ -45,7 +45,7 @@
     throws IOException {
 
     String d = q.toString(defaultFieldName);
-    Set ignore = new TreeSet();
+    Set&lt;Integer&gt; ignore = new TreeSet&lt;Integer&gt;();
     for (int i = 0; i &lt; results.length; i++) {
       ignore.add(Integer.valueOf(results[i]));
     }
@@ -85,11 +85,11 @@
 
     QueryUtils.check(query,searcher);
     
-    Set correct = new TreeSet();
+    Set&lt;Integer&gt; correct = new TreeSet&lt;Integer&gt;();
     for (int i = 0; i &lt; results.length; i++) {
       correct.add(Integer.valueOf(results[i]));
     }
-    final Set actual = new TreeSet();
+    final Set&lt;Integer&gt; actual = new TreeSet&lt;Integer&gt;();
     final Collector c = new SetCollector(actual);
 
     searcher.search(query, c);
@@ -117,8 +117,8 @@
   }
 
   public static class SetCollector extends Collector {
-    final Set bag;
-    public SetCollector(Set bag) {
+    final Set&lt;Integer&gt; bag;
+    public SetCollector(Set&lt;Integer&gt; bag) {
       this.bag = bag;
     }
     private int base = 0;
@@ -161,12 +161,12 @@
 
     ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
 
-    Set correct = new TreeSet();
+    Set&lt;Integer&gt; correct = new TreeSet&lt;Integer&gt;();
     for (int i = 0; i &lt; results.length; i++) {
       correct.add(Integer.valueOf(results[i]));
     }
 
-    Set actual = new TreeSet();
+    Set&lt;Integer&gt; actual = new TreeSet&lt;Integer&gt;();
     for (int i = 0; i &lt; hits.length; i++) {
       actual.add(Integer.valueOf(hits[i].doc));
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java Fri Dec  4 13:07:47 2009
@@ -419,9 +419,9 @@
     }    
   }
 
-  static final class JustCompileTopDocsCollector extends TopDocsCollector {
+  static final class JustCompileTopDocsCollector extends TopDocsCollector&lt;ScoreDoc&gt; {
 
-    protected JustCompileTopDocsCollector(PriorityQueue pq) {
+    protected JustCompileTopDocsCollector(PriorityQueue&lt;ScoreDoc&gt; pq) {
       super(pq);
     }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/QueryUtils.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/QueryUtils.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/QueryUtils.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/QueryUtils.java Fri Dec  4 13:07:47 2009
@@ -352,7 +352,7 @@
 
         List&lt;IndexReader&gt; readerList = new ArrayList&lt;IndexReader&gt;();
         ReaderUtil.gatherSubReaders(readerList, s.getIndexReader());
-        IndexReader[] readers = (IndexReader[]) readerList.toArray(new IndexReader[0]);
+        IndexReader[] readers =  readerList.toArray(new IndexReader[0]);
         for(int i = 0; i &lt; readers.length; i++) {
           IndexReader reader = readers[i];
           Weight w = q.weight(s);
@@ -413,7 +413,7 @@
     
     List&lt;IndexReader&gt; readerList = new ArrayList&lt;IndexReader&gt;();
     ReaderUtil.gatherSubReaders(readerList, s.getIndexReader());
-    IndexReader[] readers = (IndexReader[]) readerList.toArray(new IndexReader[0]);
+    IndexReader[] readers = readerList.toArray(new IndexReader[0]);
     for(int i = 0; i &lt; readers.length; i++) {
       IndexReader reader = readers[i];
       Weight w = q.weight(s);

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestComplexExplanationsOfNonMatches.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestComplexExplanationsOfNonMatches.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestComplexExplanationsOfNonMatches.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestComplexExplanationsOfNonMatches.java Fri Dec  4 13:07:47 2009
@@ -18,24 +18,6 @@
  */
 
 
-import org.apache.lucene.store.RAMDirectory;
-
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-
-import org.apache.lucene.analysis.WhitespaceAnalyzer;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-
-import junit.framework.TestCase;
-
-import java.util.Random;
-import java.util.BitSet;
 
 /**
  * subclass of TestSimpleExplanations that verifies non matches.

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java Fri Dec  4 13:07:47 2009
@@ -153,7 +153,7 @@
       // make a query without sorting first
     ScoreDoc[] hitsByRank = searcher.search(query, null, 1000).scoreDocs;
     checkHits(hitsByRank, "Sort by rank: "); // check for duplicates
-        Map resultMap = new TreeMap();
+        Map&lt;Integer,Integer&gt; resultMap = new TreeMap&lt;Integer,Integer&gt;();
         // store hits in TreeMap - TreeMap does not allow duplicates; existing entries are silently overwritten
         for(int hitid=0;hitid&lt;hitsByRank.length; ++hitid) {
             resultMap.put(
@@ -190,7 +190,7 @@
    */
     private void checkHits(ScoreDoc[] hits, String prefix) {
         if(hits!=null) {
-            Map idMap = new TreeMap();
+            Map&lt;Integer,Integer&gt; idMap = new TreeMap&lt;Integer,Integer&gt;();
             for(int docnum=0;docnum&lt;hits.length;++docnum) {
                 Integer luceneId = null;
 
@@ -200,7 +200,7 @@
                     message.append("Duplicate key for hit index = ");
                     message.append(docnum);
                     message.append(", previous index = ");
-                    message.append(((Integer)idMap.get(luceneId)).toString());
+                    message.append((idMap.get(luceneId)).toString());
                     message.append(", Lucene ID = ");
                     message.append(luceneId);
                     log(message.toString());

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestDocIdSet.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestDocIdSet.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestDocIdSet.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestDocIdSet.java Fri Dec  4 13:07:47 2009
@@ -77,7 +77,7 @@
       };
 	  
     DocIdSetIterator iter = filteredSet.iterator();
-    ArrayList/*&lt;Integer&gt;*/ list = new ArrayList/*&lt;Integer&gt;*/();
+    ArrayList&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
     int doc = iter.advance(3);
     if (doc != DocIdSetIterator.NO_MORE_DOCS) {
       list.add(Integer.valueOf(doc));
@@ -88,9 +88,9 @@
 	  
     int[] docs = new int[list.size()];
     int c=0;
-    Iterator/*&lt;Integer&gt;*/ intIter = list.iterator();
+    Iterator&lt;Integer&gt; intIter = list.iterator();
     while(intIter.hasNext()) {
-      docs[c++] = ((Integer) intIter.next()).intValue();
+      docs[c++] = intIter.next().intValue();
     }
     int[] answer = new int[]{4,6,8};
     boolean same = Arrays.equals(answer, docs);

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java Fri Dec  4 13:07:47 2009
@@ -30,7 +30,7 @@
 
 public class TestElevationComparator extends LuceneTestCase {
 
-  private final Map/*&lt;String, Integer&gt;*/ priority = new HashMap/*&lt;String, Integer&gt;*/();
+  private final Map&lt;String,Integer&gt; priority = new HashMap&lt;String,Integer&gt;();
 
   //@Test
   public void testSorting() throws Throwable {
@@ -126,9 +126,9 @@
 }
 
 class ElevationComparatorSource extends FieldComparatorSource {
-  private final Map/*&lt;String, Integer&gt;*/ priority;
+  private final Map&lt;String,Integer&gt; priority;
 
-  public ElevationComparatorSource(final Map/*&lt;String, Integer&gt;*/ boosts) {
+  public ElevationComparatorSource(final Map&lt;String,Integer&gt; boosts) {
    this.priority = boosts;
   }
 
@@ -152,7 +152,7 @@
 
      private int docVal(int doc) throws IOException {
        String id = idIndex.lookup[idIndex.order[doc]];
-       Integer prio = (Integer) priority.get(id);
+       Integer prio = priority.get(id);
        return prio == null ? 0 : prio.intValue();
      }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java Fri Dec  4 13:07:47 2009
@@ -18,8 +18,7 @@
  */
 
 import java.io.IOException;
-import java.text.Collator;
-import java.util.Locale;
+
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
@@ -66,7 +65,7 @@
     Query q = new TermQuery(new Term("body","body"));
 
     // test id, bounded on both ends
-    FieldCacheRangeFilter fcrf;
+    FieldCacheRangeFilter&lt;String&gt; fcrf;
     result = search.search(q,fcrf = FieldCacheRangeFilter.newStringRange("id",minIP,maxIP,T,T), numDocs).scoreDocs;
     assertTrue(fcrf.getDocIdSet(reader.getSequentialSubReaders()[0]).isCacheable());
     assertEquals("find all", numDocs, result.length);
@@ -213,7 +212,7 @@
     Query q = new TermQuery(new Term("body","body"));
 
     // test id, bounded on both ends
-    FieldCacheRangeFilter fcrf;
+    FieldCacheRangeFilter&lt;Short&gt; fcrf;
     result = search.search(q,fcrf=FieldCacheRangeFilter.newShortRange("id",minIdO,maxIdO,T,T), numDocs).scoreDocs;
     assertTrue(fcrf.getDocIdSet(reader.getSequentialSubReaders()[0]).isCacheable());
     assertEquals("find all", numDocs, result.length);
@@ -305,7 +304,7 @@
 
     // test id, bounded on both ends
         
-    FieldCacheRangeFilter fcrf;
+    FieldCacheRangeFilter&lt;Integer&gt; fcrf;
     result = search.search(q,fcrf=FieldCacheRangeFilter.newIntRange("id",minIdO,maxIdO,T,T), numDocs).scoreDocs;
     assertTrue(fcrf.getDocIdSet(reader.getSequentialSubReaders()[0]).isCacheable());
     assertEquals("find all", numDocs, result.length);
@@ -397,7 +396,7 @@
 
     // test id, bounded on both ends
         
-    FieldCacheRangeFilter fcrf;
+    FieldCacheRangeFilter&lt;Long&gt; fcrf;
     result = search.search(q,fcrf=FieldCacheRangeFilter.newLongRange("id",minIdO,maxIdO,T,T), numDocs).scoreDocs;
     assertTrue(fcrf.getDocIdSet(reader.getSequentialSubReaders()[0]).isCacheable());
     assertEquals("find all", numDocs, result.length);
@@ -550,7 +549,7 @@
     assertTrue(reader.hasDeletions());
 
     ScoreDoc[] result;
-    FieldCacheRangeFilter fcrf;
+    FieldCacheRangeFilter&lt;Byte&gt; fcrf;
     Query q = new TermQuery(new Term("body","body"));
 
     result = search.search(q,fcrf=FieldCacheRangeFilter.newByteRange("id",Byte.valueOf((byte) -20),Byte.valueOf((byte) 20),T,T), 100).scoreDocs;

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java Fri Dec  4 13:07:47 2009
@@ -54,20 +54,20 @@
     ScoreDoc[] results;
     MatchAllDocsQuery q = new MatchAllDocsQuery();
 
-    List terms = new ArrayList();
+    List&lt;String&gt; terms = new ArrayList&lt;String&gt;();
     terms.add("5");
-    results = searcher.search(q, new FieldCacheTermsFilter(fieldName, (String[]) terms.toArray(new String[0])), numDocs).scoreDocs;
+    results = searcher.search(q, new FieldCacheTermsFilter(fieldName,  terms.toArray(new String[0])), numDocs).scoreDocs;
     assertEquals("Must match nothing", 0, results.length);
 
-    terms = new ArrayList();
+    terms = new ArrayList&lt;String&gt;();
     terms.add("10");
-    results = searcher.search(q, new FieldCacheTermsFilter(fieldName, (String[]) terms.toArray(new String[0])), numDocs).scoreDocs;
+    results = searcher.search(q, new FieldCacheTermsFilter(fieldName,  terms.toArray(new String[0])), numDocs).scoreDocs;
     assertEquals("Must match 1", 1, results.length);
 
-    terms = new ArrayList();
+    terms = new ArrayList&lt;String&gt;();
     terms.add("10");
     terms.add("20");
-    results = searcher.search(q, new FieldCacheTermsFilter(fieldName, (String[]) terms.toArray(new String[0])), numDocs).scoreDocs;
+    results = searcher.search(q, new FieldCacheTermsFilter(fieldName,  terms.toArray(new String[0])), numDocs).scoreDocs;
     assertEquals("Must match 2", 2, results.length);
 
     reader.close();

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java Fri Dec  4 13:07:47 2009
@@ -17,7 +17,6 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermEnum;
 import org.apache.lucene.index.IndexReader;
@@ -31,7 +30,6 @@
 import org.apache.lucene.util.LuceneTestCase;
 
 import java.io.IOException;
-import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.Collections;
 
@@ -68,7 +66,7 @@
         query1.add(new Term("body", "blueberry"));
         query2.add(new Term("body", "strawberry"));
 
-        LinkedList termsWithPrefix = new LinkedList();
+        LinkedList&lt;Term&gt; termsWithPrefix = new LinkedList&lt;Term&gt;();
         IndexReader ir = IndexReader.open(indexStore, true);
 
         // this TermEnum gives "piccadilly", "pie" and "pizza".
@@ -81,9 +79,9 @@
             }
         } while (te.next());
 
-        query1.add((Term[])termsWithPrefix.toArray(new Term[0]));
+        query1.add(termsWithPrefix.toArray(new Term[0]));
         assertEquals("body:\"blueberry (piccadilly pie pizza)\"", query1.toString());
-        query2.add((Term[])termsWithPrefix.toArray(new Term[0]));
+        query2.add(termsWithPrefix.toArray(new Term[0]));
         assertEquals("body:\"strawberry (piccadilly pie pizza)\"", query2.toString());
 
         ScoreDoc[] result;
@@ -103,7 +101,7 @@
                 termsWithPrefix.add(te.term());
             }
         } while (te.next());
-        query3.add((Term[])termsWithPrefix.toArray(new Term[0]));
+        query3.add(termsWithPrefix.toArray(new Term[0]));
         query3.add(new Term("body", "pizza"));
 
         result = searcher.search(query3, null, 1000).scoreDocs;

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java Fri Dec  4 13:07:47 2009
@@ -253,9 +253,9 @@
     assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 2, document.getFields().size() == 2);
     //Should be one document from each directory
     //they both have two fields, contents and other
-    Set ftl = new HashSet();
+    Set&lt;String&gt; ftl = new HashSet&lt;String&gt;();
     ftl.add("other");
-    SetBasedFieldSelector fs = new SetBasedFieldSelector(ftl, Collections.EMPTY_SET);
+    SetBasedFieldSelector fs = new SetBasedFieldSelector(ftl, Collections. &lt;String&gt; emptySet());
     document = searcher.doc(hits[0].doc, fs);
     assertTrue("document is null and it shouldn't be", document != null);
     assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 1, document.getFields().size() == 1);
@@ -265,7 +265,7 @@
     assertTrue("value is null and it shouldn't be", value != null);
     ftl.clear();
     ftl.add("contents");
-    fs = new SetBasedFieldSelector(ftl, Collections.EMPTY_SET);
+    fs = new SetBasedFieldSelector(ftl, Collections. &lt;String&gt; emptySet());
     document = searcher.doc(hits[1].doc, fs);
     value = document.get("contents");
     assertTrue("value is null and it shouldn't be", value != null);    

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java Fri Dec  4 13:07:47 2009
@@ -76,7 +76,7 @@
         query1.add(new Term("body", "blueberry"));
         query2.add(new Term("body", "strawberry"));
 
-        LinkedList termsWithPrefix = new LinkedList();
+        LinkedList&lt;Term&gt; termsWithPrefix = new LinkedList&lt;Term&gt;();
         IndexReader ir = IndexReader.open(indexStore, true);
 
         // this TermEnum gives "piccadilly", "pie" and "pizza".
@@ -89,8 +89,8 @@
             }
         } while (te.next());
 
-        query1.add((Term[])termsWithPrefix.toArray(new Term[0]));
-        query2.add((Term[])termsWithPrefix.toArray(new Term[0]));
+        query1.add(termsWithPrefix.toArray(new Term[0]));
+        query2.add(termsWithPrefix.toArray(new Term[0]));
 
         ScoreDoc[] result;
         result = searcher.search(query1, null, 1000).scoreDocs;

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java Fri Dec  4 13:07:47 2009
@@ -66,7 +66,7 @@
     }
     
     Scorer s = new SimpleScorer();
-    TopDocsCollector tdc = TopScoreDocCollector.create(scores.length, true);
+    TopDocsCollector&lt;ScoreDoc&gt; tdc = TopScoreDocCollector.create(scores.length, true);
     Collector c = new PositiveScoresOnlyCollector(tdc);
     c.setScorer(s);
     while (s.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestSimpleExplanationsOfNonMatches.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestSimpleExplanationsOfNonMatches.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestSimpleExplanationsOfNonMatches.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestSimpleExplanationsOfNonMatches.java Fri Dec  4 13:07:47 2009
@@ -18,24 +18,7 @@
  */
 
 
-import org.apache.lucene.store.RAMDirectory;
 
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-
-import org.apache.lucene.analysis.WhitespaceAnalyzer;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-
-import junit.framework.TestCase;
-
-import java.util.Random;
-import java.util.BitSet;
 
 /**
  * subclass of TestSimpleExplanations that verifies non matches.

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java Fri Dec  4 13:07:47 2009
@@ -634,9 +634,9 @@
   public void testNormalizedScores() throws Exception {
 
     // capture relevancy scores
-    HashMap scoresX = getScores (full.search (queryX, null, 1000).scoreDocs, full);
-    HashMap scoresY = getScores (full.search (queryY, null, 1000).scoreDocs, full);
-    HashMap scoresA = getScores (full.search (queryA, null, 1000).scoreDocs, full);
+    HashMap&lt;String,Float&gt; scoresX = getScores (full.search (queryX, null, 1000).scoreDocs, full);
+    HashMap&lt;String,Float&gt; scoresY = getScores (full.search (queryY, null, 1000).scoreDocs, full);
+    HashMap&lt;String,Float&gt; scoresA = getScores (full.search (queryA, null, 1000).scoreDocs, full);
 
     // we'll test searching locally, remote and multi
     
@@ -977,9 +977,9 @@
     assertEquals (expectedResult, buff.toString());
   }
 
-  private HashMap getScores (ScoreDoc[] hits, Searcher searcher)
+  private HashMap&lt;String,Float&gt; getScores (ScoreDoc[] hits, Searcher searcher)
   throws IOException {
-    HashMap scoreMap = new HashMap();
+    HashMap&lt;String,Float&gt; scoreMap = new HashMap&lt;String,Float&gt;();
     int n = hits.length;
     for (int i=0; i&lt;n; ++i) {
       Document doc = searcher.doc(hits[i].doc);
@@ -991,15 +991,15 @@
   }
 
   // make sure all the values in the maps match
-  private void assertSameValues (HashMap m1, HashMap m2) {
+  private &lt;K, V&gt; void assertSameValues (HashMap&lt;K,V&gt; m1, HashMap&lt;K,V&gt; m2) {
     int n = m1.size();
     int m = m2.size();
     assertEquals (n, m);
-    Iterator iter = m1.keySet().iterator();
+    Iterator&lt;K&gt; iter = m1.keySet().iterator();
     while (iter.hasNext()) {
-      Object key = iter.next();
-      Object o1 = m1.get(key);
-      Object o2 = m2.get(key);
+      K key = iter.next();
+      V o1 = m1.get(key);
+      V o2 = m2.get(key);
       if (o1 instanceof Float) {
         assertEquals(((Float)o1).floatValue(), ((Float)o2).floatValue(), 1e-6);
       } else {

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestSpanQueryFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestSpanQueryFilter.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestSpanQueryFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestSpanQueryFilter.java Fri Dec  4 13:07:47 2009
@@ -16,7 +16,6 @@
  * limitations under the License.
  */
 
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.lucene.analysis.SimpleAnalyzer;
@@ -58,12 +57,11 @@
     DocIdSet docIdSet = result.getDocIdSet();
     assertTrue("docIdSet is null and it shouldn't be", docIdSet != null);
     assertContainsDocId("docIdSet doesn't contain docId 10", docIdSet, 10);
-    List spans = result.getPositions();
+    List&lt;SpanFilterResult.PositionInfo&gt; spans = result.getPositions();
     assertTrue("spans is null and it shouldn't be", spans != null);
     int size = getDocIdSetSize(docIdSet);
     assertTrue("spans Size: " + spans.size() + " is not: " + size, spans.size() == size);
-    for (Iterator iterator = spans.iterator(); iterator.hasNext();) {
-       SpanFilterResult.PositionInfo info = (SpanFilterResult.PositionInfo) iterator.next();
+    for (final SpanFilterResult.PositionInfo info: spans) {
       assertTrue("info is null and it shouldn't be", info != null);
       //The doc should indicate the bit is on
       assertContainsDocId("docIdSet doesn't contain docId " + info.getDoc(), docIdSet, info.getDoc());

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestTermRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestTermRangeQuery.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestTermRangeQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestTermRangeQuery.java Fri Dec  4 13:07:47 2009
@@ -21,7 +21,6 @@
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.Term;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenStream;

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java Fri Dec  4 13:07:47 2009
@@ -76,7 +76,7 @@
                                        indexReader.termDocs(allTerm), indexSearcher.getSimilarity(),
                                        indexReader.norms(FIELD));
         //we have 2 documents with the term all in them, one document for all the other values
-        final List docs = new ArrayList();
+        final List&lt;TestHit&gt; docs = new ArrayList&lt;TestHit&gt;();
         //must call next first
 
 
@@ -107,8 +107,8 @@
             }
         });
         assertTrue("docs Size: " + docs.size() + " is not: " + 2, docs.size() == 2);
-        TestHit doc0 = (TestHit) docs.get(0);
-        TestHit doc5 = (TestHit) docs.get(1);
+        TestHit doc0 =  docs.get(0);
+        TestHit doc5 =  docs.get(1);
         //The scores should be the same
         assertTrue(doc0.score + " does not equal: " + doc5.score, doc0.score == doc5.score);
         /*

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestTermVectors.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestTermVectors.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestTermVectors.java Fri Dec  4 13:07:47 2009
@@ -28,7 +28,6 @@
 
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.SortedSet;
 
@@ -167,7 +166,6 @@
         }
         else{
           try{
-            TermPositionVector posVec = (TermPositionVector)vector[0];
             assertTrue(false);
           }
           catch(ClassCastException ignore){
@@ -208,7 +206,7 @@
     String test2 = "computer in a computer lab"; //5 terms
     String test3 = "a chocolate lab grows old"; //5 terms
     String test4 = "eating chocolate with a chocolate lab in an old chocolate colored computer lab"; //13 terms
-    Map test4Map = new HashMap();
+    Map&lt;String,Integer&gt; test4Map = new HashMap&lt;String,Integer&gt;();
     test4Map.put("chocolate", Integer.valueOf(3));
     test4Map.put("lab", Integer.valueOf(2));
     test4Map.put("eating", Integer.valueOf(1));
@@ -246,7 +244,7 @@
       TermDocs termDocs = knownSearcher.reader.termDocs();
       //System.out.println("Terms: " + termEnum.size() + " Orig Len: " + termArray.length);
       
-      Similarity sim = knownSearcher.getSimilarity();
+      //Similarity sim = knownSearcher.getSimilarity();
       while (termEnum.next() == true)
       {
         Term term = termEnum.term();
@@ -258,11 +256,11 @@
           int freq = termDocs.freq();
           //System.out.println("Doc Id: " + docId + " freq " + freq);
           TermFreqVector vector = knownSearcher.reader.getTermFreqVector(docId, "field");
-          float tf = sim.tf(freq);
-          float idf = sim.idf(knownSearcher.docFreq(term), knownSearcher.maxDoc());
+          //float tf = sim.tf(freq);
+          //float idf = sim.idf(knownSearcher.docFreq(term), knownSearcher.maxDoc());
           //float qNorm = sim.queryNorm()
           //This is fine since we don't have stop words
-          float lNorm = sim.lengthNorm("field", vector.getTerms().length);
+          //float lNorm = sim.lengthNorm("field", vector.getTerms().length);
           //float coord = sim.coord()
           //System.out.println("TF: " + tf + " IDF: " + idf + " LenNorm: " + lNorm);
           assertTrue(vector != null);
@@ -283,7 +281,6 @@
       ScoreDoc[] hits = knownSearcher.search(query, null, 1000).scoreDocs;
       //doc 3 should be the first hit b/c it is the shortest match
       assertTrue(hits.length == 3);
-      float score = hits[0].score;
       /*System.out.println("Hit 0: " + hits.id(0) + " Score: " + hits.score(0) + " String: " + hits.doc(0).toString());
       System.out.println("Explain: " + knownSearcher.explain(query, hits.id(0)));
       System.out.println("Hit 1: " + hits.id(1) + " Score: " + hits.score(1) + " String: " + hits.doc(1).toString());
@@ -304,21 +301,20 @@
         //System.out.println("Term: " + term);
         int freq = freqs[i];
         assertTrue(test4.indexOf(term) != -1);
-        Integer freqInt = (Integer)test4Map.get(term);
+        Integer freqInt = test4Map.get(term);
         assertTrue(freqInt != null);
         assertTrue(freqInt.intValue() == freq);        
       }
       SortedTermVectorMapper mapper = new SortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
       knownSearcher.reader.getTermFreqVector(hits[1].doc, mapper);
-      SortedSet vectorEntrySet = mapper.getTermVectorEntrySet();
+      SortedSet&lt;TermVectorEntry&gt; vectorEntrySet = mapper.getTermVectorEntrySet();
       assertTrue("mapper.getTermVectorEntrySet() Size: " + vectorEntrySet.size() + " is not: " + 10, vectorEntrySet.size() == 10);
       TermVectorEntry last = null;
-      for (Iterator iterator = vectorEntrySet.iterator(); iterator.hasNext();) {
-         TermVectorEntry tve = (TermVectorEntry) iterator.next();
+      for (final TermVectorEntry tve : vectorEntrySet) {
         if (tve != null &amp;&amp; last != null)
         {
           assertTrue("terms are not properly sorted", last.getFrequency() &gt;= tve.getFrequency());
-          Integer expectedFreq = (Integer) test4Map.get(tve.getTerm());
+          Integer expectedFreq =  test4Map.get(tve.getTerm());
           //we expect double the expectedFreq, since there are two fields with the exact same text and we are collapsing all fields
           assertTrue("Frequency is not correct:", tve.getFrequency() == 2*expectedFreq.intValue());
         }
@@ -328,9 +324,9 @@
 
       FieldSortedTermVectorMapper fieldMapper = new FieldSortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
       knownSearcher.reader.getTermFreqVector(hits[1].doc, fieldMapper);
-      Map map = fieldMapper.getFieldToTerms();
+      Map&lt;String,SortedSet&lt;TermVectorEntry&gt;&gt; map = fieldMapper.getFieldToTerms();
       assertTrue("map Size: " + map.size() + " is not: " + 2, map.size() == 2);
-      vectorEntrySet = (SortedSet) map.get("field");
+      vectorEntrySet = map.get("field");
       assertTrue("vectorEntrySet is null and it shouldn't be", vectorEntrySet != null);
       assertTrue("vectorEntrySet Size: " + vectorEntrySet.size() + " is not: " + 10, vectorEntrySet.size() == 10);
       knownSearcher.close();

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestThreadSafe.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestThreadSafe.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestThreadSafe.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestThreadSafe.java Fri Dec  4 13:07:47 2009
@@ -85,9 +85,8 @@
                 }
               );
 
-      List fields = doc.getFields();
-      for (int i=0; i&lt;fields.size(); i++) {
-        Fieldable f = (Fieldable)fields.get(i);
+      List&lt;Fieldable&gt; fields = doc.getFields();
+      for (final Fieldable f : fields ) {
         validateField(f);
       }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestTopDocsCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestTopDocsCollector.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestTopDocsCollector.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestTopDocsCollector.java Fri Dec  4 13:07:47 2009
@@ -30,7 +30,7 @@
 
 public class TestTopDocsCollector extends LuceneTestCase {
 
-  private static final class MyTopsDocCollector extends TopDocsCollector {
+  private static final class MyTopsDocCollector extends TopDocsCollector&lt;ScoreDoc&gt; {
 
     private int idx = 0;
     private int base = 0;
@@ -50,7 +50,7 @@
         maxScore = results[0].score;
       } else {
         for (int i = pq.size(); i &gt; 1; i--) { pq.pop(); }
-        maxScore = ((ScoreDoc) pq.pop()).score;
+        maxScore = pq.pop().score;
       }
       
       return new TopDocs(totalHits, results, maxScore);
@@ -94,10 +94,10 @@
   
   private Directory dir = new RAMDirectory();
 
-  private TopDocsCollector doSearch(int numResults) throws IOException {
+  private TopDocsCollector&lt;ScoreDoc&gt; doSearch(int numResults) throws IOException {
     Query q = new MatchAllDocsQuery();
     IndexSearcher searcher = new IndexSearcher(dir, true);
-    TopDocsCollector tdc = new MyTopsDocCollector(numResults);
+    TopDocsCollector&lt;ScoreDoc&gt; tdc = new MyTopsDocCollector(numResults);
     searcher.search(q, tdc);
     searcher.close();
     return tdc;
@@ -125,7 +125,7 @@
   
   public void testInvalidArguments() throws Exception {
     int numResults = 5;
-    TopDocsCollector tdc = doSearch(numResults);
+    TopDocsCollector&lt;ScoreDoc&gt; tdc = doSearch(numResults);
     
     // start &lt; 0
     assertEquals(0, tdc.topDocs(-1).scoreDocs.length);
@@ -145,17 +145,17 @@
   }
   
   public void testZeroResults() throws Exception {
-    TopDocsCollector tdc = new MyTopsDocCollector(5);
+    TopDocsCollector&lt;ScoreDoc&gt; tdc = new MyTopsDocCollector(5);
     assertEquals(0, tdc.topDocs(0, 1).scoreDocs.length);
   }
   
   public void testFirstResultsPage() throws Exception {
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector&lt;ScoreDoc&gt; tdc = doSearch(15);
     assertEquals(10, tdc.topDocs(0, 10).scoreDocs.length);
   }
   
   public void testSecondResultsPages() throws Exception {
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector&lt;ScoreDoc&gt; tdc = doSearch(15);
     // ask for more results than are available
     assertEquals(5, tdc.topDocs(10, 10).scoreDocs.length);
     
@@ -169,12 +169,12 @@
   }
   
   public void testGetAllResults() throws Exception {
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector&lt;ScoreDoc&gt; tdc = doSearch(15);
     assertEquals(15, tdc.topDocs().scoreDocs.length);
   }
   
   public void testGetResultsFromStart() throws Exception {
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector&lt;ScoreDoc&gt; tdc = doSearch(15);
     // should bring all results
     assertEquals(15, tdc.topDocs(0).scoreDocs.length);
     
@@ -185,7 +185,7 @@
   
   public void testMaxScore() throws Exception {
     // ask for all results
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector&lt;ScoreDoc&gt; tdc = doSearch(15);
     TopDocs td = tdc.topDocs();
     assertEquals(MAX_SCORE, td.getMaxScore(), 0f);
     
@@ -198,7 +198,7 @@
   // This does not test the PQ's correctness, but whether topDocs()
   // implementations return the results in decreasing score order.
   public void testResultsOrder() throws Exception {
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector&lt;ScoreDoc&gt; tdc = doSearch(15);
     ScoreDoc[] sd = tdc.topDocs().scoreDocs;
     
     assertEquals(MAX_SCORE, sd[0].score, 0f);

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java Fri Dec  4 13:07:47 2009
@@ -59,7 +59,7 @@
     bq.setMinimumNumberShouldMatch(1);
     IndexSearcher searcher = new IndexSearcher(dir, true);
     for (int i = 0; i &lt; inOrder.length; i++) {
-      TopDocsCollector tdc = TopScoreDocCollector.create(3, inOrder[i]);
+      TopDocsCollector&lt;ScoreDoc&gt; tdc = TopScoreDocCollector.create(3, inOrder[i]);
       assertEquals("org.apache.lucene.search.TopScoreDocCollector$" + actualTSDCClass[i], tdc.getClass().getName());
       
       searcher.search(new MatchAllDocsQuery(), tdc);

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java Fri Dec  4 13:07:47 2009
@@ -19,7 +19,6 @@
 
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.Iterator;
 
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.queryParser.QueryParser;
@@ -184,11 +183,11 @@
     TopDocs td5CustomMulAdd = s.search(q5CustomMulAdd,null,1000);
     
     // put results in map so we can verify the scores although they have changed
-    HashMap h1 = topDocsToMap(td1);
-    HashMap h2CustomNeutral = topDocsToMap(td2CustomNeutral);
-    HashMap h3CustomMul = topDocsToMap(td3CustomMul);
-    HashMap h4CustomAdd = topDocsToMap(td4CustomAdd);
-    HashMap h5CustomMulAdd = topDocsToMap(td5CustomMulAdd);
+    HashMap&lt;Integer,Float&gt; h1               = topDocsToMap(td1);
+    HashMap&lt;Integer,Float&gt; h2CustomNeutral  = topDocsToMap(td2CustomNeutral);
+    HashMap&lt;Integer,Float&gt; h3CustomMul      = topDocsToMap(td3CustomMul);
+    HashMap&lt;Integer,Float&gt; h4CustomAdd      = topDocsToMap(td4CustomAdd);
+    HashMap&lt;Integer,Float&gt; h5CustomMulAdd   = topDocsToMap(td5CustomMulAdd);
     
     verifyResults(boost, s, 
         h1, h2CustomNeutral, h3CustomMul, h4CustomAdd, h5CustomMulAdd,
@@ -197,7 +196,7 @@
   
   // verify results are as expected.
   private void verifyResults(float boost, IndexSearcher s, 
-      HashMap h1, HashMap h2customNeutral, HashMap h3CustomMul, HashMap h4CustomAdd, HashMap h5CustomMulAdd,
+      HashMap&lt;Integer,Float&gt; h1, HashMap&lt;Integer,Float&gt; h2customNeutral, HashMap&lt;Integer,Float&gt; h3CustomMul, HashMap&lt;Integer,Float&gt; h4CustomAdd, HashMap&lt;Integer,Float&gt; h5CustomMulAdd,
       Query q1, Query q2, Query q3, Query q4, Query q5) throws Exception {
     
     // verify numbers of matches
@@ -214,8 +213,7 @@
     QueryUtils.check(q5,s);
 
     // verify scores ratios
-    for (Iterator it = h1.keySet().iterator(); it.hasNext();) {
-      Integer x = (Integer) it.next();
+    for (final Integer x : h1.keySet()) {
 
       int doc =  x.intValue();
       log("doc = "+doc);
@@ -224,22 +222,22 @@
       log("fieldScore = "+fieldScore);
       assertTrue("fieldScore should not be 0",fieldScore&gt;0);
 
-      float score1 = ((Float)h1.get(x)).floatValue();
+      float score1 = h1.get(x).floatValue();
       logResult("score1=", s, q1, doc, score1);
       
-      float score2 = ((Float)h2customNeutral.get(x)).floatValue();
+      float score2 = h2customNeutral.get(x).floatValue();
       logResult("score2=", s, q2, doc, score2);
       assertEquals("same score (just boosted) for neutral", boost * score1, score2, TEST_SCORE_TOLERANCE_DELTA);
 
-      float score3 = ((Float)h3CustomMul.get(x)).floatValue();
+      float score3 = h3CustomMul.get(x).floatValue();
       logResult("score3=", s, q3, doc, score3);
       assertEquals("new score for custom mul", boost * fieldScore * score1, score3, TEST_SCORE_TOLERANCE_DELTA);
       
-      float score4 = ((Float)h4CustomAdd.get(x)).floatValue();
+      float score4 = h4CustomAdd.get(x).floatValue();
       logResult("score4=", s, q4, doc, score4);
       assertEquals("new score for custom add", boost * (fieldScore + score1), score4, TEST_SCORE_TOLERANCE_DELTA);
       
-      float score5 = ((Float)h5CustomMulAdd.get(x)).floatValue();
+      float score5 = h5CustomMulAdd.get(x).floatValue();
       logResult("score5=", s, q5, doc, score5);
       assertEquals("new score for custom mul add", boost * fieldScore * (score1 + fieldScore), score5, TEST_SCORE_TOLERANCE_DELTA);
     }
@@ -253,8 +251,8 @@
 
   // since custom scoring modifies the order of docs, map results 
   // by doc ids so that we can later compare/verify them 
-  private HashMap topDocsToMap(TopDocs td) {
-    HashMap h = new HashMap(); 
+  private HashMap&lt;Integer,Float&gt; topDocsToMap(TopDocs td) {
+    HashMap&lt;Integer,Float&gt; h = new HashMap&lt;Integer,Float&gt;(); 
     for (int i=0; i&lt;td.totalHits; i++) {
       h.put(Integer.valueOf(td.scoreDocs[i].doc), Float.valueOf(td.scoreDocs[i].score));
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/function/TestDocValues.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/function/TestDocValues.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/function/TestDocValues.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/function/TestDocValues.java Fri Dec  4 13:07:47 2009
@@ -18,7 +18,6 @@
  */
 
 import org.apache.lucene.util.LuceneTestCase;
-import junit.framework.Assert;
 
 /**
  * DocValues TestCase  

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java Fri Dec  4 13:07:47 2009
@@ -157,7 +157,7 @@
   // Test that values loaded for FieldScoreQuery are cached properly and consumes the proper RAM resources.
   private void doTestCaching (String field, FieldScoreQuery.Type tp) throws CorruptIndexException, Exception {
     // prepare expected array types for comparison
-    HashMap expectedArrayTypes = new HashMap();
+    HashMap&lt;FieldScoreQuery.Type,Object&gt; expectedArrayTypes = new HashMap&lt;FieldScoreQuery.Type,Object&gt;();
     expectedArrayTypes.put(FieldScoreQuery.Type.BYTE, new byte[0]);
     expectedArrayTypes.put(FieldScoreQuery.Type.SHORT, new short[0]);
     expectedArrayTypes.put(FieldScoreQuery.Type.INT, new int[0]);

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java Fri Dec  4 13:07:47 2009
@@ -21,7 +21,6 @@
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.LowerCaseTokenizer;
-import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.TokenFilter;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
@@ -91,7 +90,6 @@
   }
   
   private PayloadNearQuery newPhraseQuery (String fieldName, String phrase, boolean inOrder) {
-    int n;
     String[] words = phrase.split("[\\s]+");
     SpanQuery clauses[] = new SpanQuery[words.length];
     for (int i=0;i&lt;clauses.length;i++) {
@@ -159,7 +157,6 @@
   public void testPayloadNear() throws IOException {
     SpanNearQuery q1, q2;
     PayloadNearQuery query;
-    TopDocs hits;
     //SpanNearQuery(clauses, 10000, false)
     q1 = spanNearQuery("field2", "twenty two");
     q2 = spanNearQuery("field2", "twenty three");

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java Fri Dec  4 13:07:47 2009
@@ -63,7 +63,7 @@
     }
 
     @Override
-    public Collection getPayload() throws IOException {
+    public Collection&lt;byte[]&gt; getPayload() throws IOException {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
 
@@ -96,7 +96,7 @@
   static final class JustCompilePayloadSpans extends Spans {
 
     @Override
-    public Collection getPayload() throws IOException {
+    public Collection&lt;byte[]&gt; getPayload() throws IOException {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java Fri Dec  4 13:07:47 2009
@@ -168,7 +168,7 @@
 
     QueryUtils.checkEqual(q, qr);
 
-    HashSet set = new HashSet();
+    HashSet&lt;Term&gt; set = new HashSet&lt;Term&gt;();
     qr.extractTerms(set);
     assertEquals(2, set.size());
   }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java Fri Dec  4 13:07:47 2009
@@ -21,7 +21,6 @@
 import java.io.StringReader;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
 import org.apache.lucene.analysis.Analyzer;
@@ -271,13 +270,13 @@
     Spans spans = snq.getSpans(is.getIndexReader());
 
     TopDocs topDocs = is.search(snq, 1);
-    Set payloadSet = new HashSet();
+    Set&lt;String&gt; payloadSet = new HashSet&lt;String&gt;();
     for (int i = 0; i &lt; topDocs.scoreDocs.length; i++) {
       while (spans.next()) {
-        Collection payloads = spans.getPayload();
+        Collection&lt;byte[]&gt; payloads = spans.getPayload();
 
-        for (Iterator it = payloads.iterator(); it.hasNext();) {
-          payloadSet.add(new String((byte[]) it.next()));
+        for (final byte [] payload : payloads) {
+          payloadSet.add(new String(payload));
         }
       }
     }
@@ -305,12 +304,12 @@
     Spans spans = snq.getSpans(is.getIndexReader());
 
     TopDocs topDocs = is.search(snq, 1);
-    Set payloadSet = new HashSet();
+    Set&lt;String&gt; payloadSet = new HashSet&lt;String&gt;();
     for (int i = 0; i &lt; topDocs.scoreDocs.length; i++) {
       while (spans.next()) {
-        Collection payloads = spans.getPayload();
-        for (Iterator it = payloads.iterator(); it.hasNext();) {
-          payloadSet.add(new String((byte[]) it.next()));
+        Collection&lt;byte[]&gt; payloads = spans.getPayload();
+        for (final byte[] payload : payloads) {
+          payloadSet.add(new String(payload));
         }
       }
     }
@@ -338,22 +337,21 @@
     Spans spans = snq.getSpans(is.getIndexReader());
 
     TopDocs topDocs = is.search(snq, 1);
-    Set payloadSet = new HashSet();
+    Set&lt;String&gt; payloadSet = new HashSet&lt;String&gt;();
     for (int i = 0; i &lt; topDocs.scoreDocs.length; i++) {
       while (spans.next()) {
-        Collection payloads = spans.getPayload();
+        Collection&lt;byte[]&gt; payloads = spans.getPayload();
 
-        for (Iterator it = payloads.iterator(); it.hasNext();) {
-          payloadSet.add(new String((byte[]) it.next()));
+        for (final byte [] payload : payloads) {
+          payloadSet.add(new String(payload));
         }
       }
     }
     assertEquals(2, payloadSet.size());
     if(DEBUG) {
-      Iterator pit = payloadSet.iterator();
-      while (pit.hasNext()) {
-        System.out.println("match:" + pit.next());
-      }
+      for (final String payload : payloadSet)
+        System.out.println("match:" +  payload);
+      
     }
     assertTrue(payloadSet.contains("a:Noise:10"));
     assertTrue(payloadSet.contains("k:Noise:11"));
@@ -375,12 +373,10 @@
     IndexReader reader = searcher.getIndexReader();
     PayloadSpanUtil psu = new PayloadSpanUtil(reader);
     
-    Collection payloads = psu.getPayloadsForQuery(new TermQuery(new Term(PayloadHelper.FIELD, "rr")));
+    Collection&lt;byte[]&gt; payloads = psu.getPayloadsForQuery(new TermQuery(new Term(PayloadHelper.FIELD, "rr")));
     if(DEBUG)
       System.out.println("Num payloads:" + payloads.size());
-    Iterator it = payloads.iterator();
-    while(it.hasNext()) {
-      byte[] bytes = (byte[]) it.next();
+    for (final byte [] bytes : payloads) {
       if(DEBUG)
         System.out.println(new String(bytes));
     }
@@ -405,10 +401,9 @@
       }
       //See payload helper, for the PayloadHelper.FIELD field, there is a single byte payload at every token
       if (spans.isPayloadAvailable()) {
-        Collection payload = spans.getPayload();
+        Collection&lt;byte[]&gt; payload = spans.getPayload();
         assertTrue("payload Size: " + payload.size() + " is not: " + expectedNumPayloads, payload.size() == expectedNumPayloads);
-        for (Iterator iterator = payload.iterator(); iterator.hasNext();) {
-           byte[] thePayload = (byte[]) iterator.next();
+        for (final byte [] thePayload : payload) {
           assertTrue("payload[0] Size: " + thePayload.length + " is not: " + expectedPayloadLength,
                   thePayload.length == expectedPayloadLength);
           assertTrue(thePayload[0] + " does not equal: " + expectedFirstByte, thePayload[0] == expectedFirstByte);
@@ -450,12 +445,10 @@
       if(DEBUG)
         System.out.println("\nSpans Dump --");
       if (spans.isPayloadAvailable()) {
-        Collection payload = spans.getPayload();
+        Collection&lt;byte[]&gt; payload = spans.getPayload();
         if(DEBUG)
           System.out.println("payloads for span:" + payload.size());
-        Iterator it = payload.iterator();
-        while(it.hasNext()) {
-          byte[] bytes = (byte[]) it.next();
+        for (final byte [] bytes : payload) {
           if(DEBUG)
             System.out.println("doc:" + spans.doc() + " s:" + spans.start() + " e:" + spans.end() + " "
               + new String(bytes));
@@ -484,8 +477,8 @@
   class PayloadFilter extends TokenFilter {
     String fieldName;
     int numSeen = 0;
-    Set entities = new HashSet();
-    Set nopayload = new HashSet();
+    Set&lt;String&gt; entities = new HashSet&lt;String&gt;();
+    Set&lt;String&gt; nopayload = new HashSet&lt;String&gt;();
     int pos;
     PayloadAttribute payloadAtt;
     TermAttribute termAtt;

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestSpanExplanations.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestSpanExplanations.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestSpanExplanations.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestSpanExplanations.java Fri Dec  4 13:07:47 2009
@@ -18,24 +18,7 @@
  */
 
 import org.apache.lucene.search.*;
-import org.apache.lucene.store.RAMDirectory;
 
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-
-import org.apache.lucene.analysis.WhitespaceAnalyzer;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-
-import junit.framework.TestCase;
-
-import java.util.Random;
-import java.util.BitSet;
 
 /**
  * TestExplanations subclass focusing on span queries

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java Fri Dec  4 13:07:47 2009
@@ -56,9 +56,9 @@
     if (openFiles == null)
       openFiles = new HashMap&lt;String,Integer&gt;();
     if (createdFiles == null)
-      createdFiles = new HashSet();
+      createdFiles = new HashSet&lt;String&gt;();
     if (unSyncedFiles == null)
-      unSyncedFiles = new HashSet();
+      unSyncedFiles = new HashSet&lt;String&gt;();
   }
 
   public MockRAMDirectory() {
@@ -89,9 +89,9 @@
    *  unsynced files. */
   public synchronized void crash() throws IOException {
     crashed = true;
-    openFiles = new HashMap();
+    openFiles = new HashMap&lt;String,Integer&gt;();
     Iterator&lt;String&gt; it = unSyncedFiles.iterator();
-    unSyncedFiles = new HashSet();
+    unSyncedFiles = new HashSet&lt;String&gt;();
     int count = 0;
     while(it.hasNext()) {
       String name = it.next();
@@ -264,7 +264,7 @@
   @Override
   public synchronized void close() {
     if (openFiles == null) {
-      openFiles = new HashMap();
+      openFiles = new HashMap&lt;String,Integer&gt;();
     }
     if (noDeleteOpenFile &amp;&amp; openFiles.size() &gt; 0) {
       // RuntimeException instead of IOException because
@@ -311,7 +311,7 @@
     }
   }
 
-  ArrayList failures;
+  ArrayList&lt;Failure&gt; failures;
 
   /**
    * add a Failure object to the list of objects to be evaluated
@@ -319,7 +319,7 @@
    */
   synchronized public void failOn(Failure fail) {
     if (failures == null) {
-      failures = new ArrayList();
+      failures = new ArrayList&lt;Failure&gt;();
     }
     failures.add(fail);
   }

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMInputStream.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMInputStream.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMInputStream.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMInputStream.java Fri Dec  4 13:07:47 2009
@@ -45,7 +45,7 @@
     // all clones get closed:
     if (!isClone) {
       synchronized(dir) {
-        Integer v = (Integer) dir.openFiles.get(name);
+        Integer v = dir.openFiles.get(name);
         // Could be null when MockRAMDirectory.crash() was called
         if (v != null) {
           if (v.intValue() == 1) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java Fri Dec  4 13:07:47 2009
@@ -22,7 +22,6 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Random;
 
@@ -287,7 +286,7 @@
 
     private static class MockFSDirectory extends Directory {
 
-      List allIndexInputs = new ArrayList();
+      List&lt;IndexInput&gt; allIndexInputs = new ArrayList&lt;IndexInput&gt;();
 
       Random rand;
 
@@ -305,10 +304,9 @@
       }
 
       public void tweakBufferSizes() {
-        Iterator it = allIndexInputs.iterator();
         //int count = 0;
-        while(it.hasNext()) {
-          BufferedIndexInput bii = (BufferedIndexInput) it.next();
+        for (final IndexInput ip : allIndexInputs) {
+          BufferedIndexInput bii = (BufferedIndexInput) ip;
           int bufferSize = 1024+(int) Math.abs(rand.nextInt() % 32768);
           bii.setBufferSize(bufferSize);
           //count++;

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java Fri Dec  4 13:07:47 2009
@@ -33,7 +33,7 @@
    * @throws IOException
    */
   public void testBasic() throws IOException {
-    Set fileExtensions = new HashSet();
+    Set&lt;String&gt; fileExtensions = new HashSet&lt;String&gt;();
     fileExtensions.add("fdt");
     fileExtensions.add("fdx");
     

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestHugeRamFile.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestHugeRamFile.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestHugeRamFile.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestHugeRamFile.java Fri Dec  4 13:07:47 2009
@@ -31,13 +31,13 @@
    * buffers under maxint. */
   private static class DenseRAMFile extends RAMFile {
     private long capacity = 0;
-    private HashMap singleBuffers = new HashMap();
+    private HashMap&lt;Integer,byte[]&gt; singleBuffers = new HashMap&lt;Integer,byte[]&gt;();
     @Override
     byte[] newBuffer(int size) {
       capacity += size;
       if (capacity &lt;= MAX_VALUE) {
         // below maxint we reuse buffers
-        byte buf[] = (byte[]) singleBuffers.get(Integer.valueOf(size));
+        byte buf[] = singleBuffers.get(Integer.valueOf(size));
         if (buf==null) {
           buf = new byte[size]; 
           //System.out.println("allocate: "+size);

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java Fri Dec  4 13:07:47 2009
@@ -21,7 +21,6 @@
 import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
@@ -63,8 +62,7 @@
         assertTrue("# calls to makeLock is 0 (after instantiating IndexWriter)",
                    lf.makeLockCount &gt;= 1);
         
-        for(Iterator e = lf.locksCreated.keySet().iterator(); e.hasNext();) {
-            String lockName = (String) e.next();
+        for(final String lockName : lf.locksCreated.keySet()) {
             MockLockFactory.MockLock lock = (MockLockFactory.MockLock) lf.locksCreated.get(lockName);
             assertTrue("# calls to Lock.obtain is 0 (after instantiating IndexWriter)",
                        lock.lockAttempts &gt; 0);
@@ -341,7 +339,7 @@
     public class MockLockFactory extends LockFactory {
 
         public boolean lockPrefixSet;
-        public Map locksCreated = Collections.synchronizedMap(new HashMap());
+        public Map&lt;String,Lock&gt; locksCreated = Collections.synchronizedMap(new HashMap&lt;String,Lock&gt;());
         public int makeLockCount = 0;
 
         @Override

Modified: lucene/java/trunk/src/test/org/apache/lucene/util/LocalizedTestCase.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/LocalizedTestCase.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/LocalizedTestCase.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/LocalizedTestCase.java Fri Dec  4 13:07:47 2009
@@ -43,7 +43,7 @@
   /**
    * An optional limited set of testcases that will run under different Locales.
    */
-  private final Set testWithDifferentLocales;
+  private final Set&lt;String&gt; testWithDifferentLocales;
 
   public LocalizedTestCase() {
     super();
@@ -55,12 +55,12 @@
     testWithDifferentLocales = null;
   }
 
-  public LocalizedTestCase(Set testWithDifferentLocales) {
+  public LocalizedTestCase(Set&lt;String&gt; testWithDifferentLocales) {
     super();
     this.testWithDifferentLocales = testWithDifferentLocales;
   }
 
-  public LocalizedTestCase(String name, Set testWithDifferentLocales) {
+  public LocalizedTestCase(String name, Set&lt;String&gt; testWithDifferentLocales) {
     super(name);
     this.testWithDifferentLocales = testWithDifferentLocales;
   }

Modified: lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java Fri Dec  4 13:07:47 2009
@@ -151,7 +151,7 @@
    * @param iter Each next() is toString()ed and logged on it's own line. If iter is null this is logged differnetly then an empty iterator.
    * @param stream Stream to log messages to.
    */
-  public static void dumpIterator(String label, Iterator iter, 
+  public static &lt;T&gt; void dumpIterator(String label, Iterator&lt;T&gt; iter, 
                                   PrintStream stream) {
     stream.println("*** BEGIN "+label+" ***");
     if (null == iter) {
@@ -170,7 +170,7 @@
    */
   public static void dumpArray(String label, Object[] objs, 
                                PrintStream stream) {
-    Iterator iter = (null == objs) ? null : Arrays.asList(objs).iterator();
+    Iterator&lt;Object&gt; iter = (null == objs) ? null : Arrays.asList(objs).iterator();
     dumpIterator(label, iter, stream);
   }
   

Modified: lucene/java/trunk/src/test/org/apache/lucene/util/TestCloseableThreadLocal.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/TestCloseableThreadLocal.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/TestCloseableThreadLocal.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/TestCloseableThreadLocal.java Fri Dec  4 13:07:47 2009
@@ -29,7 +29,7 @@
   public void testNullValue() throws Exception {
     // Tests that null can be set as a valid value (LUCENE-1805). This
     // previously failed in get().
-    CloseableThreadLocal ctl = new CloseableThreadLocal();
+    CloseableThreadLocal&lt;Object&gt; ctl = new CloseableThreadLocal&lt;Object&gt;();
     ctl.set(null);
     assertNull(ctl.get());
   }
@@ -37,12 +37,11 @@
   public void testDefaultValueWithoutSetting() throws Exception {
     // LUCENE-1805: make sure default get returns null,
     // twice in a row
-    CloseableThreadLocal ctl = new CloseableThreadLocal();
-    assertNull(ctl.get());
+    CloseableThreadLocal&lt;Object&gt; ctl = new CloseableThreadLocal&lt;Object&gt;();
     assertNull(ctl.get());
   }
 
-  public class InitValueThreadLocal extends CloseableThreadLocal {
+  public class InitValueThreadLocal extends CloseableThreadLocal&lt;Object&gt; {
     @Override
     protected Object initialValue() {
       return TEST_VALUE;

Modified: lucene/java/trunk/src/test/org/apache/lucene/util/TestNumericUtils.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/TestNumericUtils.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/TestNumericUtils.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/TestNumericUtils.java Fri Dec  4 13:07:47 2009
@@ -17,9 +17,6 @@
 * limitations under the License.
 */
 
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.OpenBitSet;
-
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
@@ -174,7 +171,7 @@
   
   /** Note: The neededBounds iterator must be unsigned (easier understanding what's happening) */
   protected void assertLongRangeSplit(final long lower, final long upper, int precisionStep,
-    final boolean useBitSet, final Iterator neededBounds
+    final boolean useBitSet, final Iterator&lt;Long&gt; neededBounds
   ) throws Exception {
     final OpenBitSet bits=useBitSet ? new OpenBitSet(upper-lower+1) : null;
     
@@ -189,8 +186,8 @@
         min ^= 0x8000000000000000L;
         max ^= 0x8000000000000000L;
         //System.out.println("Long.valueOf(0x"+Long.toHexString(min&gt;&gt;&gt;shift)+"L),Long.valueOf(0x"+Long.toHexString(max&gt;&gt;&gt;shift)+"L),");
-        assertEquals( "inner min bound", ((Long)neededBounds.next()).longValue(), min&gt;&gt;&gt;shift);
-        assertEquals( "inner max bound", ((Long)neededBounds.next()).longValue(), max&gt;&gt;&gt;shift);
+        assertEquals( "inner min bound", neededBounds.next().longValue(), min&gt;&gt;&gt;shift);
+        assertEquals( "inner max bound", neededBounds.next().longValue(), max&gt;&gt;&gt;shift);
       }
     }, precisionStep, lower, upper);
     
@@ -246,7 +243,7 @@
     }).iterator());
 
     // a inverse range should produce no sub-ranges
-    assertLongRangeSplit(9500L, -5000L, 4, false, Collections.EMPTY_LIST.iterator());    
+    assertLongRangeSplit(9500L, -5000L, 4, false, Collections. &lt;Long&gt; emptyList().iterator());    
 
     // a 0-length range should reproduce the range itsself
     assertLongRangeSplit(9500L, 9500L, 4, false, Arrays.asList(new Long[]{
@@ -256,7 +253,7 @@
 
   /** Note: The neededBounds iterator must be unsigned (easier understanding what's happening) */
   protected void assertIntRangeSplit(final int lower, final int upper, int precisionStep,
-    final boolean useBitSet, final Iterator neededBounds
+    final boolean useBitSet, final Iterator&lt;Integer&gt; neededBounds
   ) throws Exception {
     final OpenBitSet bits=useBitSet ? new OpenBitSet(upper-lower+1) : null;
     
@@ -271,8 +268,8 @@
         min ^= 0x80000000;
         max ^= 0x80000000;
         //System.out.println("Integer.valueOf(0x"+Integer.toHexString(min&gt;&gt;&gt;shift)+"),Integer.valueOf(0x"+Integer.toHexString(max&gt;&gt;&gt;shift)+"),");
-        assertEquals( "inner min bound", ((Integer)neededBounds.next()).intValue(), min&gt;&gt;&gt;shift);
-        assertEquals( "inner max bound", ((Integer)neededBounds.next()).intValue(), max&gt;&gt;&gt;shift);
+        assertEquals( "inner min bound", neededBounds.next().intValue(), min&gt;&gt;&gt;shift);
+        assertEquals( "inner max bound", neededBounds.next().intValue(), max&gt;&gt;&gt;shift);
       }
     }, precisionStep, lower, upper);
     
@@ -328,7 +325,7 @@
     }).iterator());
 
     // a inverse range should produce no sub-ranges
-    assertIntRangeSplit(9500, -5000, 4, false, Collections.EMPTY_LIST.iterator());    
+    assertIntRangeSplit(9500, -5000, 4, false, Collections. &lt;Integer&gt; emptyList().iterator());    
 
     // a 0-length range should reproduce the range itsself
     assertIntRangeSplit(9500, 9500, 4, false, Arrays.asList(new Integer[]{

Modified: lucene/java/trunk/src/test/org/apache/lucene/util/cache/BaseTestLRU.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/cache/BaseTestLRU.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/cache/BaseTestLRU.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/cache/BaseTestLRU.java Fri Dec  4 13:07:47 2009
@@ -21,7 +21,7 @@
 
 public class BaseTestLRU extends LuceneTestCase {
 
-  protected void testCache(Cache cache, int n) throws Exception {
+  protected void testCache(Cache&lt;Integer,Object&gt; cache, int n) throws Exception {
     Object dummy = new Object();
     
     for (int i = 0; i &lt; n; i++) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/util/cache/TestDoubleBarrelLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/cache/TestDoubleBarrelLRUCache.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/cache/TestDoubleBarrelLRUCache.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/cache/TestDoubleBarrelLRUCache.java Fri Dec  4 13:07:47 2009
@@ -21,7 +21,7 @@
 
   public void testLRUCache() throws Exception {
     final int n = 100;
-    testCache(new DoubleBarrelLRUCache(n), n);
+    testCache(new DoubleBarrelLRUCache&lt;Integer,Object&gt;(n), n);
   }
 
   private class CacheThread extends Thread {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887181 [1/2] - in /lucene/java/trunk: ./ src/java/org/apache/lucene/index/ src/java/org/apache/lucene/search/ src/java/org/apache/lucene/util/ src/test/org/apache/lucene/ src/test/org/apache/lucene/analysis/ src/test/org/apache/lucene/anal...</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091204130809.76B8C238888E@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204130809-76B8C238888E@eris-apache-org%3e</id>
<updated>2009-12-04T13:08:04Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Fri Dec  4 13:07:47 2009
New Revision: 887181

URL: http://svn.apache.org/viewvc?rev=887181&amp;view=rev
Log:
LUCENE-2065: use generics throughout unit tests

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/PositionBasedTermVectorMapper.java
    lucene/java/trunk/src/java/org/apache/lucene/search/CachingWrapperFilter.java
    lucene/java/trunk/src/java/org/apache/lucene/util/AttributeImpl.java
    lucene/java/trunk/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java
    lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java
    lucene/java/trunk/src/test/org/apache/lucene/TestSearchForDuplicates.java
    lucene/java/trunk/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java
    lucene/java/trunk/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
    lucene/java/trunk/src/test/org/apache/lucene/analysis/TestASCIIFoldingFilter.java
    lucene/java/trunk/src/test/org/apache/lucene/analysis/TestMappingCharFilter.java
    lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java
    lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java
    lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopFilter.java
    lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java
    lucene/java/trunk/src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpls.java
    lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java
    lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java
    lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestAtomicUpdate.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestByteSlices.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestCheckIndex.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestDeletionPolicy.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyBug.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestNorms.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestPayloads.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestPositionBasedTermVectorMapper.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentMerger.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing2.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactionRollback.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactions.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestWordlistLoader.java
    lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java
    lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
    lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java
    lucene/java/trunk/src/test/org/apache/lucene/search/CachingWrapperFilterHelper.java
    lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java
    lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java
    lucene/java/trunk/src/test/org/apache/lucene/search/QueryUtils.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestComplexExplanationsOfNonMatches.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestDocIdSet.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestSimpleExplanationsOfNonMatches.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestSpanQueryFilter.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestTermRangeQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestTermVectors.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestThreadSafe.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestTopDocsCollector.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java
    lucene/java/trunk/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/function/TestDocValues.java
    lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java
    lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
    lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestSpanExplanations.java
    lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java
    lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMInputStream.java
    lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
    lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
    lucene/java/trunk/src/test/org/apache/lucene/store/TestHugeRamFile.java
    lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java
    lucene/java/trunk/src/test/org/apache/lucene/util/LocalizedTestCase.java
    lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java
    lucene/java/trunk/src/test/org/apache/lucene/util/TestCloseableThreadLocal.java
    lucene/java/trunk/src/test/org/apache/lucene/util/TestNumericUtils.java
    lucene/java/trunk/src/test/org/apache/lucene/util/cache/BaseTestLRU.java
    lucene/java/trunk/src/test/org/apache/lucene/util/cache/TestDoubleBarrelLRUCache.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Fri Dec  4 13:07:47 2009
@@ -66,6 +66,9 @@
 * LUCENE-1844: Speed up the unit tests (Mark Miller, Erick Erickson,
   Mike McCandless)
 
+* LUCENE-2065: Use Java 5 generics throughout our unit tests.  (Kay
+  Kay via Mike McCandless)
+
 ======================= Release 3.0.0 2009-11-25 =======================
 
 Changes in backwards compatibility policy

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/PositionBasedTermVectorMapper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/PositionBasedTermVectorMapper.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/PositionBasedTermVectorMapper.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/PositionBasedTermVectorMapper.java Fri Dec  4 13:07:47 2009
@@ -110,7 +110,7 @@
    *
    * @return A map between field names and a Map.  The sub-Map key is the position as the integer, the value is {@link org.apache.lucene.index.PositionBasedTermVectorMapper.TVPositionInfo}.
    */
-  public Map&lt;String, Map&lt;Integer, TVPositionInfo&gt;&gt;  getFieldToTerms() {
+  public Map&lt;String,Map&lt;Integer,TVPositionInfo&gt;&gt;  getFieldToTerms() {
     return fieldToTerms;
   }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/CachingWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/CachingWrapperFilter.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/CachingWrapperFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/CachingWrapperFilter.java Fri Dec  4 13:07:47 2009
@@ -35,7 +35,7 @@
   /**
    * A transient Filter cache (package private because of test)
    */
-  transient Map&lt;IndexReader, DocIdSet&gt; cache;
+  transient Map&lt;IndexReader,DocIdSet&gt; cache;
   
   private final ReentrantLock lock = new ReentrantLock();
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/util/AttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/util/AttributeImpl.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/util/AttributeImpl.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/util/AttributeImpl.java Fri Dec  4 13:07:47 2009
@@ -51,7 +51,7 @@
   @Override
   public String toString() {
     StringBuilder buffer = new StringBuilder();
-    Class clazz = this.getClass();
+    Class&lt;?&gt; clazz = this.getClass();
     Field[] fields = clazz.getDeclaredFields();
     try {
       for (int i = 0; i &lt; fields.length; i++) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java Fri Dec  4 13:07:47 2009
@@ -212,7 +212,7 @@
       
       if (seen.contains(rf)) continue;
 
-      List kids = getAllDecendentReaderKeys(rf.readerKey);
+      List&lt;Object&gt; kids = getAllDecendentReaderKeys(rf.readerKey);
       for (Object kidKey : kids) {
         ReaderField kid = new ReaderField(kidKey, rf.fieldName);
         
@@ -270,7 +270,7 @@
    * the hierarchy of subReaders building up a list of the objects 
    * returned by obj.getFieldCacheKey()
    */
-  private List getAllDecendentReaderKeys(Object seed) {
+  private List&lt;Object&gt; getAllDecendentReaderKeys(Object seed) {
     List&lt;Object&gt; all = new ArrayList&lt;Object&gt;(17); // will grow as we iter
     all.add(seed);
     for (int i = 0; i &lt; all.size(); i++) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java Fri Dec  4 13:07:47 2009
@@ -33,7 +33,6 @@
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.Version;
-import org.apache.lucene.util._TestUtil;
 
 /**
  * A very simple demo used in the API documentation (src/java/overview.html).

Modified: lucene/java/trunk/src/test/org/apache/lucene/TestSearchForDuplicates.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/TestSearchForDuplicates.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/TestSearchForDuplicates.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/TestSearchForDuplicates.java Fri Dec  4 13:07:47 2009
@@ -30,7 +30,6 @@
 import org.apache.lucene.util.Version;
 
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.Version;
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java Fri Dec  4 13:07:47 2009
@@ -19,7 +19,6 @@
  * limitations under the License.
  */
 
-import java.util.Iterator;
 import java.util.Collection;
 import java.io.File;
 import java.io.IOException;
@@ -79,7 +78,7 @@
         writer.commit();
       }
     }
-    IndexCommit cp = (IndexCommit) dp.snapshot();
+    IndexCommit cp = dp.snapshot();
     copyFiles(dir, cp);
     writer.close();
     copyFiles(dir, cp);
@@ -181,7 +180,7 @@
   public void backupIndex(Directory dir, SnapshotDeletionPolicy dp) throws Exception {
     // To backup an index we first take a snapshot:
     try {
-      copyFiles(dir, (IndexCommit) dp.snapshot());
+      copyFiles(dir,  dp.snapshot());
     } finally {
       // Make sure to release the snapshot, otherwise these
       // files will never be deleted during this IndexWriter
@@ -195,10 +194,8 @@
     // While we hold the snapshot, and nomatter how long
     // we take to do the backup, the IndexWriter will
     // never delete the files in the snapshot:
-    Collection files = cp.getFileNames();
-    Iterator it = files.iterator();
-    while(it.hasNext()) {
-      final String fileName = (String) it.next();
+    Collection&lt;String&gt; files = cp.getFileNames();
+    for (final String fileName : files) { 
       // NOTE: in a real backup you would not use
       // readFile; you would need to use something else
       // that copies the file to a backup location.  This

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/BaseTokenStreamTestCase.java Fri Dec  4 13:07:47 2009
@@ -17,7 +17,6 @@
  * limitations under the License.
  */
 
-import java.util.Set;
 import java.io.StringReader;
 import java.io.IOException;
  

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestASCIIFoldingFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestASCIIFoldingFilter.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestASCIIFoldingFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestASCIIFoldingFilter.java Fri Dec  4 13:07:47 2009
@@ -1871,7 +1871,7 @@
     };
 
     // Construct input text and expected output tokens
-    List expectedOutputTokens = new ArrayList();
+    List&lt;String&gt; expectedOutputTokens = new ArrayList&lt;String&gt;();
     StringBuilder inputText = new StringBuilder();
     for (int n = 0 ; n &lt; foldings.length ; n += 2) {
       if (n &gt; 0) {
@@ -1892,9 +1892,9 @@
     TokenStream stream = new WhitespaceTokenizer(new StringReader(inputText.toString()));
     ASCIIFoldingFilter filter = new ASCIIFoldingFilter(stream);
     TermAttribute termAtt = filter.getAttribute(TermAttribute.class);
-    Iterator expectedIter = expectedOutputTokens.iterator();
+    Iterator&lt;String&gt; expectedIter = expectedOutputTokens.iterator();
     while (expectedIter.hasNext()) {;
-      assertTermEquals((String)expectedIter.next(), filter, termAtt);
+      assertTermEquals(expectedIter.next(), filter, termAtt);
     }
     assertFalse(filter.incrementToken());
   }

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestMappingCharFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestMappingCharFilter.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestMappingCharFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestMappingCharFilter.java Fri Dec  4 13:07:47 2009
@@ -18,7 +18,6 @@
 package org.apache.lucene.analysis;
 
 import java.io.StringReader;
-import java.util.List;
 
 public class TestMappingCharFilter extends BaseTokenStreamTestCase {
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java Fri Dec  4 13:07:47 2009
@@ -1,13 +1,9 @@
 package org.apache.lucene.analysis;
 
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
-import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
-import org.apache.lucene.analysis.tokenattributes.TypeAttribute;
+
 import org.apache.lucene.util.Version;
 
-import java.io.StringReader;
 
 /**
  * Copyright 2004 The Apache Software Foundation

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java Fri Dec  4 13:07:47 2009
@@ -30,7 +30,7 @@
 public class TestStopAnalyzer extends BaseTokenStreamTestCase {
   
   private StopAnalyzer stop = new StopAnalyzer(Version.LUCENE_CURRENT);
-  private Set inValidTokens = new HashSet();
+  private Set&lt;Object&gt; inValidTokens = new HashSet&lt;Object&gt;();
   
   public TestStopAnalyzer(String s) {
     super(s);
@@ -40,7 +40,7 @@
   protected void setUp() throws Exception {
     super.setUp();
     
-    Iterator it = StopAnalyzer.ENGLISH_STOP_WORDS_SET.iterator();
+    Iterator&lt;?&gt; it = StopAnalyzer.ENGLISH_STOP_WORDS_SET.iterator();
     while(it.hasNext()) {
       inValidTokens.add(it.next());
     }
@@ -59,7 +59,7 @@
   }
 
   public void testStopList() throws IOException {
-    Set stopWordsSet = new HashSet();
+    Set&lt;Object&gt; stopWordsSet = new HashSet&lt;Object&gt;();
     stopWordsSet.add("good");
     stopWordsSet.add("test");
     stopWordsSet.add("analyzer");
@@ -78,7 +78,7 @@
   }
 
   public void testStopListPositions() throws IOException {
-    Set stopWordsSet = new HashSet();
+    Set&lt;Object&gt; stopWordsSet = new HashSet&lt;Object&gt;();
     stopWordsSet.add("good");
     stopWordsSet.add("test");
     stopWordsSet.add("analyzer");

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopFilter.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopFilter.java Fri Dec  4 13:07:47 2009
@@ -37,7 +37,7 @@
 
   public void testExactCase() throws IOException {
     StringReader reader = new StringReader("Now is The Time");
-    Set&lt;String&gt; stopWords = new HashSet(Arrays.asList("is", "the", "Time"));
+    Set&lt;String&gt; stopWords = new HashSet&lt;String&gt;(Arrays.asList("is", "the", "Time"));
     TokenStream stream = new StopFilter(Version.LUCENE_CURRENT, new WhitespaceTokenizer(reader), stopWords, false);
     final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     assertTrue(stream.incrementToken());
@@ -49,7 +49,7 @@
 
   public void testIgnoreCase() throws IOException {
     StringReader reader = new StringReader("Now is The Time");
-    Set&lt;String&gt; stopWords = new HashSet(Arrays.asList( "is", "the", "Time" ));
+    Set&lt;Object&gt; stopWords = new HashSet&lt;Object&gt;(Arrays.asList( "is", "the", "Time" ));
     TokenStream stream = new StopFilter(Version.LUCENE_CURRENT, new WhitespaceTokenizer(reader), stopWords, true);
     final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     assertTrue(stream.incrementToken());
@@ -60,7 +60,7 @@
   public void testStopFilt() throws IOException {
     StringReader reader = new StringReader("Now is The Time");
     String[] stopWords = new String[] { "is", "the", "Time" };
-    Set stopSet = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords);
+    Set&lt;Object&gt; stopSet = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords);
     TokenStream stream = new StopFilter(Version.LUCENE_CURRENT, new WhitespaceTokenizer(reader), stopSet);
     final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     assertTrue(stream.incrementToken());
@@ -75,16 +75,16 @@
    */
   public void testStopPositons() throws IOException {
     StringBuilder sb = new StringBuilder();
-    ArrayList a = new ArrayList();
+    ArrayList&lt;String&gt; a = new ArrayList&lt;String&gt;();
     for (int i=0; i&lt;20; i++) {
       String w = English.intToEnglish(i).trim();
       sb.append(w).append(" ");
       if (i%3 != 0) a.add(w);
     }
     log(sb.toString());
-    String stopWords[] = (String[]) a.toArray(new String[0]);
+    String stopWords[] = a.toArray(new String[0]);
     for (int i=0; i&lt;a.size(); i++) log("Stop: "+stopWords[i]);
-    Set stopSet = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords);
+    Set&lt;Object&gt; stopSet = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords);
     // with increments
     StringReader reader = new StringReader(sb.toString());
     StopFilter stpf = new StopFilter(Version.LUCENE_24, new WhitespaceTokenizer(reader), stopSet);
@@ -94,8 +94,8 @@
     stpf = new StopFilter(Version.LUCENE_CURRENT, new WhitespaceTokenizer(reader), stopSet);
     doTestStopPositons(stpf,false);
     // with increments, concatenating two stop filters
-    ArrayList a0 = new ArrayList();
-    ArrayList a1 = new ArrayList();
+    ArrayList&lt;String&gt; a0 = new ArrayList&lt;String&gt;();
+    ArrayList&lt;String&gt; a1 = new ArrayList&lt;String&gt;();
     for (int i=0; i&lt;a.size(); i++) {
       if (i%2==0) { 
         a0.add(a.get(i));
@@ -103,12 +103,12 @@
         a1.add(a.get(i));
       }
     }
-    String stopWords0[] = (String[]) a0.toArray(new String[0]);
+    String stopWords0[] =  a0.toArray(new String[0]);
     for (int i=0; i&lt;a0.size(); i++) log("Stop0: "+stopWords0[i]);
-    String stopWords1[] = (String[]) a1.toArray(new String[0]);
+    String stopWords1[] =  a1.toArray(new String[0]);
     for (int i=0; i&lt;a1.size(); i++) log("Stop1: "+stopWords1[i]);
-    Set stopSet0 = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords0);
-    Set stopSet1 = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords1);
+    Set&lt;Object&gt; stopSet0 = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords0);
+    Set&lt;Object&gt; stopSet1 = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords1);
     reader = new StringReader(sb.toString());
     StopFilter stpf0 = new StopFilter(Version.LUCENE_CURRENT, new WhitespaceTokenizer(reader), stopSet0); // first part of the set
     stpf0.setEnablePositionIncrements(true);

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java Fri Dec  4 13:07:47 2009
@@ -26,8 +26,7 @@
 
 import java.io.IOException;
 import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
+
 
 /**
  * tests for the TestTeeSinkTokenFilter

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpls.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpls.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpls.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/tokenattributes/TestSimpleAttributeImpls.java Fri Dec  4 13:07:47 2009
@@ -126,7 +126,7 @@
   }
 
   public static final AttributeImpl assertCopyIsEqual(AttributeImpl att) throws Exception {
-    AttributeImpl copy = (AttributeImpl) att.getClass().newInstance();
+    AttributeImpl copy = att.getClass().newInstance();
     att.copyTo(copy);
     assertEquals("Copied instance must be equal", att, copy);
     assertEquals("Copied instance's hashcode must be equal", att.hashCode(), copy.hashCode());

Modified: lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java Fri Dec  4 13:07:47 2009
@@ -9,7 +9,6 @@
 import java.util.Locale;
 
 import org.apache.lucene.util.LocalizedTestCase;
-import org.apache.lucene.util.LuceneTestCase;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more

Modified: lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java Fri Dec  4 13:07:47 2009
@@ -29,7 +29,7 @@
     }
 
     public void testMax() {
-        // make sure the constants convert to their equivelents
+        // make sure the constants convert to their equivalents
         assertEquals(Long.MAX_VALUE, NumberTools
                 .stringToLong(NumberTools.MAX_STRING_VALUE));
         assertEquals(NumberTools.MAX_STRING_VALUE, NumberTools

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java Fri Dec  4 13:07:47 2009
@@ -109,7 +109,7 @@
   
   
   
-  public static Map nameValues = null;
+  public static Map&lt;String,Object&gt; nameValues = null;
 
   // ordered list of all the fields...
   // could use LinkedHashMap for this purpose if Java1.4 is OK
@@ -130,17 +130,16 @@
     largeLazyField//placeholder for large field, since this is null.  It must always be last
   };
 
-  // Map&lt;String fieldName, Fieldable field&gt;
-  public static Map all=new HashMap();
-  public static Map indexed=new HashMap();
-  public static Map stored=new HashMap();
-  public static Map unstored=new HashMap();
-  public static Map unindexed=new HashMap();
-  public static Map termvector=new HashMap();
-  public static Map notermvector=new HashMap();
-  public static Map lazy= new HashMap();
-  public static Map noNorms=new HashMap();
-  public static Map noTf=new HashMap();
+  public static Map&lt;String,Fieldable&gt; all     =new HashMap&lt;String,Fieldable&gt;();
+  public static Map&lt;String,Fieldable&gt; indexed =new HashMap&lt;String,Fieldable&gt;();
+  public static Map&lt;String,Fieldable&gt; stored  =new HashMap&lt;String,Fieldable&gt;();
+  public static Map&lt;String,Fieldable&gt; unstored=new HashMap&lt;String,Fieldable&gt;();
+  public static Map&lt;String,Fieldable&gt; unindexed=new HashMap&lt;String,Fieldable&gt;();
+  public static Map&lt;String,Fieldable&gt; termvector=new HashMap&lt;String,Fieldable&gt;();
+  public static Map&lt;String,Fieldable&gt; notermvector=new HashMap&lt;String,Fieldable&gt;();
+  public static Map&lt;String,Fieldable&gt; lazy= new HashMap&lt;String,Fieldable&gt;();
+  public static Map&lt;String,Fieldable&gt; noNorms=new HashMap&lt;String,Fieldable&gt;();
+  public static Map&lt;String,Fieldable&gt; noTf=new HashMap&lt;String,Fieldable&gt;();
 
   static {
     //Initialize the large Lazy Field
@@ -175,14 +174,14 @@
   }
 
 
-  private static void add(Map map, Fieldable field) {
+  private static void add(Map&lt;String,Fieldable&gt; map, Fieldable field) {
     map.put(field.name(), field);
   }
 
 
   static
   {
-    nameValues = new HashMap();
+    nameValues = new HashMap&lt;String,Object&gt;();
     nameValues.put(TEXT_FIELD_1_KEY, FIELD_1_TEXT);
     nameValues.put(TEXT_FIELD_2_KEY, FIELD_2_TEXT);
     nameValues.put(TEXT_FIELD_3_KEY, FIELD_3_TEXT);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestAtomicUpdate.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestAtomicUpdate.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestAtomicUpdate.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestAtomicUpdate.java Fri Dec  4 13:07:47 2009
@@ -20,8 +20,6 @@
 import org.apache.lucene.store.*;
 import org.apache.lucene.document.*;
 import org.apache.lucene.analysis.*;
-import org.apache.lucene.search.*;
-import org.apache.lucene.queryParser.*;
 
 import java.util.Random;
 import java.io.File;

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Fri Dec  4 13:07:47 2009
@@ -286,7 +286,7 @@
     for(int i=0;i&lt;35;i++) {
       if (!reader.isDeleted(i)) {
         Document d = reader.document(i);
-        List fields = d.getFields();
+        List&lt;Fieldable&gt; fields = d.getFields();
         if (!oldName.startsWith("19.") &amp;&amp;
             !oldName.startsWith("20.") &amp;&amp;
             !oldName.startsWith("21.") &amp;&amp;
@@ -295,19 +295,19 @@
           if (d.getField("content3") == null) {
             final int numFields = oldName.startsWith("29.") ? 7 : 5;
             assertEquals(numFields, fields.size());
-            Field f = (Field) d.getField("id");
+            Field f =  d.getField("id");
             assertEquals(""+i, f.stringValue());
 
-            f = (Field) d.getField("utf8");
+            f = d.getField("utf8");
             assertEquals("Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", f.stringValue());
 
-            f = (Field) d.getField("autf8");
+            f =  d.getField("autf8");
             assertEquals("Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", f.stringValue());
         
-            f = (Field) d.getField("content2");
+            f = d.getField("content2");
             assertEquals("here is more content with aaa aaa aaa", f.stringValue());
 
-            f = (Field) d.getField("fie\u2C77ld");
+            f = d.getField("fie\u2C77ld");
             assertEquals("field with non-ascii name", f.stringValue());
           }
         }       

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestByteSlices.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestByteSlices.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestByteSlices.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestByteSlices.java Fri Dec  4 13:07:47 2009
@@ -21,7 +21,7 @@
 public class TestByteSlices extends LuceneTestCase {
 
   private static class ByteBlockAllocator extends ByteBlockPool.Allocator {
-    ArrayList freeByteBlocks = new ArrayList();
+    ArrayList&lt;byte[]&gt; freeByteBlocks = new ArrayList&lt;byte[]&gt;();
     
     /* Allocate another byte[] from the shared pool */
     @Override
@@ -31,7 +31,7 @@
       if (0 == size)
         b = new byte[DocumentsWriter.BYTE_BLOCK_SIZE];
       else
-        b = (byte[]) freeByteBlocks.remove(size-1);
+        b =  freeByteBlocks.remove(size-1);
       return b;
     }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestCheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestCheckIndex.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestCheckIndex.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestCheckIndex.java Fri Dec  4 13:07:47 2009
@@ -58,7 +58,7 @@
       fail();
     }
     
-    final CheckIndex.Status.SegmentInfoStatus seg = (CheckIndex.Status.SegmentInfoStatus) indexStatus.segmentInfos.get(0);
+    final CheckIndex.Status.SegmentInfoStatus seg = indexStatus.segmentInfos.get(0);
     assertTrue(seg.openReaderPassed);
 
     assertNotNull(seg.diagnostics);
@@ -84,7 +84,7 @@
     assertEquals(18, seg.termVectorStatus.totVectors);
 
     assertTrue(seg.diagnostics.size() &gt; 0);
-    final List onlySegments = new ArrayList();
+    final List&lt;String&gt; onlySegments = new ArrayList&lt;String&gt;();
     onlySegments.add("_0");
     
     assertTrue(checker.checkIndex(onlySegments).clean == true);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestDeletionPolicy.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestDeletionPolicy.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestDeletionPolicy.java Fri Dec  4 13:07:47 2009
@@ -19,7 +19,6 @@
 
 import java.io.IOException;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.Collection;
@@ -43,14 +42,14 @@
 
 public class TestDeletionPolicy extends LuceneTestCase
 {
-  private void verifyCommitOrder(List commits) throws IOException {
-    final IndexCommit firstCommit = ((IndexCommit) commits.get(0));
+  private void verifyCommitOrder(List&lt;? extends IndexCommit&gt; commits) throws IOException {
+    final IndexCommit firstCommit =  commits.get(0);
     long last = SegmentInfos.generationFromSegmentsFileName(firstCommit.getSegmentsFileName());
     assertEquals(last, firstCommit.getGeneration());
     long lastVersion = firstCommit.getVersion();
     long lastTimestamp = firstCommit.getTimestamp();
     for(int i=1;i&lt;commits.size();i++) {
-      final IndexCommit commit = ((IndexCommit) commits.get(i));
+      final IndexCommit commit =  commits.get(i);
       long now = SegmentInfos.generationFromSegmentsFileName(commit.getSegmentsFileName());
       long nowVersion = commit.getVersion();
       long nowTimestamp = commit.getTimestamp();
@@ -68,12 +67,12 @@
     int numOnInit;
     int numOnCommit;
     Directory dir;
-    public void onInit(List commits) throws IOException {
+    public void onInit(List&lt;? extends IndexCommit&gt; commits) throws IOException {
       verifyCommitOrder(commits);
       numOnInit++;
     }
-    public void onCommit(List commits) throws IOException {
-      IndexCommit lastCommit = (IndexCommit) commits.get(commits.size()-1);
+    public void onCommit(List&lt;? extends IndexCommit&gt; commits) throws IOException {
+      IndexCommit lastCommit =  commits.get(commits.size()-1);
       IndexReader r = IndexReader.open(dir, true);
       assertEquals("lastCommit.isOptimized()=" + lastCommit.isOptimized() + " vs IndexReader.isOptimized=" + r.isOptimized(), r.isOptimized(), lastCommit.isOptimized());
       r.close();
@@ -89,18 +88,16 @@
   class KeepNoneOnInitDeletionPolicy implements IndexDeletionPolicy {
     int numOnInit;
     int numOnCommit;
-    public void onInit(List commits) throws IOException {
+    public void onInit(List&lt;? extends IndexCommit&gt; commits) throws IOException {
       verifyCommitOrder(commits);
       numOnInit++;
       // On init, delete all commit points:
-      Iterator it = commits.iterator();
-      while(it.hasNext()) {
-        final IndexCommit commit = (IndexCommit) it.next();
+      for (final IndexCommit commit : commits) {
         commit.delete();
         assertTrue(commit.isDeleted());
       }
     }
-    public void onCommit(List commits) throws IOException {
+    public void onCommit(List&lt;? extends IndexCommit&gt; commits) throws IOException {
       verifyCommitOrder(commits);
       int size = commits.size();
       // Delete all but last one:
@@ -116,25 +113,25 @@
     int numOnCommit;
     int numToKeep;
     int numDelete;
-    Set seen = new HashSet();
+    Set&lt;String&gt; seen = new HashSet&lt;String&gt;();
 
     public KeepLastNDeletionPolicy(int numToKeep) {
       this.numToKeep = numToKeep;
     }
 
-    public void onInit(List commits) throws IOException {
+    public void onInit(List&lt;? extends IndexCommit&gt; commits) throws IOException {
       verifyCommitOrder(commits);
       numOnInit++;
       // do no deletions on init
       doDeletes(commits, false);
     }
 
-    public void onCommit(List commits) throws IOException {
+    public void onCommit(List&lt;? extends IndexCommit&gt; commits) throws IOException {
       verifyCommitOrder(commits);
       doDeletes(commits, true);
     }
     
-    private void doDeletes(List commits, boolean isCommit) {
+    private void doDeletes(List&lt;? extends IndexCommit&gt; commits, boolean isCommit) {
 
       // Assert that we really are only called for each new
       // commit:
@@ -169,23 +166,21 @@
       this.expirationTimeSeconds = seconds;
     }
 
-    public void onInit(List commits) throws IOException {
+    public void onInit(List&lt;? extends IndexCommit&gt; commits) throws IOException {
       verifyCommitOrder(commits);
       onCommit(commits);
     }
 
-    public void onCommit(List commits) throws IOException {
+    public void onCommit(List&lt;? extends IndexCommit&gt; commits) throws IOException {
       verifyCommitOrder(commits);
 
-      IndexCommit lastCommit = (IndexCommit) commits.get(commits.size()-1);
+      IndexCommit lastCommit = commits.get(commits.size()-1);
 
       // Any commit older than expireTime should be deleted:
       double expireTime = dir.fileModified(lastCommit.getSegmentsFileName())/1000.0 - expirationTimeSeconds;
 
-      Iterator it = commits.iterator();
 
-      while(it.hasNext()) {
-        IndexCommit commit = (IndexCommit) it.next();
+      for (final IndexCommit commit : commits) {
         double modTime = dir.fileModified(commit.getSegmentsFileName())/1000.0;
         if (commit != lastCommit &amp;&amp; modTime &lt; expireTime) {
           commit.delete();
@@ -297,14 +292,12 @@
       assertEquals(2, policy.numOnCommit);
 
       // Test listCommits
-      Collection commits = IndexReader.listCommits(dir);
+      Collection&lt;IndexCommit&gt; commits = IndexReader.listCommits(dir);
       // 1 from opening writer + 2 from closing writer
       assertEquals(3, commits.size());
 
-      Iterator it = commits.iterator();
       // Make sure we can open a reader on each commit:
-      while(it.hasNext()) {
-        IndexCommit commit = (IndexCommit) it.next();
+      for (final IndexCommit commit : commits) {
         IndexReader r = IndexReader.open(commit, null, false);
         r.close();
       }
@@ -356,12 +349,10 @@
     }
     writer.close();
 
-    Collection commits = IndexReader.listCommits(dir);
+    Collection&lt;IndexCommit&gt; commits = IndexReader.listCommits(dir);
     assertEquals(6, commits.size());
     IndexCommit lastCommit = null;
-    Iterator it = commits.iterator();
-    while(it.hasNext()) {
-      IndexCommit commit = (IndexCommit) it.next();
+    for (final IndexCommit commit : commits) {
       if (lastCommit == null || commit.getGeneration() &gt; lastCommit.getGeneration())
         lastCommit = commit;
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java Fri Dec  4 13:07:47 2009
@@ -22,7 +22,7 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.util.Iterator;
+
 import java.util.LinkedList;
 import java.util.List;
 
@@ -48,7 +48,7 @@
 
     private File workDir;
     private File indexDir;
-    private LinkedList files;
+    private LinkedList&lt;File&gt; files;
 
 
     /** Set the test case. This test case needs
@@ -66,7 +66,7 @@
         Directory directory = FSDirectory.open(indexDir);
         directory.close();
 
-        files = new LinkedList();
+        files = new LinkedList&lt;File&gt;();
         files.add(createOutput("test.txt",
             "This is the first test file"
         ));
@@ -188,9 +188,9 @@
       merger.closeReaders();
       
       if (useCompoundFile) {
-        List filesToDelete = merger.createCompoundFile(merged + ".cfs");
-        for (Iterator iter = filesToDelete.iterator(); iter.hasNext();)
-          si1.dir.deleteFile((String) iter.next());
+        List&lt;String&gt; filesToDelete = merger.createCompoundFile(merged + ".cfs");
+        for (final String fileToDelete : filesToDelete) 
+          si1.dir.deleteFile(fileToDelete);
       }
 
       return new SegmentInfo(merged, si1.docCount + si2.docCount, si1.dir, useCompoundFile, true);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java Fri Dec  4 13:07:47 2009
@@ -100,10 +100,10 @@
     FieldsReader reader = new FieldsReader(dir, TEST_SEGMENT_NAME, fieldInfos);
     assertTrue(reader != null);
     assertTrue(reader.size() == 1);
-    Set loadFieldNames = new HashSet();
+    Set&lt;String&gt; loadFieldNames = new HashSet&lt;String&gt;();
     loadFieldNames.add(DocHelper.TEXT_FIELD_1_KEY);
     loadFieldNames.add(DocHelper.TEXT_FIELD_UTF1_KEY);
-    Set lazyFieldNames = new HashSet();
+    Set&lt;String&gt; lazyFieldNames = new HashSet&lt;String&gt;();
     //new String[]{DocHelper.LARGE_LAZY_FIELD_KEY, DocHelper.LAZY_FIELD_KEY, DocHelper.LAZY_FIELD_BINARY_KEY};
     lazyFieldNames.add(DocHelper.LARGE_LAZY_FIELD_KEY);
     lazyFieldNames.add(DocHelper.LAZY_FIELD_KEY);
@@ -150,10 +150,10 @@
     FieldsReader reader = new FieldsReader(dir, TEST_SEGMENT_NAME, fieldInfos);
     assertTrue(reader != null);
     assertTrue(reader.size() == 1);
-    Set loadFieldNames = new HashSet();
+    Set&lt;String&gt; loadFieldNames = new HashSet&lt;String&gt;();
     loadFieldNames.add(DocHelper.TEXT_FIELD_1_KEY);
     loadFieldNames.add(DocHelper.TEXT_FIELD_UTF1_KEY);
-    Set lazyFieldNames = new HashSet();
+    Set&lt;String&gt; lazyFieldNames = new HashSet&lt;String&gt;();
     lazyFieldNames.add(DocHelper.LARGE_LAZY_FIELD_KEY);
     lazyFieldNames.add(DocHelper.LAZY_FIELD_KEY);
     lazyFieldNames.add(DocHelper.LAZY_FIELD_BINARY_KEY);
@@ -183,9 +183,10 @@
     Document doc = reader.doc(0, fieldSelector);
     assertTrue("doc is null and it shouldn't be", doc != null);
     int count = 0;
-    List l = doc.getFields();
-    for (Iterator iter = l.iterator(); iter.hasNext();) {
-      Field field = (Field) iter.next();
+    List&lt;Fieldable&gt; l = doc.getFields();
+    for (final Fieldable fieldable : l ) {
+      Field field = (Field) fieldable;
+
       assertTrue("field is null and it shouldn't be", field != null);
       String sv = field.stringValue();
       assertTrue("sv is null and it shouldn't be", sv != null);
@@ -220,9 +221,9 @@
     long lazyTime = 0;
     long regularTime = 0;
     int length = 50;
-    Set lazyFieldNames = new HashSet();
+    Set&lt;String&gt; lazyFieldNames = new HashSet&lt;String&gt;();
     lazyFieldNames.add(DocHelper.LARGE_LAZY_FIELD_KEY);
-    SetBasedFieldSelector fieldSelector = new SetBasedFieldSelector(Collections.EMPTY_SET, lazyFieldNames);
+    SetBasedFieldSelector fieldSelector = new SetBasedFieldSelector(Collections. &lt;String&gt; emptySet(), lazyFieldNames);
 
     for (int i = 0; i &lt; length; i++) {
       reader = new FieldsReader(tmpDir, TEST_SEGMENT_NAME, fieldInfos);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java Fri Dec  4 13:07:47 2009
@@ -28,7 +28,6 @@
 import org.apache.lucene.document.Field;
 import java.io.*;
 import java.util.*;
-import java.util.zip.*;
 
 /*
   Verify we can read the pre-2.1 file format, do searches
@@ -155,33 +154,34 @@
     Arrays.sort(files);
     Arrays.sort(files2);
     
-    Set dif = difFiles(files, files2);
+    Set&lt;String&gt; dif = difFiles(files, files2);
     
     if (!Arrays.equals(files, files2)) {
       fail("IndexFileDeleter failed to delete unreferenced extra files: should have deleted " + (filesPre.length-files.length) + " files but only deleted " + (filesPre.length - files2.length) + "; expected files:\n    " + asString(files) + "\n  actual files:\n    " + asString(files2)+"\ndif: "+dif);
     }
   }
 
-  private static Set difFiles(String[] files1, String[] files2) {
-    Set set1 = new HashSet();
-    Set set2 = new HashSet();
-    Set extra = new HashSet();
+  private static Set&lt;String&gt; difFiles(String[] files1, String[] files2) {
+    Set&lt;String&gt; set1 = new HashSet&lt;String&gt;();
+    Set&lt;String&gt; set2 = new HashSet&lt;String&gt;();
+    Set&lt;String&gt; extra = new HashSet&lt;String&gt;();
+    
     for (int x=0; x &lt; files1.length; x++) {
       set1.add(files1[x]);
     }
     for (int x=0; x &lt; files2.length; x++) {
       set2.add(files2[x]);
     }
-    Iterator i1 = set1.iterator();
+    Iterator&lt;String&gt; i1 = set1.iterator();
     while (i1.hasNext()) {
-      Object o = i1.next();
+      String o = i1.next();
       if (!set2.contains(o)) {
         extra.add(o);
       }
     }
-    Iterator i2 = set2.iterator();
+    Iterator&lt;String&gt; i2 = set2.iterator();
     while (i2.hasNext()) {
-      Object o = i2.next();
+      String o = i2.next();
       if (!set1.contains(o)) {
         extra.add(o);
       }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java Fri Dec  4 13:07:47 2009
@@ -25,9 +25,11 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Set;
+import java.util.SortedSet;
 
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
@@ -72,7 +74,7 @@
     public void testCommitUserData() throws Exception {
       RAMDirectory d = new MockRAMDirectory();
 
-      Map commitUserData = new HashMap();
+      Map&lt;String,String&gt; commitUserData = new HashMap&lt;String,String&gt;();
       commitUserData.put("foo", "fighters");
       
       // set up writer
@@ -156,7 +158,7 @@
         writer.close();
         // set up reader
         IndexReader reader = IndexReader.open(d, false);
-        Collection fieldNames = reader.getFieldNames(IndexReader.FieldOption.ALL);
+        Collection&lt;String&gt; fieldNames = reader.getFieldNames(IndexReader.FieldOption.ALL);
         assertTrue(fieldNames.contains("keyword"));
         assertTrue(fieldNames.contains("text"));
         assertTrue(fieldNames.contains("unindexed"));
@@ -260,12 +262,12 @@
     IndexReader reader = IndexReader.open(d, false);
     FieldSortedTermVectorMapper mapper = new FieldSortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
     reader.getTermFreqVector(0, mapper);
-    Map map = mapper.getFieldToTerms();
+    Map&lt;String,SortedSet&lt;TermVectorEntry&gt;&gt; map = mapper.getFieldToTerms();
     assertTrue("map is null and it shouldn't be", map != null);
     assertTrue("map Size: " + map.size() + " is not: " + 4, map.size() == 4);
-    Set set = (Set) map.get("termvector");
-    for (Iterator iterator = set.iterator(); iterator.hasNext();) {
-      TermVectorEntry entry = (TermVectorEntry) iterator.next();
+    Set&lt;TermVectorEntry&gt; set = map.get("termvector");
+    for (Iterator&lt;TermVectorEntry&gt; iterator = set.iterator(); iterator.hasNext();) {
+      TermVectorEntry entry =  iterator.next();
       assertTrue("entry is null and it shouldn't be", entry != null);
       System.out.println("Entry: " + entry);
     }
@@ -380,9 +382,9 @@
         for (int i = 0; i &lt; bin.length; i++) {
           assertEquals(bin[i], data1[i + b1.getBinaryOffset()]);
         }
-        Set lazyFields = new HashSet();
+        Set&lt;String&gt; lazyFields = new HashSet&lt;String&gt;();
         lazyFields.add("bin1");
-        FieldSelector sel = new SetBasedFieldSelector(new HashSet(), lazyFields);
+        FieldSelector sel = new SetBasedFieldSelector(new HashSet&lt;String&gt;(), lazyFields);
         doc = reader.document(reader.maxDoc() - 1, sel);
         Fieldable[] fieldables = doc.getFieldables("bin1");
         assertNotNull(fieldables);
@@ -1340,19 +1342,19 @@
       assertEquals("Only one index is optimized.", index1.isOptimized(), index2.isOptimized());
       
       // check field names
-      Collection fields1 = index1.getFieldNames(FieldOption.ALL);
-      Collection fields2 = index1.getFieldNames(FieldOption.ALL);
+      Collection&lt;String&gt; fields1 = index1.getFieldNames(FieldOption.ALL);
+      Collection&lt;String&gt; fields2 = index1.getFieldNames(FieldOption.ALL);
       assertEquals("IndexReaders have different numbers of fields.", fields1.size(), fields2.size());
-      Iterator it1 = fields1.iterator();
-      Iterator it2 = fields1.iterator();
+      Iterator&lt;String&gt; it1 = fields1.iterator();
+      Iterator&lt;String&gt; it2 = fields1.iterator();
       while (it1.hasNext()) {
-        assertEquals("Different field names.", (String) it1.next(), (String) it2.next());
+        assertEquals("Different field names.", it1.next(), it2.next());
       }
       
       // check norms
       it1 = fields1.iterator();
       while (it1.hasNext()) {
-        String curField = (String) it1.next();
+        String curField = it1.next();
         byte[] norms1 = index1.norms(curField);
         byte[] norms2 = index2.norms(curField);
         if (norms1 != null &amp;&amp; norms2 != null)
@@ -1378,14 +1380,14 @@
         if (!index1.isDeleted(i)) {
           Document doc1 = index1.document(i);
           Document doc2 = index2.document(i);
-          fields1 = doc1.getFields();
-          fields2 = doc2.getFields();
-          assertEquals("Different numbers of fields for doc " + i + ".", fields1.size(), fields2.size());
-          it1 = fields1.iterator();
-          it2 = fields2.iterator();
-          while (it1.hasNext()) {
-            Field curField1 = (Field) it1.next();
-            Field curField2 = (Field) it2.next();
+          List&lt;Fieldable&gt; fieldable1 = doc1.getFields();
+          List&lt;Fieldable&gt; fieldable2 = doc2.getFields();
+          assertEquals("Different numbers of fields for doc " + i + ".", fieldable1.size(), fieldable2.size());
+          Iterator&lt;Fieldable&gt; itField1 = fieldable1.iterator();
+          Iterator&lt;Fieldable&gt; itField2 = fieldable2.iterator();
+          while (itField1.hasNext()) {
+            Field curField1 = (Field) itField1.next();
+            Field curField2 = (Field) itField2.next();
             assertEquals("Different fields names for doc " + i + ".", curField1.name(), curField2.name());
             assertEquals("Different field values for doc " + i + ".", curField1.stringValue(), curField2.stringValue());
           }          
@@ -1587,15 +1589,11 @@
     writer.addDocument(createDocument("a"));
     writer.close();
     
-    Collection commits = IndexReader.listCommits(dir);
-    Iterator it = commits.iterator();
-    while(it.hasNext()) {
-      IndexCommit commit = (IndexCommit) it.next();
-      Collection files = commit.getFileNames();
-      HashSet seen = new HashSet();
-      Iterator it2 = files.iterator();
-      while(it2.hasNext()) {
-        String fileName = (String) it2.next();
+    Collection&lt;IndexCommit&gt; commits = IndexReader.listCommits(dir);
+    for (final IndexCommit commit : commits) {
+      Collection&lt;String&gt; files = commit.getFileNames();
+      HashSet&lt;String&gt; seen = new HashSet&lt;String&gt;();
+      for (final String fileName : files) { 
         assertTrue("file " + fileName + " was duplicated", !seen.contains(fileName));
         seen.add(fileName);
       }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java Fri Dec  4 13:07:47 2009
@@ -55,9 +55,9 @@
 
   private int numDocNorms;
 
-  private ArrayList norms;
+  private ArrayList&lt;Float&gt; norms;
 
-  private ArrayList modifiedNorms;
+  private ArrayList&lt;Float&gt; modifiedNorms;
 
   private float lastNorm = 0;
 
@@ -91,19 +91,19 @@
     Directory dir1 = FSDirectory.open(indexDir1);
     IndexWriter.unlock(dir1);
 
-    norms = new ArrayList();
-    modifiedNorms = new ArrayList();
+    norms = new ArrayList&lt;Float&gt;();
+    modifiedNorms = new ArrayList&lt;Float&gt;();
 
     createIndex(dir1);
     doTestNorms(dir1);
 
     // test with a single index: index2
-    ArrayList norms1 = norms;
-    ArrayList modifiedNorms1 = modifiedNorms;
+    ArrayList&lt;Float&gt; norms1 = norms;
+    ArrayList&lt;Float&gt; modifiedNorms1 = modifiedNorms;
     int numDocNorms1 = numDocNorms;
 
-    norms = new ArrayList();
-    modifiedNorms = new ArrayList();
+    norms = new ArrayList&lt;Float&gt;();
+    modifiedNorms = new ArrayList&lt;Float&gt;();
     numDocNorms = 0;
 
     File indexDir2 = new File(tempDir, "lucenetestindex2");
@@ -282,10 +282,10 @@
       String field = "f" + i;
       byte b[] = ir.norms(field);
       assertEquals("number of norms mismatches", numDocNorms, b.length);
-      ArrayList storedNorms = (i == 1 ? modifiedNorms : norms);
+      ArrayList&lt;Float&gt; storedNorms = (i == 1 ? modifiedNorms : norms);
       for (int j = 0; j &lt; b.length; j++) {
         float norm = Similarity.getDefault().decodeNormValue(b[j]);
-        float norm1 = ((Float) storedNorms.get(j)).floatValue();
+        float norm1 =  storedNorms.get(j).floatValue();
         assertEquals("stored norm value of " + field + " for doc " + j + " is "
             + norm + " - a mismatch!", norm, norm1, 0.000001);
       }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java Fri Dec  4 13:07:47 2009
@@ -20,9 +20,10 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
+
 import java.util.List;
 import java.util.Random;
 import java.util.Map;
@@ -732,13 +733,13 @@
       }      
     };
     
-    final List readers = Collections.synchronizedList(new ArrayList());
+    final List&lt;ReaderCouple&gt; readers = Collections.synchronizedList(new ArrayList&lt;ReaderCouple&gt;());
     IndexReader firstReader = IndexReader.open(dir, false);
     IndexReader reader = firstReader;
     final Random rnd = newRandom();
     
     ReaderThread[] threads = new ReaderThread[n];
-    final Set readersToClose = Collections.synchronizedSet(new HashSet());
+    final Set&lt;IndexReader&gt; readersToClose = Collections.synchronizedSet(new HashSet&lt;IndexReader&gt;());
     
     for (int i = 0; i &lt; n; i++) {
       if (i % 2 == 0) {
@@ -806,7 +807,7 @@
             while (!stopped) {
               int numReaders = readers.size();
               if (numReaders &gt; 0) {
-                ReaderCouple c = (ReaderCouple) readers.get(rnd.nextInt(numReaders));
+                ReaderCouple c =  readers.get(rnd.nextInt(numReaders));
                 TestIndexReader.assertIndexEquals(c.newReader, c.refreshedReader);
               }
               
@@ -845,17 +846,15 @@
       
     }
     
-    Iterator it = readersToClose.iterator();
-    while (it.hasNext()) {
-      ((IndexReader) it.next()).close();
+    for (final IndexReader readerToClose : readersToClose) {
+      readerToClose.close();
     }
     
     firstReader.close();
     reader.close();
     
-    it = readersToClose.iterator();
-    while (it.hasNext()) {
-      assertReaderClosed((IndexReader) it.next(), true, true);
+    for (final IndexReader readerToClose : readersToClose) {
+      assertReaderClosed(readerToClose, true, true);
     }
 
     assertReaderClosed(reader, true, true);
@@ -1185,9 +1184,9 @@
   }
 
   private static class KeepAllCommits implements IndexDeletionPolicy {
-    public void onInit(List commits) {
+    public void onInit(List&lt;? extends IndexCommit&gt; commits) {
     }
-    public void onCommit(List commits) {
+    public void onCommit(List&lt;? extends IndexCommit&gt; commits) {
     }
   }
 
@@ -1198,13 +1197,13 @@
       Document doc = new Document();
       doc.add(new Field("id", ""+i, Field.Store.NO, Field.Index.NOT_ANALYZED));
       writer.addDocument(doc);
-      Map data = new HashMap();
+      Map&lt;String,String&gt; data = new HashMap&lt;String,String&gt;();
       data.put("index", i+"");
       writer.commit(data);
     }
     for(int i=0;i&lt;4;i++) {
       writer.deleteDocuments(new Term("id", ""+i));
-      Map data = new HashMap();
+      Map&lt;String,String&gt; data = new HashMap&lt;String,String&gt;();
       data.put("index", (4+i)+"");
       writer.commit(data);
     }
@@ -1214,9 +1213,8 @@
     assertEquals(0, r.numDocs());
     assertEquals(4, r.maxDoc());
 
-    Iterator it = IndexReader.listCommits(dir).iterator();
-    while(it.hasNext()) {
-      IndexCommit commit = (IndexCommit) it.next();
+    Collection&lt;IndexCommit&gt; commits = IndexReader.listCommits(dir);
+    for (final IndexCommit commit : commits) {
       IndexReader r2 = r.reopen(commit);
       assertTrue(r2 != r);
 
@@ -1228,13 +1226,13 @@
         // expected
       }
 
-      final Map s = commit.getUserData();
+      final Map&lt;String,String&gt; s = commit.getUserData();
       final int v;
       if (s.size() == 0) {
         // First commit created by IW
         v = -1;
       } else {
-        v = Integer.parseInt((String) s.get("index"));
+        v = Integer.parseInt(s.get("index"));
       }
       if (v &lt; 4) {
         assertEquals(1+v, r2.numDocs());

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java Fri Dec  4 13:07:47 2009
@@ -48,6 +48,7 @@
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Fieldable;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.PhraseQuery;
 import org.apache.lucene.search.Query;
@@ -2131,7 +2132,7 @@
         writer.setMergeFactor(2);
 
         final IndexWriter finalWriter = writer;
-        final ArrayList failure = new ArrayList();
+        final ArrayList&lt;Throwable&gt; failure = new ArrayList&lt;Throwable&gt;();
         Thread t1 = new Thread() {
             @Override
             public void run() {
@@ -2160,7 +2161,7 @@
           };
 
         if (failure.size() &gt; 0)
-          throw (Throwable) failure.get(0);
+          throw failure.get(0);
 
         t1.start();
 
@@ -3475,14 +3476,14 @@
       final TermAttribute termAtt = addAttribute(TermAttribute.class);
       final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
       
-      final Iterator tokens = Arrays.asList(new String[]{"a","b","c"}).iterator();
+      final Iterator&lt;String&gt; tokens = Arrays.asList(new String[]{"a","b","c"}).iterator();
       boolean first = true;
       
       @Override
       public boolean incrementToken() {
         if (!tokens.hasNext()) return false;
         clearAttributes();
-        termAtt.setTermBuffer((String) tokens.next());
+        termAtt.setTermBuffer( tokens.next());
         posIncrAtt.setPositionIncrement(first ? 0 : 1);
         first = false;
         return true;
@@ -3643,7 +3644,7 @@
     Directory dir, dir2;
     final static int NUM_INIT_DOCS = 17;
     IndexWriter writer2;
-    final List failures = new ArrayList();
+    final List&lt;Throwable&gt; failures = new ArrayList&lt;Throwable&gt;();
     volatile boolean didClose;
     final IndexReader[] readers;
     final int NUM_COPY;
@@ -3992,7 +3993,7 @@
     w.setMaxBufferedDocs(2);
     for(int j=0;j&lt;17;j++)
       addDoc(w);
-    Map data = new HashMap();
+    Map&lt;String,String&gt; data = new HashMap&lt;String,String&gt;();
     data.put("label", "test1");
     w.commit(data);
     w.close();
@@ -4040,7 +4041,7 @@
   // LUCENE-1429
   public void testOutOfMemoryErrorCausesCloseToFail() throws Exception {
 
-    final List thrown = new ArrayList();
+    final List&lt;Throwable&gt; thrown = new ArrayList&lt;Throwable&gt;();
 
     final IndexWriter writer = new IndexWriter(new MockRAMDirectory(), new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED) {
         @Override
@@ -4562,7 +4563,7 @@
     w.addDocument(doc);
     IndexReader r = w.getReader();
     doc = r.document(0);
-    Iterator it = doc.getFields().iterator();
+    Iterator&lt;Fieldable&gt; it = doc.getFields().iterator();
     assertTrue(it.hasNext());
     Field f = (Field) it.next();
     assertEquals(f.name(), "zzz");

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Fri Dec  4 13:07:47 2009
@@ -109,7 +109,7 @@
     }
   }
 
-  ThreadLocal doFail = new ThreadLocal();
+  ThreadLocal&lt;Thread&gt; doFail = new ThreadLocal&lt;Thread&gt;();
 
   public class MockIndexWriter extends IndexWriter {
     Random r = new java.util.Random(17);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterReader.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterReader.java Fri Dec  4 13:07:47 2009
@@ -306,10 +306,10 @@
     final static int NUM_THREADS = 5;
     final Thread[] threads = new Thread[NUM_THREADS];
     IndexWriter mainWriter;
-    List deletedTerms = new ArrayList();
-    LinkedList toDeleteTerms = new LinkedList();
+    List&lt;Term&gt; deletedTerms = new ArrayList&lt;Term&gt;();
+    LinkedList&lt;Term&gt; toDeleteTerms = new LinkedList&lt;Term&gt;();
     Random random;
-    final List failures = new ArrayList();
+    final List&lt;Throwable&gt; failures = new ArrayList&lt;Throwable&gt;();
     
     public DeleteThreads(IndexWriter mainWriter) throws IOException {
       this.mainWriter = mainWriter;
@@ -326,7 +326,7 @@
     
     Term getDeleteTerm() {
       synchronized (toDeleteTerms) {
-        return (Term)toDeleteTerms.removeFirst();
+        return toDeleteTerms.removeFirst();
       }
     }
     
@@ -373,7 +373,7 @@
     int numDirs;
     final Thread[] threads = new Thread[NUM_THREADS];
     IndexWriter mainWriter;
-    final List failures = new ArrayList();
+    final List&lt;Throwable&gt; failures = new ArrayList&lt;Throwable&gt;();
     IndexReader[] readers;
     boolean didClose = false;
     HeavyAtomicInt count = new HeavyAtomicInt(0);
@@ -723,7 +723,7 @@
     final float SECONDS = 0.5f;
 
     final long endTime = (long) (System.currentTimeMillis() + 1000.*SECONDS);
-    final List excs = Collections.synchronizedList(new ArrayList());
+    final List&lt;Throwable&gt; excs = Collections.synchronizedList(new ArrayList&lt;Throwable&gt;());
 
     final Thread[] threads = new Thread[NUM_THREAD];
     for(int i=0;i&lt;NUM_THREAD;i++) {
@@ -787,7 +787,7 @@
     final float SECONDS = 0.5f;
 
     final long endTime = (long) (System.currentTimeMillis() + 1000.*SECONDS);
-    final List excs = Collections.synchronizedList(new ArrayList());
+    final List&lt;Throwable&gt; excs = Collections.synchronizedList(new ArrayList&lt;Throwable&gt;());
 
     final Thread[] threads = new Thread[NUM_THREAD];
     for(int i=0;i&lt;NUM_THREAD;i++) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyBug.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyBug.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyBug.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyBug.java Fri Dec  4 13:07:47 2009
@@ -46,7 +46,7 @@
     "this string is a bigger string, mary had a little lamb, little lamb, little lamb!"
   };
 
-  private static Set dataset = new HashSet(Arrays.asList(data));
+  private static Set&lt;String&gt; dataset = new HashSet&lt;String&gt;(Arrays.asList(data));
   
   private static String MAGIC_FIELD = "f"+(NUM_FIELDS/3);
   
@@ -93,11 +93,11 @@
       Document d = reader.document(docs[i], SELECTOR);
       d.get(MAGIC_FIELD);
       
-      List fields = d.getFields();
-      for (Iterator fi = fields.iterator(); fi.hasNext(); ) {
+      List&lt;Fieldable&gt; fields = d.getFields();
+      for (Iterator&lt;Fieldable&gt; fi = fields.iterator(); fi.hasNext(); ) {
         Fieldable f=null;
         try {
-          f = (Fieldable) fi.next();
+          f =  fi.next();
           String fname = f.name();
           String fval = f.stringValue();
           assertNotNull(docs[i]+" FIELD: "+fname, fval);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestNorms.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestNorms.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestNorms.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestNorms.java Fri Dec  4 13:07:47 2009
@@ -52,8 +52,8 @@
   private Similarity similarityOne;
   private Analyzer anlzr;
   private int numDocNorms;
-  private ArrayList norms; 
-  private ArrayList modifiedNorms; 
+  private ArrayList&lt;Float&gt; norms; 
+  private ArrayList&lt;Float&gt; modifiedNorms; 
   private float lastNorm = 0;
   private float normDelta = (float) 0.001;
 
@@ -85,19 +85,19 @@
     File indexDir1 = new File(tempDir, "lucenetestindex1");
     Directory dir1 = FSDirectory.open(indexDir1);
 
-    norms = new ArrayList();
-    modifiedNorms = new ArrayList();
+    norms = new ArrayList&lt;Float&gt;();
+    modifiedNorms = new ArrayList&lt;Float&gt;();
 
     createIndex(dir1);
     doTestNorms(dir1);
 
     // test with a single index: index2
-    ArrayList norms1 = norms;
-    ArrayList modifiedNorms1 = modifiedNorms;
+    ArrayList&lt;Float&gt; norms1 = norms;
+    ArrayList&lt;Float&gt; modifiedNorms1 = modifiedNorms;
     int numDocNorms1 = numDocNorms;
 
-    norms = new ArrayList();
-    modifiedNorms = new ArrayList();
+    norms = new ArrayList&lt;Float&gt;();
+    modifiedNorms = new ArrayList&lt;Float&gt;();
     numDocNorms = 0;
     
     File indexDir2 = new File(tempDir, "lucenetestindex2");
@@ -187,10 +187,10 @@
       String field = "f"+i;
       byte b[] = ir.norms(field);
       assertEquals("number of norms mismatches",numDocNorms,b.length);
-      ArrayList storedNorms = (i==1 ? modifiedNorms : norms);
+      ArrayList&lt;Float&gt; storedNorms = (i==1 ? modifiedNorms : norms);
       for (int j = 0; j &lt; b.length; j++) {
         float norm = similarityOne.decodeNormValue(b[j]);
-        float norm1 = ((Float)storedNorms.get(j)).floatValue();
+        float norm1 = storedNorms.get(j).floatValue();
         assertEquals("stored norm value of "+field+" for doc "+j+" is "+norm+" - a mismatch!", norm, norm1, 0.000001);
       }
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java Fri Dec  4 13:07:47 2009
@@ -71,7 +71,7 @@
     ParallelReader pr = new ParallelReader();
     pr.add(IndexReader.open(dir1, false));
     pr.add(IndexReader.open(dir2, false));
-    Collection fieldNames = pr.getFieldNames(IndexReader.FieldOption.ALL);
+    Collection&lt;String&gt; fieldNames = pr.getFieldNames(IndexReader.FieldOption.ALL);
     assertEquals(4, fieldNames.size());
     assertTrue(fieldNames.contains("f1"));
     assertTrue(fieldNames.contains("f2"));

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestPayloads.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestPayloads.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestPayloads.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestPayloads.java Fri Dec  4 13:07:47 2009
@@ -382,7 +382,7 @@
      * This Analyzer uses an WhitespaceTokenizer and PayloadFilter.
      */
     private static class PayloadAnalyzer extends Analyzer {
-        Map fieldToData = new HashMap();
+        Map&lt;String,PayloadData&gt; fieldToData = new HashMap&lt;String,PayloadData&gt;();
         
         void setPayloadData(String field, byte[] data, int offset, int length) {
             fieldToData.put(field, new PayloadData(0, data, offset, length));
@@ -394,7 +394,7 @@
         
         @Override
         public TokenStream tokenStream(String fieldName, Reader reader) {
-            PayloadData payload = (PayloadData) fieldToData.get(fieldName);
+            PayloadData payload =  fieldToData.get(fieldName);
             TokenStream ts = new WhitespaceTokenizer(reader);
             if (payload != null) {
                 if (payload.numFieldInstancesToSkip == 0) {
@@ -550,10 +550,10 @@
     }
     
     private static class ByteArrayPool {
-        private List pool;
+        private List&lt;byte[]&gt; pool;
         
         ByteArrayPool(int capacity, int size) {
-            pool = new ArrayList();
+            pool = new ArrayList&lt;byte[]&gt;();
             for (int i = 0; i &lt; capacity; i++) {
                 pool.add(new byte[size]);
             }
@@ -572,7 +572,7 @@
         }
     
         synchronized byte[] get() {
-            return (byte[]) pool.remove(0);
+            return pool.remove(0);
         }
         
         synchronized void release(byte[] b) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestPositionBasedTermVectorMapper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestPositionBasedTermVectorMapper.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestPositionBasedTermVectorMapper.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestPositionBasedTermVectorMapper.java Fri Dec  4 13:07:47 2009
@@ -19,7 +19,6 @@
 
 import java.io.IOException;
 import java.util.BitSet;
-import java.util.Iterator;
 import java.util.Map;
 
 public class TestPositionBasedTermVectorMapper extends LuceneTestCase {
@@ -69,19 +68,19 @@
       mapper.map(token, 1, null, thePositions[i]);
 
     }
-    Map map = mapper.getFieldToTerms();
+    Map&lt;String,Map&lt;Integer,PositionBasedTermVectorMapper.TVPositionInfo&gt;&gt; map = mapper.getFieldToTerms();
     assertTrue("map is null and it shouldn't be", map != null);
     assertTrue("map Size: " + map.size() + " is not: " + 1, map.size() == 1);
-    Map positions = (Map) map.get("test");
+    Map&lt;Integer,PositionBasedTermVectorMapper.TVPositionInfo&gt; positions = map.get("test");
     assertTrue("thePositions is null and it shouldn't be", positions != null);
     
     assertTrue("thePositions Size: " + positions.size() + " is not: " + numPositions, positions.size() == numPositions);
     BitSet bits = new BitSet(numPositions);
-    for (Iterator iterator = positions.entrySet().iterator(); iterator.hasNext();) {
-      Map.Entry entry = (Map.Entry) iterator.next();
-      PositionBasedTermVectorMapper.TVPositionInfo info = (PositionBasedTermVectorMapper.TVPositionInfo) entry.getValue();
+    for (Map.Entry&lt;Integer,PositionBasedTermVectorMapper.TVPositionInfo&gt; entry : positions.entrySet()) {
+    
+      PositionBasedTermVectorMapper.TVPositionInfo info = entry.getValue();
       assertTrue("info is null and it shouldn't be", info != null);
-      int pos = ((Integer) entry.getKey()).intValue();
+      int pos = entry.getKey().intValue();
       bits.set(pos);
       assertTrue(info.getPosition() + " does not equal: " + pos, info.getPosition() == pos);
       assertTrue("info.getOffsets() is null and it shouldn't be", info.getOffsets() != null);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentMerger.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentMerger.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentMerger.java Fri Dec  4 13:07:47 2009
@@ -85,7 +85,7 @@
     assertTrue(termDocs != null);
     assertTrue(termDocs.next() == true);
     
-    Collection stored = mergedReader.getFieldNames(IndexReader.FieldOption.INDEXED_WITH_TERMVECTOR);
+    Collection&lt;String&gt; stored = mergedReader.getFieldNames(IndexReader.FieldOption.INDEXED_WITH_TERMVECTOR);
     assertTrue(stored != null);
     //System.out.println("stored size: " + stored.size());
     assertTrue("We do not have 3 fields that were indexed with term vector",stored.size() == 3);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java Fri Dec  4 13:07:47 2009
@@ -62,9 +62,8 @@
     //There are 2 unstored fields on the document that are not preserved across writing
     assertTrue(DocHelper.numFields(result) == DocHelper.numFields(testDoc) - DocHelper.unstored.size());
     
-    List fields = result.getFields();
-    for (Iterator iter = fields.iterator(); iter.hasNext();) {
-      Fieldable field = (Fieldable) iter.next();
+    List&lt;Fieldable&gt; fields = result.getFields();
+    for (final Fieldable field : fields ) { 
       assertTrue(field != null);
       assertTrue(DocHelper.nameValues.containsKey(field.name()));
     }
@@ -84,19 +83,19 @@
   }    
   
   public void testGetFieldNameVariations() {
-    Collection result = reader.getFieldNames(IndexReader.FieldOption.ALL);
+    Collection&lt;String&gt; result = reader.getFieldNames(IndexReader.FieldOption.ALL);
     assertTrue(result != null);
     assertTrue(result.size() == DocHelper.all.size());
-    for (Iterator iter = result.iterator(); iter.hasNext();) {
-      String s = (String) iter.next();
+    for (Iterator&lt;String&gt; iter = result.iterator(); iter.hasNext();) {
+      String s =  iter.next();
       //System.out.println("Name: " + s);
       assertTrue(DocHelper.nameValues.containsKey(s) == true || s.equals(""));
     }                                                                               
     result = reader.getFieldNames(IndexReader.FieldOption.INDEXED);
     assertTrue(result != null);
     assertTrue(result.size() == DocHelper.indexed.size());
-    for (Iterator iter = result.iterator(); iter.hasNext();) {
-      String s = (String) iter.next();
+    for (Iterator&lt;String&gt; iter = result.iterator(); iter.hasNext();) {
+      String s = iter.next();
       assertTrue(DocHelper.indexed.containsKey(s) == true || s.equals(""));
     }
     

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing.java Fri Dec  4 13:07:47 2009
@@ -21,7 +21,6 @@
 import org.apache.lucene.document.*;
 import org.apache.lucene.analysis.*;
 import org.apache.lucene.search.*;
-import org.apache.lucene.queryParser.*;
 
 import java.util.Random;
 import java.io.File;
@@ -155,7 +154,7 @@
     modifier.close();
 
     for(int i=0;i&lt;numThread;i++)
-      assertTrue(!((TimedThread) threads[i]).failed);
+      assertTrue(! threads[i].failed);
 
     //System.out.println("    Writer: " + indexerThread.count + " iterations");
     //System.out.println("Searcher 1: " + searcherThread1.count + " searchers created");

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing2.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing2.java?rev=887181&amp;r1=887180&amp;r2=887181&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing2.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing2.java Fri Dec  4 13:07:47 2009
@@ -73,7 +73,7 @@
     // dir1 = FSDirectory.open("foofoofoo");
     Directory dir2 = new MockRAMDirectory();
     // mergeFactor=2; maxBufferedDocs=2; Map docs = indexRandom(1, 3, 2, dir1);
-    Map docs = indexRandom(10, 10, 100, dir1);
+    Map&lt;String,Document&gt; docs = indexRandom(10, 10, 100, dir1);
     indexSerial(docs, dir2);
 
     // verifying verify
@@ -97,7 +97,7 @@
       int range=r.nextInt(20)+1;
       Directory dir1 = new MockRAMDirectory();
       Directory dir2 = new MockRAMDirectory();
-      Map docs = indexRandom(nThreads, iter, range, dir1);
+      Map&lt;String,Document&gt; docs = indexRandom(nThreads, iter, range, dir1);
       indexSerial(docs, dir2);
       verifyEquals(dir1, dir2, "id");
     }
@@ -106,9 +106,9 @@
 
   static Term idTerm = new Term("id","");
   IndexingThread[] threads;
-  static Comparator fieldNameComparator = new Comparator() {
-        public int compare(Object o1, Object o2) {
-          return ((Fieldable)o1).name().compareTo(((Fieldable)o2).name());
+  static Comparator&lt;Fieldable&gt; fieldNameComparator = new Comparator&lt;Fieldable&gt;() {
+        public int compare(Fieldable o1, Fieldable o2) {
+          return o1.name().compareTo(o2.name());
         }
   };
 
@@ -117,12 +117,12 @@
   // everything.
   
   public static class DocsAndWriter {
-    Map docs;
+    Map&lt;String,Document&gt; docs;
     IndexWriter writer;
   }
   
   public DocsAndWriter indexRandomIWReader(int nThreads, int iterations, int range, Directory dir) throws IOException, InterruptedException {
-    Map docs = new HashMap();
+    Map&lt;String,Document&gt; docs = new HashMap&lt;String,Document&gt;();
     IndexWriter w = new MockIndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
     w.setUseCompoundFile(false);
 
@@ -172,8 +172,8 @@
     return dw;
   }
   
-  public Map indexRandom(int nThreads, int iterations, int range, Directory dir) throws IOException, InterruptedException {
-    Map docs = new HashMap();
+  public Map&lt;String,Document&gt; indexRandom(int nThreads, int iterations, int range, Directory dir) throws IOException, InterruptedException {
+    Map&lt;String,Document&gt; docs = new HashMap&lt;String,Document&gt;();
     for(int iter=0;iter&lt;3;iter++) {
       IndexWriter w = new MockIndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
       w.setUseCompoundFile(false);
@@ -217,14 +217,14 @@
   }
 
   
-  public static void indexSerial(Map docs, Directory dir) throws IOException {
+  public static void indexSerial(Map&lt;String,Document&gt; docs, Directory dir) throws IOException {
     IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
 
     // index all docs in a single thread
-    Iterator iter = docs.values().iterator();
+    Iterator&lt;Document&gt; iter = docs.values().iterator();
     while (iter.hasNext()) {
-      Document d = (Document)iter.next();
-      ArrayList fields = new ArrayList();
+      Document d = iter.next();
+      ArrayList&lt;Fieldable&gt; fields = new ArrayList&lt;Fieldable&gt;();
       fields.addAll(d.getFields());
       // put fields in same order each time
       Collections.sort(fields, fieldNameComparator);
@@ -232,7 +232,7 @@
       Document d1 = new Document();
       d1.setBoost(d.getBoost());
       for (int i=0; i&lt;fields.size(); i++) {
-        d1.add((Fieldable) fields.get(i));
+        d1.add(fields.get(i));
       }
       w.addDocument(d1);
       // System.out.println("indexing "+d1);
@@ -391,8 +391,8 @@
   }
 
   public static void verifyEquals(Document d1, Document d2) {
-    List ff1 = d1.getFields();
-    List ff2 = d2.getFields();
+    List&lt;Fieldable&gt; ff1 = d1.getFields();
+    List&lt;Fieldable&gt; ff2 = d2.getFields();
 
     Collections.sort(ff1, fieldNameComparator);
     Collections.sort(ff2, fieldNameComparator);
@@ -405,8 +405,8 @@
 
 
     for (int i=0; i&lt;ff1.size(); i++) {
-      Fieldable f1 = (Fieldable)ff1.get(i);
-      Fieldable f2 = (Fieldable)ff2.get(i);
+      Fieldable f1 = ff1.get(i);
+      Fieldable f2 = ff2.get(i);
       if (f1.isBinary()) {
         assert(f2.isBinary());
         //TODO
@@ -480,7 +480,7 @@
     int base;
     int range;
     int iterations;
-    Map docs = new HashMap();  // Map&lt;String,Document&gt;
+    Map&lt;String,Document&gt; docs = new HashMap&lt;String,Document&gt;();  
     Random r;
 
     public int nextInt(int lim) {
@@ -561,7 +561,7 @@
     public void indexDoc() throws IOException {
       Document d = new Document();
 
-      ArrayList fields = new ArrayList();      
+      ArrayList&lt;Field&gt; fields = new ArrayList&lt;Field&gt;();      
       String idString = getIdString();
       Field idField =  new Field(idTerm.field(), idString, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
       fields.add(idField);
@@ -609,7 +609,7 @@
       }
 
       for (int i=0; i&lt;fields.size(); i++) {
-        d.add((Fieldable) fields.get(i));
+        d.add(fields.get(i));
       }
       w.updateDocument(idTerm.createTerm(idString), d);
       // System.out.println("indexing "+d);




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r887122 - /lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java</title>
<author><name>simonw@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091204091031.15C2423889DF@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091204091031-15C2423889DF@eris-apache-org%3e</id>
<updated>2009-12-04T09:10:27Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: simonw
Date: Fri Dec  4 09:10:21 2009
New Revision: 887122

URL: http://svn.apache.org/viewvc?rev=887122&amp;view=rev
Log:
fixed javadoc warnings due to missing closing braces

Modified:
    lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java

Modified: lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java?rev=887122&amp;r1=887121&amp;r2=887122&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java
(original)
+++ lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java
Fri Dec  4 09:10:21 2009
@@ -78,42 +78,42 @@
   
   private final Token wrapper = new Token();
   /**
-   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, String[],
int, int, int, boolean) instead
+   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, String[],
int, int, int, boolean)} instead
    */
   protected CompoundWordTokenFilterBase(TokenStream input, String[] dictionary, int minWordSize,
int minSubwordSize, int maxSubwordSize, boolean onlyLongestMatch) {
     this(Version.LUCENE_30, input, makeDictionary(dictionary),minWordSize,minSubwordSize,maxSubwordSize,
onlyLongestMatch);
   }
   
   /**
-   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, String[],
boolean) instead
+   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, String[],
boolean)} instead
    */
   protected CompoundWordTokenFilterBase(TokenStream input, String[] dictionary, boolean onlyLongestMatch)
{
     this(Version.LUCENE_30, input, makeDictionary(dictionary),DEFAULT_MIN_WORD_SIZE,DEFAULT_MIN_SUBWORD_SIZE,DEFAULT_MAX_SUBWORD_SIZE,
onlyLongestMatch);
   }
   
   /**
-   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, Set, boolean)
instead
+   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, Set, boolean)}
instead
    */
   protected CompoundWordTokenFilterBase(TokenStream input, Set&lt;?&gt; dictionary, boolean
onlyLongestMatch) {
     this(Version.LUCENE_30, input, dictionary,DEFAULT_MIN_WORD_SIZE,DEFAULT_MIN_SUBWORD_SIZE,DEFAULT_MAX_SUBWORD_SIZE,
onlyLongestMatch);
   }
   
   /**
-   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, String[])
instead
+   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, String[])}
instead
    */
   protected CompoundWordTokenFilterBase(TokenStream input, String[] dictionary) {
     this(Version.LUCENE_30, input, makeDictionary(dictionary),DEFAULT_MIN_WORD_SIZE,DEFAULT_MIN_SUBWORD_SIZE,DEFAULT_MAX_SUBWORD_SIZE,
false);
   }
   
   /**
-   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, Set) instead
+   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, Set)} instead
    */
   protected CompoundWordTokenFilterBase(TokenStream input, Set&lt;?&gt; dictionary) {
     this(Version.LUCENE_30, input, dictionary,DEFAULT_MIN_WORD_SIZE,DEFAULT_MIN_SUBWORD_SIZE,DEFAULT_MAX_SUBWORD_SIZE,
false);
   }
 
   /**
-   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, Set[], int,
int, int, boolean) instead
+   * @deprecated use {@link #CompoundWordTokenFilterBase(Version, TokenStream, Set, int,
int, int, boolean)} instead
    */
   protected CompoundWordTokenFilterBase(TokenStream input, Set&lt;?&gt; dictionary, int minWordSize,
int minSubwordSize, int maxSubwordSize, boolean onlyLongestMatch) {
     this(Version.LUCENE_30, input, dictionary, minWordSize, minSubwordSize, maxSubwordSize,
onlyLongestMatch);




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r886912 - in /lucene/java/branches/lucene_3_0: ./ contrib/ contrib/highlighter/src/test/ contrib/spellchecker/src/java/org/apache/lucene/search/spell/ src/java/org/apache/lucene/search/ src/test/org/apache/lucene/analysis/ src/test/org/apac...</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091203203743.B29E72388893@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091203203743-B29E72388893@eris-apache-org%3e</id>
<updated>2009-12-03T20:37:43Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Thu Dec  3 20:37:42 2009
New Revision: 886912

URL: http://svn.apache.org/viewvc?rev=886912&amp;view=rev
Log:
LUCENE-2108: add SpellChecker.close()

Modified:
    lucene/java/branches/lucene_3_0/   (props changed)
    lucene/java/branches/lucene_3_0/CHANGES.txt   (props changed)
    lucene/java/branches/lucene_3_0/contrib/   (props changed)
    lucene/java/branches/lucene_3_0/contrib/CHANGES.txt   (contents, props changed)
    lucene/java/branches/lucene_3_0/contrib/highlighter/src/test/   (props changed)
    lucene/java/branches/lucene_3_0/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java
  (props changed)

Propchange: lucene/java/branches/lucene_3_0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:37:42 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4:748824
 /lucene/java/branches/lucene_2_9:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests:818601-821336
-/lucene/java/trunk:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257
+/lucene/java/trunk:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911

Propchange: lucene/java/branches/lucene_3_0/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:37:42 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/CHANGES.txt:748824
 /lucene/java/branches/lucene_2_9/CHANGES.txt:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/CHANGES.txt:818601-821336
-/lucene/java/trunk/CHANGES.txt:881213,881315,881466,882374,882464,882672,882807,882888,882977,883074-883075,883554,883654,883661,884870,886257
+/lucene/java/trunk/CHANGES.txt:881213,881315,881466,882374,882464,882672,882807,882888,882977,883074-883075,883554,883654,883661,884870,886257,886911

Propchange: lucene/java/branches/lucene_3_0/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:37:42 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib:748824
 /lucene/java/branches/lucene_2_9/contrib:817269-818600,825998,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib:818601-821336
-/lucene/java/trunk/contrib:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257
+/lucene/java/trunk/contrib:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911

Modified: lucene/java/branches/lucene_3_0/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/contrib/CHANGES.txt?rev=886912&amp;r1=886911&amp;r2=886912&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/contrib/CHANGES.txt (original)
+++ lucene/java/branches/lucene_3_0/contrib/CHANGES.txt Thu Dec  3 20:37:42 2009
@@ -1,5 +1,12 @@
 Lucene contrib change Log
 
+======================= 3.0 branch (not yet released) =======================
+
+API Changes
+
+ * LUCENE-2108: Add SpellChecker.close, to close the underlying
+   reader.  (Eirik BjÃ¸rsnÃ¸s via Mike McCandless)
+
 ======================= Release 3.0.0 2009-11-25 =======================
 
 Changes in backwards compatibility policy

Propchange: lucene/java/branches/lucene_3_0/contrib/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:37:42 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib/CHANGES.txt:748824
 /lucene/java/branches/lucene_2_9/contrib/CHANGES.txt:817269-818600,825998,826775,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/CHANGES.txt:818601-821336
-/lucene/java/trunk/contrib/CHANGES.txt:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257
+/lucene/java/trunk/contrib/CHANGES.txt:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911

Propchange: lucene/java/branches/lucene_3_0/contrib/highlighter/src/test/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:37:42 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib/highlighter/src/test:748824
 /lucene/java/branches/lucene_2_9/contrib/highlighter/src/test:817269-818600,825998,826775,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/highlighter/src/test:818601-821336
-/lucene/java/trunk/contrib/highlighter/src/test:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257
+/lucene/java/trunk/contrib/highlighter/src/test:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911

Modified: lucene/java/branches/lucene_3_0/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java?rev=886912&amp;r1=886911&amp;r2=886912&amp;view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
(original)
+++ lucene/java/branches/lucene_3_0/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
Thu Dec  3 20:37:42 2009
@@ -409,4 +409,12 @@
       }
     }
   }
+
+  /**
+   * Close the IndexSearcher used by this SpellChecker.
+   */
+  public void close() throws IOException {
+    searcher.close();
+    searcher = null;
+  }
 }

Propchange: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:37:42 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:818601-821336
-/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:881213,881315,881466,881984,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257
+/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:881213,881315,881466,881984,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:37:42 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257
+/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:37:42 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestDateTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:37:42 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestNumberTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:37:42 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257
+/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  3 20:37:42 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/util/TestAttributeSource.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/util/TestAttributeSource.java:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/util/TestAttributeSource.java:818601-821336
-/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883079,883554,884870,886257
+/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883079,883554,884870,886257,886911




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r886911 - in /lucene/java/trunk/contrib: CHANGES.txt spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091203203519.BB1382388893@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091203203519-BB1382388893@eris-apache-org%3e</id>
<updated>2009-12-03T20:35:19Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Thu Dec  3 20:35:19 2009
New Revision: 886911

URL: http://svn.apache.org/viewvc?rev=886911&amp;view=rev
Log:
LUCENE-2108: add SpellChecker.close()

Modified:
    lucene/java/trunk/contrib/CHANGES.txt
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java

Modified: lucene/java/trunk/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/CHANGES.txt?rev=886911&amp;r1=886910&amp;r2=886911&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/CHANGES.txt Thu Dec  3 20:35:19 2009
@@ -10,13 +10,17 @@
    now reverses supplementary characters correctly if used with Version &gt; 3.0.
    (Simon Willnauer, Robert Muir)
    
+API Changes
+
+ * LUCENE-2108: Add SpellChecker.close, to close the underlying
+   reader.  (Eirik BjÃ¸rsnÃ¸s via Mike McCandless)
+
 New features
 
  * LUCENE-2067: Add a Czech light stemmer. CzechAnalyzer will now stem words
    when Version is set to 3.1 or higher.  (Robert Muir)
    
  * LUCENE-2062: Add a Bulgarian analyzer.  (Robert Muir, Simon Willnauer)
-   
 
 ======================= Release 3.0.0 2009-11-25 =======================
 

Modified: lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java?rev=886911&amp;r1=886910&amp;r2=886911&amp;view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
(original)
+++ lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
Thu Dec  3 20:35:19 2009
@@ -409,4 +409,12 @@
       }
     }
   }
+
+  /**
+   * Close the IndexSearcher used by this SpellChecker.
+   */
+  public void close() throws IOException {
+    searcher.close();
+    searcher = null;
+  }
 }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r886855 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/util/SorterTemplate.java</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091203172436.58C5C2388962@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091203172436-58C5C2388962@eris-apache-org%3e</id>
<updated>2009-12-03T17:24:28Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Thu Dec  3 17:23:59 2009
New Revision: 886855

URL: http://svn.apache.org/viewvc?rev=886855&amp;view=rev
Log:
LUCENE-1483: remove now unused SorterTemplate utility class

Removed:
    lucene/java/trunk/src/java/org/apache/lucene/util/SorterTemplate.java
Modified:
    lucene/java/trunk/CHANGES.txt

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=886855&amp;r1=886854&amp;r2=886855&amp;view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Thu Dec  3 17:23:59 2009
@@ -4,6 +4,10 @@
 ======================= Trunk (not yet released) =======================
 Changes in backwards compatibility policy
 
+* LUCENE-1483: Removed utility class oal.util.SorterTemplate; this
+  class is no longer used by Lucene.  (Gunnar Wagenknecht via Mike
+  McCandless)
+
 Changes in runtime behavior
 
 API Changes




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r886768 - /lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java</title>
<author><name>mikemccand@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091203130325.535B7238898A@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091203130325-535B7238898A@eris-apache-org%3e</id>
<updated>2009-12-03T13:03:25Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: mikemccand
Date: Thu Dec  3 13:03:24 2009
New Revision: 886768

URL: http://svn.apache.org/viewvc?rev=886768&amp;view=rev
Log:
LUCENE-1458 (on flex branch): reminder to cutover to DBLRU

Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java?rev=886768&amp;r1=886767&amp;r2=886768&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/standard/StandardTermsDictReader.java
Thu Dec  3 13:03:24 2009
@@ -584,8 +584,7 @@
     }
   }
 
-  // TODO: -- wonder if simple double-barrel LRU cache
-  // would be better
+  // nocommit -- must cutover to DBLRU
   private static class ReuseLRUCache&lt;K,V&gt; extends LinkedHashMap&lt;K, V&gt; {
 
     /**




</pre>
</div>
</content>
</entry>
<entry>
<title>=?utf-8?q?=5BLucene-java_Wiki=5D_Update_of_=22PoweredBy=22_by_Roderikvand?= =?utf-8?q?erVeer?=</title>
<author><name>Apache Wiki &lt;wikidiffs@apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091203072824.13039.58380@eos.apache.org%3e"/>
<id>urn:uuid:%3c20091203072824-13039-58380@eos-apache-org%3e</id>
<updated>2009-12-03T07:28:24Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Lucene-java Wiki" for change notification.

The "PoweredBy" page has been changed by RoderikvanderVeer.
The comment on this change is: Added sites based upon Openmercury.be.
http://wiki.apache.org/lucene-java/PoweredBy?action=diff&amp;rev1=408&amp;rev2=409

--------------------------------------------------

   * [[http://ncrhunt.com]] - City based local search engine for India(Ncr region)
   * [[http://www.cse.lk]] - Colombo Stock Exchange Website - with a live ticker
   * [[http://so.3gmatrix.cn/|3GMatrix.cn]] - China's professional 3G information platform(Run
 Lucene on Google App Engine).
+  * [[http://www.lasermedico.be|Lasermedico]] - based upon [[http://www.openmercury.be|OpenMercury]]
and features Lucene in a page search and a custom product search module
+  * [[http://www.acco.be/uitgeverij|Acco Uitgeverij]] - based upon [[http://www.openmercury.be|OpenMercury]]
and features Lucene in a complete catalog search and CRM module
+  * [[http://www.vitalinea.be|Vitalinea]] - based upon [[http://www.openmercury.be|OpenMercury]]
and features Lucene in a CRM module and a custom dieting module personalized with the CRM
+  * [[http://www.ikwilstarten.be|Acerta - Ik wil starten.be]] - based upon [[http://www.openmercury.be|OpenMercury]]
and features Lucene in a webpage search and CRM module
+  * [[http://www.toerismevlaanderen.nl|Toerisme Vlaanderen]] - based upon [[http://www.openmercury.be|OpenMercury]]
and features Lucene in a webpage search.
+  * [[http://www.flandersdc.be|FlandersDC]] - based upon [[http://www.openmercury.be|OpenMercury]]
and features Lucene in a webpage search and CRM module
+  * [[http://www.cultuurcentrummechelen.be|CC Mechelen]] - based upon [[http://www.openmercury.be|OpenMercury]]
and features Lucene in a webpage search and CRM module
+  * [[http://www.uzbrussel.be|UZ Brussel]] - based upon [[http://www.openmercury.be|OpenMercury]]
and features Lucene in a webpage search.
  


</pre>
</div>
</content>
</entry>
<entry>
<title>=?utf-8?q?=5BLucene-java_Wiki=5D_Update_of_=22PoweredBy=22_by_Roderikvand?= =?utf-8?q?erVeer?=</title>
<author><name>Apache Wiki &lt;wikidiffs@apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091203071753.13036.76380@eos.apache.org%3e"/>
<id>urn:uuid:%3c20091203071753-13036-76380@eos-apache-org%3e</id>
<updated>2009-12-03T07:17:53Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Lucene-java Wiki" for change notification.

The "PoweredBy" page has been changed by RoderikvanderVeer.
The comment on this change is: Added OpenMercury.be content management framework.
http://wiki.apache.org/lucene-java/PoweredBy?action=diff&amp;rev1=407&amp;rev2=408

--------------------------------------------------

   * [[http://www.odinjobs.com/|Odin Jobs]] - Job Match engine built on top of lucene that
returns the most relevant jobs based on job seekers qualifications and preferences. The match
engine uses lucene to index 3 million IT jobs every 48 hours. The match engine directly uses
the IndexSearcher (without query parser) to match a resume with a job description.
   * [[http://www.omgili.com/|Omgili]] - An innovative, advanced search engine for web-based
discussion forums.
   * [[http://www.opensolaris.org/os/project/opengrok|OpenGrok]] - a "wicked fast" source
code search engine with cross-referencing various program file formats, including browsing
and navigation for version control systems like SCCS, RCS and CVS.
+  * [[http://www.openmercury.be|OpenMercury]] - an open-source java-based content management
framework, using Lucene for in-site webpage searches, a CRM module, and customer specific
searches like a product searches
   * [[http://online-commons.tigris.org/|Online Commons]] - powerful tools for the organizing,
searching, and viewing of information
   * [[http://www.panFMP.org/|panFMP]] - PANGAEA Framework for Metadata Portals
   * [[http://pauker.sourceforge.net/|Pauker]] - Open Source flashcard learning application
using a combination of ultra-shortterm, shortterm, and longterm memory


</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r886343 - /lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FilteredTermsEnum.java</title>
<author><name>markrmiller@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091202235744.BC29423888FD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091202235744-BC29423888FD@eris-apache-org%3e</id>
<updated>2009-12-02T23:57:44Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: markrmiller
Date: Wed Dec  2 23:57:43 2009
New Revision: 886343

URL: http://svn.apache.org/viewvc?rev=886343&amp;view=rev
Log:
LUCENE-1458: (flex branch) fix javadoc spelling

Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FilteredTermsEnum.java

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FilteredTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FilteredTermsEnum.java?rev=886343&amp;r1=886342&amp;r2=886343&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FilteredTermsEnum.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FilteredTermsEnum.java
Wed Dec  2 23:57:43 2009
@@ -40,7 +40,7 @@
   /** the delegate enum - to set this member use {@link #setEnum} */
   protected TermsEnum actualEnum;
     
-  /** Return true if term is acceptd */
+  /** Return true if term is accepted */
   protected abstract AcceptStatus accept(TermRef term);
     
   /** Equality measure on the term */




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r886340 - /lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java</title>
<author><name>uschindler@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091202232917.7847C23888DD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091202232917-7847C23888DD@eris-apache-org%3e</id>
<updated>2009-12-02T23:29:17Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: uschindler
Date: Wed Dec  2 23:29:17 2009
New Revision: 886340

URL: http://svn.apache.org/viewvc?rev=886340&amp;view=rev
Log:
other way round!

Modified:
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=886340&amp;r1=886339&amp;r2=886340&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
(original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
Wed Dec  2 23:29:17 2009
@@ -456,7 +456,7 @@
           break;
       } while (termEnum.next() != null);
     }
-    assertNotNull(termEnum.next());
+    assertNull(termEnum.next());
     System.out.println("TermEnum on 'field4' for range [" + lower + "," + upper
         + "] contained " + count + " terms.");
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r886339 - /lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java</title>
<author><name>uschindler@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091202232749.C062E23888DD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091202232749-C062E23888DD@eris-apache-org%3e</id>
<updated>2009-12-02T23:27:49Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: uschindler
Date: Wed Dec  2 23:27:49 2009
New Revision: 886339

URL: http://svn.apache.org/viewvc?rev=886339&amp;view=rev
Log:
Fix the NRQ TermsEnum test after merge. The count was wrong because after initializing the
TermsEnum it is already on first term. So the first check must be !empty()

Modified:
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=886339&amp;r1=886338&amp;r2=886339&amp;view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
(original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
Wed Dec  2 23:27:49 2009
@@ -443,9 +443,8 @@
     NumericRangeQuery&lt;Integer&gt; q = NumericRangeQuery.newIntRange("field4", 4,
         lower, upper, true, true);
     FilteredTermsEnum termEnum = q.getTermsEnum(searcher.getIndexReader());
-    //nocommit: double check this merge 'fix'
     int count = 0;
-    if (termEnum.next() != null) {
+    if (!termEnum.empty()) {
       do {
         final TermRef t = termEnum.term();
         if (t != null) {
@@ -457,7 +456,7 @@
           break;
       } while (termEnum.next() != null);
     }
-    assertFalse(termEnum.next() != null);
+    assertNotNull(termEnum.next());
     System.out.println("TermEnum on 'field4' for range [" + lower + "," + upper
         + "] contained " + count + " terms.");
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r886336 - /lucene/java/trunk/src/test/org/apache/lucene/search/TestWildcard.java</title>
<author><name>uschindler@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/lucene-java-commits/200912.mbox/%3c20091202230709.C115923888C5@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091202230709-C115923888C5@eris-apache-org%3e</id>
<updated>2009-12-02T23:07:09Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: uschindler
Date: Wed Dec  2 23:07:08 2009
New Revision: 886336

URL: http://svn.apache.org/viewvc?rev=886336&amp;view=rev
Log:
Change the wildcard test in trunk, too

Modified:
    lucene/java/trunk/src/test/org/apache/lucene/search/TestWildcard.java

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestWildcard.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestWildcard.java?rev=886336&amp;r1=886335&amp;r2=886336&amp;view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestWildcard.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestWildcard.java Wed Dec  2 23:07:08
2009
@@ -104,8 +104,9 @@
     MultiTermQuery wq = new WildcardQuery(new Term("field", ""));
     wq.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
     assertMatches(searcher, wq, 0);
-    BooleanQuery expected = new BooleanQuery(true);
-    assertEquals(searcher.rewrite(expected), searcher.rewrite(wq));
+    Query q = searcher.rewrite(wq);
+    assertTrue(q instanceof BooleanQuery);
+    assertEquals(0, ((BooleanQuery) q).clauses().size());
   }
   
   /**




</pre>
</div>
</content>
</entry>
</feed>
