lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r828011 - in /lucene/java/trunk/src/java/org/apache/lucene: analysis/ document/ index/ search/ search/payloads/ util/
Date Wed, 21 Oct 2009 13:37:40 GMT
Author: uschindler
Date: Wed Oct 21 13:37:39 2009
New Revision: 828011

URL: http://svn.apache.org/viewvc?rev=828011&view=rev
Log:
LUCENE-1257: Remove the rest of unchecked warnings and some unneeded casts. I added a TODO,
where I do not understand the code and not for sure know, whats inside the collections. This
could be fixed some time later. But the core code now compiles without any unchecked warning.

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/analysis/BaseCharFilter.java
    lucene/java/trunk/src/java/org/apache/lucene/document/Document.java
    lucene/java/trunk/src/java/org/apache/lucene/index/DocFieldConsumers.java
    lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java
    lucene/java/trunk/src/java/org/apache/lucene/index/FreqProxTermsWriter.java
    lucene/java/trunk/src/java/org/apache/lucene/index/NormsWriter.java
    lucene/java/trunk/src/java/org/apache/lucene/index/TermsHash.java
    lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FieldDoc.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java
    lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
    lucene/java/trunk/src/java/org/apache/lucene/search/Similarity.java
    lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java
    lucene/java/trunk/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/BaseCharFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/BaseCharFilter.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/BaseCharFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/BaseCharFilter.java Wed Oct 21 13:37:39
2009
@@ -49,8 +49,8 @@
       return currentOff;
     }
     for (int i = pcmList.size() - 1; i >= 0; i--) {
-      if (currentOff >= ((OffCorrectMap) pcmList.get(i)).off) {
-        return currentOff + ((OffCorrectMap) pcmList.get(i)).cumulativeDiff;
+      if (currentOff >=  pcmList.get(i).off) {
+        return currentOff + pcmList.get(i).cumulativeDiff;
       }
     }
     return currentOff;
@@ -58,7 +58,7 @@
   
   protected int getLastCumulativeDiff() {
     return pcmList == null || pcmList.isEmpty() ?
-      0 : ((OffCorrectMap)pcmList.get(pcmList.size() - 1)).cumulativeDiff;
+      0 : pcmList.get(pcmList.size() - 1).cumulativeDiff;
   }
 
   protected void addOffCorrectMap(int off, int cumulativeDiff) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/document/Document.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/document/Document.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/document/Document.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/document/Document.java Wed Oct 21 13:37:39
2009
@@ -102,7 +102,7 @@
   public final void removeField(String name) {
     Iterator<Fieldable> it = fields.iterator();
     while (it.hasNext()) {
-      Fieldable field = (Fieldable)it.next();
+      Fieldable field = it.next();
       if (field.name().equals(name)) {
         it.remove();
         return;
@@ -122,7 +122,7 @@
   public final void removeFields(String name) {
     Iterator<Fieldable> it = fields.iterator();
     while (it.hasNext()) {
-      Fieldable field = (Fieldable)it.next();
+      Fieldable field = it.next();
       if (field.name().equals(name)) {
         it.remove();
       }
@@ -196,7 +196,7 @@
      if (result.size() == 0)
        return NO_FIELDS;
 
-     return (Field[])result.toArray(new Field[result.size()]);
+     return result.toArray(new Field[result.size()]);
    }
 
 
@@ -221,7 +221,7 @@
      if (result.size() == 0)
        return NO_FIELDABLES;
 
-     return (Fieldable[])result.toArray(new Fieldable[result.size()]);
+     return result.toArray(new Fieldable[result.size()]);
    }
 
 
@@ -244,7 +244,7 @@
     if (result.size() == 0)
       return NO_STRINGS;
     
-    return (String[])result.toArray(new String[result.size()]);
+    return result.toArray(new String[result.size()]);
   }
 
   private final static byte[][] NO_BYTES = new byte[0][];
@@ -268,7 +268,7 @@
     if (result.size() == 0)
       return NO_BYTES;
   
-    return (byte[][])result.toArray(new byte[result.size()][]);
+    return result.toArray(new byte[result.size()][]);
   }
   
   /**

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DocFieldConsumers.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DocFieldConsumers.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/DocFieldConsumers.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/DocFieldConsumers.java Wed Oct 21 13:37:39
2009
@@ -29,6 +29,8 @@
 /** This is just a "splitter" class: it lets you wrap two
  *  DocFieldConsumer instances as a single consumer. */
 
+// TODO: Fix the unchecked collections, I do not understand the whole code here -- Uwe
+@SuppressWarnings("unchecked")
 final class DocFieldConsumers extends DocFieldConsumer {
   final DocFieldConsumer one;
   final DocFieldConsumer two;

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java Wed Oct 21 13:37:39
2009
@@ -400,10 +400,12 @@
 
   /* Returns Collection of files in use by this instance,
    * including any flushed segments. */
+  @SuppressWarnings("unchecked")
   synchronized List<String> openFiles() {
-    return ( List<String>) ((ArrayList<String>) openFiles).clone();
+    return (List<String>) ((ArrayList<String>) openFiles).clone();
   }
 
+  @SuppressWarnings("unchecked")
   synchronized List<String> closedFiles() {
     return (List<String>) ((ArrayList<String>) closedFiles).clone();
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/FreqProxTermsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/FreqProxTermsWriter.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/FreqProxTermsWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/FreqProxTermsWriter.java Wed Oct 21
13:37:39 2009
@@ -27,6 +27,8 @@
 import java.util.List;
 import java.util.Iterator;
 
+// TODO: Fix the unchecked collections, I do not understand the whole code here -- Uwe
+@SuppressWarnings("unchecked")
 final class FreqProxTermsWriter extends TermsHashConsumer {
 
   public TermsHashConsumerPerThread addThread(TermsHashPerThread perThread) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/NormsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/NormsWriter.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/NormsWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/NormsWriter.java Wed Oct 21 13:37:39
2009
@@ -35,6 +35,8 @@
  *  merges all of these together into a single _X.nrm file.
  */
 
+// TODO: Fix the unchecked collections, I do not understand the whole code here -- Uwe
+@SuppressWarnings("unchecked")
 final class NormsWriter extends InvertedDocEndConsumer {
 
   private static final byte defaultNorm = Similarity.encodeNorm(1.0f);

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/TermsHash.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/TermsHash.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/TermsHash.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/TermsHash.java Wed Oct 21 13:37:39
2009
@@ -36,6 +36,8 @@
  *  under each term.
  */
 
+// TODO: Fix the unchecked collections, I do not understand the whole code here -- Uwe
+@SuppressWarnings("unchecked")
 final class TermsHash extends InvertedDocConsumer {
 
   final TermsHashConsumer consumer;

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java Wed Oct 21 13:37:39
2009
@@ -406,10 +406,10 @@
         }
   }
 
-  @Override
+  @Override @SuppressWarnings("unchecked")
   public Object clone() {
     BooleanQuery clone = (BooleanQuery)super.clone();
-    clone.clauses = (ArrayList<BooleanClause>)this.clauses.clone();
+    clone.clauses = (ArrayList<BooleanClause>) this.clauses.clone();
     return clone;
   }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java Wed Oct 21
13:37:39 2009
@@ -214,10 +214,10 @@
 
   /** Create a shallow copy of us -- used in rewriting if necessary
    * @return a copy of us (but reuse, don't copy, our subqueries) */
-  @Override
+  @Override @SuppressWarnings("unchecked")
   public Object clone() {
     DisjunctionMaxQuery clone = (DisjunctionMaxQuery)super.clone();
-    clone.disjuncts = (ArrayList<Query>)this.disjuncts.clone();
+    clone.disjuncts = (ArrayList<Query>) this.disjuncts.clone();
     return clone;
   }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FieldDoc.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/FieldDoc.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FieldDoc.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FieldDoc.java Wed Oct 21 13:37:39
2009
@@ -45,7 +45,7 @@
 	 * @see Sort
 	 * @see Searcher#search(Query,Filter,int,Sort)
 	 */
-	public Comparable[] fields;
+	public Comparable<?>[] fields;
 
 	/** Expert: Creates one of these objects with empty sort information. */
 	public FieldDoc (int doc, float score) {
@@ -53,7 +53,7 @@
 	}
 
 	/** Expert: Creates one of these objects with the given sort information. */
-	public FieldDoc (int doc, float score, Comparable[] fields) {
+	public FieldDoc (int doc, float score, Comparable<?>[] fields) {
 		super (doc, score);
 		this.fields = fields;
 	}

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java Wed Oct
21 13:37:39 2009
@@ -167,7 +167,9 @@
 					break;
         }
         case SortField.CUSTOM:{
-					c = docA.fields[i].compareTo (docB.fields[i]);
+          // TODO: Use FieldComparator? This does not make sense!
+					@SuppressWarnings("unchecked") final int temp =
+            c = ((Comparable) docA.fields[i]).compareTo((Comparable) docB.fields[i]);
 					break;
         }
         default:{

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java Wed Oct
21 13:37:39 2009
@@ -199,7 +199,7 @@
   private int nDocs;
   private TopDocs docs;
   private int i;
-  private PriorityQueue hq;
+  private PriorityQueue<?> hq;
   private int[] starts;
   private IOException ioe;
   private Sort sort;
@@ -266,7 +266,7 @@
         scoreDoc.doc += starts[i]; // convert doc 
         //it would be so nice if we had a thread-safe insert 
         synchronized (hq) {
-          if (scoreDoc == hq.insertWithOverflow(scoreDoc))
+          if (scoreDoc == ((HitQueue) hq).insertWithOverflow(scoreDoc))
             break;
         } // no more scores > minScore
       }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/Similarity.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/Similarity.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/Similarity.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/Similarity.java Wed Oct 21 13:37:39
2009
@@ -932,12 +932,12 @@
   private static final class MethodSupport implements Serializable {
     final boolean overridesCollectionIDF, overridesTermIDF;
 
-    MethodSupport(Class clazz) {
-      overridesCollectionIDF = isMethodOverridden(clazz, "idf", C_IDF_METHOD_PARAMS);
-      overridesTermIDF = isMethodOverridden(clazz, "idf", T_IDF_METHOD_PARAMS);
+    MethodSupport(Class<? extends Similarity> clazz) {
+      overridesCollectionIDF = isMethodOverridden(clazz, "idf", Collection.class, Searcher.class);
+      overridesTermIDF = isMethodOverridden(clazz, "idf", Term.class, Searcher.class);
     }
     
-    private static boolean isMethodOverridden(Class clazz, String name, Class[] params) {
+    private static boolean isMethodOverridden(Class<?> clazz, String name, Class...
params) {
       try {
         return clazz.getMethod(name, params).getDeclaringClass() != Similarity.class;
       } catch (NoSuchMethodException e) {
@@ -945,18 +945,14 @@
         throw new RuntimeException(e);
       }
     }
-    /** @deprecated Remove this when old API is removed! */
-    private static final Class[] T_IDF_METHOD_PARAMS = new Class[]{Term.class, Searcher.class};
-    
-    /** @deprecated Remove this when old API is removed! */
-    private static final Class[] C_IDF_METHOD_PARAMS = new Class[]{Collection.class, Searcher.class};
   }
   
   /** @deprecated Remove this when old API is removed! */
-  private static final IdentityHashMap<Class<? extends Similarity>,MethodSupport>
knownMethodSupport = new IdentityHashMap();
+  private static final IdentityHashMap<Class<? extends Similarity>,MethodSupport>
knownMethodSupport
+    = new IdentityHashMap<Class<? extends Similarity>,MethodSupport>();
   
   /** @deprecated Remove this when old API is removed! */
-  private static MethodSupport getSupportedMethods(Class clazz) {
+  private static MethodSupport getSupportedMethods(Class<? extends Similarity> clazz)
{
     MethodSupport supportedMethods;
     synchronized(knownMethodSupport) {
       supportedMethods = (MethodSupport) knownMethodSupport.get(clazz);

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java?rev=828011&r1=828010&r2=828011&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java Wed
Oct 21 13:37:39 2009
@@ -131,7 +131,7 @@
           }
         }
 
-        final List<Query>[] disjunctLists = new List[maxPosition + 1];
+        @SuppressWarnings("unchecked") final List<Query>[] disjunctLists = new List[maxPosition
+ 1];
         int distinctPositions = 0;
 
         for (int i = 0; i < termArrays.size(); ++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=828011&r1=828010&r2=828011&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 Wed Oct
21 13:37:39 2009
@@ -271,7 +271,7 @@
    * returned by obj.getFieldCacheKey()
    */
   private List getAllDecendentReaderKeys(Object seed) {
-    List all = new ArrayList(17); // will grow as we iter
+    List<Object> all = new ArrayList<Object>(17); // will grow as we iter
     all.add(seed);
     for (int i = 0; i < all.size(); i++) {
       Object obj = all.get(i);



Mime
View raw message