jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r801565 [2/2] - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query: ./ lucene/ lucene/join/
Date Thu, 06 Aug 2009 09:32:42 GMT
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PerQueryCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PerQueryCache.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PerQueryCache.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PerQueryCache.java
Thu Aug  6 09:32:38 2009
@@ -30,7 +30,7 @@
     /**
      * The internal map of this <code>PerQueryCache</code>.
      */
-    private final Map map = new HashMap();
+    private final Map<Key, Object> map = new HashMap<Key, Object>();
 
     /**
      * Private constructor.
@@ -41,13 +41,13 @@
     /**
      * The per thread cache instance.
      */
-    private static final ThreadLocal CACHE = new ThreadLocal();
+    private static final ThreadLocal<PerQueryCache> CACHE = new ThreadLocal<PerQueryCache>();
 
     /**
      * @return <code>PerQueryCache</code> for the current thread.
      */
     static PerQueryCache getInstance() {
-        PerQueryCache cache = (PerQueryCache) CACHE.get();
+        PerQueryCache cache = CACHE.get();
         if (cache == null) {
             cache = new PerQueryCache();
             CACHE.set(cache);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
Thu Aug  6 09:32:38 2009
@@ -79,7 +79,6 @@
      * Creates a new <code>DerefQuery</code> based on a <code>context</code>
      * query.
      *
-     * @param context the context for this query.
      * @param subQuery TODO
      * @param refProperty the name of the reference property.
      * @param nameTest a name test or <code>null</code> if any node is

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PropertiesSynonymProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PropertiesSynonymProvider.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PropertiesSynonymProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PropertiesSynonymProvider.java
Thu Aug  6 09:32:38 2009
@@ -16,16 +16,15 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-import org.apache.jackrabbit.core.fs.FileSystemResource;
-import org.apache.jackrabbit.core.fs.FileSystemException;
-
 import java.io.IOException;
-import java.util.Map;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
-import java.util.Iterator;
+
+import org.apache.jackrabbit.core.fs.FileSystemException;
+import org.apache.jackrabbit.core.fs.FileSystemResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Implements a synonym provider based on a properties file. Each line in the
@@ -73,7 +72,7 @@
     /**
      * Contains the synonym mapping. Map&lt;String, String[]>
      */
-    private Map synonyms = new HashMap();
+    private Map<String, String[]> synonyms = new HashMap<String, String[]>();
 
     /**
      * {@inheritDoc}
@@ -101,7 +100,7 @@
         term = term.toLowerCase();
         String[] syns;
         synchronized (this) {
-            syns = (String[]) synonyms.get(term);
+            syns = synonyms.get(term);
         }
         if (syns == null) {
             syns = EMPTY_ARRAY;
@@ -144,16 +143,14 @@
      * @throws IOException if an error occurs while reading from the file system
      *                     resource.
      */
-    private static Map getSynonyms(FileSystemResource config) throws IOException {
+    private static Map<String, String[]> getSynonyms(FileSystemResource config) throws
IOException {
         try {
-            Map synonyms = new HashMap();
+            Map<String, String[]> synonyms = new HashMap<String, String[]>();
             Properties props = new Properties();
             props.load(config.getInputStream());
-            Iterator it = props.entrySet().iterator();
-            while (it.hasNext()) {
-                Map.Entry e = (Map.Entry) it.next();
-                String key = (String) e.getKey();
-                String value = (String) e.getValue();
+            for (Map.Entry<Object, Object> entry : props.entrySet()) {
+                String key = (String) entry.getKey();
+                String value = (String) entry.getValue();
                 addSynonym(key, value, synonyms);
                 addSynonym(value, key, synonyms);
             }
@@ -170,9 +167,9 @@
      * @param synonym  synonym for <code>term</code>.
      * @param synonyms the Map containing the synonyms.
      */
-    private static void addSynonym(String term, String synonym, Map synonyms) {
+    private static void addSynonym(String term, String synonym, Map<String, String[]>
synonyms) {
         term = term.toLowerCase();
-        String[] syns = (String[]) synonyms.get(term);
+        String[] syns = synonyms.get(term);
         if (syns == null) {
             syns = new String[]{synonym};
         } else {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
Thu Aug  6 09:32:38 2009
@@ -171,7 +171,7 @@
          * Maps <code>Integer</code> document numbers to <code>Float</code>
          * scores.
          */
-        private final Map scores = new HashMap();
+        private final Map<Integer, Float> scores = new HashMap<Integer, Float>();
 
         /**
          * The current document number.
@@ -190,7 +190,7 @@
                 throws IOException {
             super(similarity);
             ScoreNode node;
-            Set sortedDocs = new TreeSet();
+            Set<Integer> sortedDocs = new TreeSet<Integer>();
             try {
                 while ((node = hits.nextScoreNode()) != null) {
                     String uuid = node.getNodeId().toString();
@@ -198,9 +198,9 @@
                     TermDocs tDocs = reader.termDocs(id);
                     try {
                         if (tDocs.next()) {
-                            Integer doc = new Integer(tDocs.doc());
+                            Integer doc = tDocs.doc();
                             sortedDocs.add(doc);
-                            scores.put(doc, new Float(node.getScore()));
+                            scores.put(doc, node.getScore());
                         }
                     } finally {
                         tDocs.close();
@@ -227,14 +227,14 @@
          * {@inheritDoc}
          */
         public int doc() {
-            return currentDoc.intValue();
+            return currentDoc;
         }
 
         /**
          * {@inheritDoc}
          */
         public float score() throws IOException {
-            return ((Float) scores.get(currentDoc)).floatValue();
+            return scores.get(currentDoc);
         }
 
         /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
Thu Aug  6 09:32:38 2009
@@ -16,6 +16,19 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.RowIterator;
+
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.security.AccessManager;
@@ -24,19 +37,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.RowIterator;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Map;
-import java.util.LinkedHashMap;
-
 /**
  * Implements the <code>QueryResult</code> interface.
  */

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
Thu Aug  6 09:32:38 2009
@@ -33,7 +33,6 @@
 import java.util.Map;
 import java.util.List;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.HashMap;
 import java.util.Set;
 
@@ -205,7 +204,7 @@
          */
         protected Scorer createScorer(IndexReader reader) {
             return new RangeQueryScorer(searcher.getSimilarity(), reader);
-        };
+        }
 
         /**
          * Returns this <code>RangeQuery</code>.
@@ -279,13 +278,14 @@
         /**
          * The map to store the results.
          */
-        private final Map resultMap;
+        private final Map<String, BitSet> resultMap;
 
         /**
          * Creates a new RangeQueryScorer.
          * @param similarity the similarity implementation.
          * @param reader the index reader to use.
          */
+        @SuppressWarnings({"unchecked"})
         RangeQueryScorer(Similarity similarity, IndexReader reader) {
             super(similarity);
             this.reader = reader;
@@ -302,14 +302,14 @@
             this.cacheKey = key.toString();
             // check cache
             PerQueryCache cache = PerQueryCache.getInstance();
-            Map m = (Map) cache.get(RangeQueryScorer.class, reader);
+            Map<String, BitSet> m = (Map<String, BitSet>) cache.get(RangeQueryScorer.class,
reader);
             if (m == null) {
-                m = new HashMap();
+                m = new HashMap<String, BitSet>();
                 cache.put(RangeQueryScorer.class, reader, m);
             }
             resultMap = m;
 
-            BitSet result = (BitSet) resultMap.get(cacheKey);
+            BitSet result = resultMap.get(cacheKey);
             if (result == null) {
                 result = new BitSet(reader.maxDoc());
             } else {
@@ -380,7 +380,7 @@
             if (propNameLength > 0) {
                 namePrefix = lowerTerm.text().substring(0, propNameLength);
             }
-            List startTerms = new ArrayList(2);
+            List<Term> startTerms = new ArrayList<Term>(2);
 
             if (transform == TRANSFORM_NONE || lowerTerm.text().length() <= propNameLength)
{
                 // use lowerTerm as is
@@ -397,25 +397,20 @@
                 startTerms.add(new Term(lowerTerm.field(), termText.toString()));
             }
 
-            Iterator it = startTerms.iterator();
-            while (it.hasNext()) {
-                Term startTerm = (Term) it.next();
-
+            for (Term startTerm : startTerms) {
                 TermEnum terms = reader.terms(startTerm);
                 try {
                     TermDocs docs = reader.termDocs();
                     try {
                         do {
                             Term term = terms.term();
-                            if (term != null
-                                    && term.field() == testField
-                                    && term.text().startsWith(namePrefix)) {
+                            if (term != null && term.field() == testField &&
term.text().startsWith(namePrefix)) {
                                 if (checkLower) {
                                     int compare = termCompare(term.text(), lowerTerm.text(),
propNameLength);
                                     if (compare > 0 || compare == 0 && inclusive)
{
                                         // do not check lower term anymore if no
                                         // transformation is done on the term enum
-                                        checkLower = transform == TRANSFORM_NONE ? false
: true;
+                                        checkLower = transform != TRANSFORM_NONE;
                                     } else {
                                         // continue with next term
                                         continue;
@@ -452,7 +447,7 @@
                             } else {
                                 break;
                             }
-                        } while(terms.next());
+                        } while (terms.next());
                     } finally {
                         docs.close();
                     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SimpleExcerptProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SimpleExcerptProvider.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SimpleExcerptProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SimpleExcerptProvider.java
Thu Aug  6 09:32:38 2009
@@ -68,8 +68,8 @@
                     text.append(separator);
                     separator = " ... ";
                     InternalValue[] values = propState.getValues();
-                    for (int i = 0; i < values.length; i++) {
-                        text.append(values[i].toString());
+                    for (InternalValue value : values) {
+                        text.append(value.toString());
                     }
                 }
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TermDocsCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TermDocsCache.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TermDocsCache.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TermDocsCache.java
Thu Aug  6 09:32:38 2009
@@ -22,13 +22,12 @@
 import java.util.BitSet;
 import java.util.Arrays;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.TermDocs;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermEnum;
-import org.apache.commons.collections.map.LRUMap;
-import org.apache.commons.collections.map.LinkedMap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -61,13 +60,19 @@
     /**
      * Map of {@link Term#text()} that are unknown to the underlying index.
      */
-    private final Map unknownValues = Collections.synchronizedMap(new LRUMap(100));
+    private final Map<String, String> unknownValues = Collections.synchronizedMap(new
LinkedHashMap<String, String>() {
+        private static final long serialVersionUID = 1443679637070403838L;
+
+        protected boolean removeEldestEntry(Map.Entry<String, String> eldest) {
+            return size() > 100;
+        }
+    });
 
     /**
      * The cache of the {@link #CACHE_SIZE} most frequently requested TermDocs.
      * Maps term text <code>String</code> to {@link CacheEntry}.
      */
-    private final LinkedMap cache = new LinkedMap();
+    private final Map<String, CacheEntry> cache = new LinkedHashMap<String, CacheEntry>();
 
     /**
      * Creates a new cache for the given <code>reader</code> and
@@ -102,23 +107,23 @@
         // maintain cache
         CacheEntry entry;
         synchronized (cache) {
-            entry = (CacheEntry) cache.get(text);
+            entry = cache.get(text);
             if (entry == null) {
                 // check space
                 if (cache.size() >= CACHE_SIZE) {
                     // prune half of them and adjust the rest
-                    CacheEntry[] entries = (CacheEntry[]) cache.values().toArray(
+                    CacheEntry[] entries = cache.values().toArray(
                             new CacheEntry[cache.size()]);
                     Arrays.sort(entries);
                     int threshold = entries[CACHE_SIZE / 2].numAccessed;
-                    for (Iterator it = cache.entrySet().iterator(); it.hasNext(); ) {
-                        Map.Entry e = (Map.Entry) it.next();
-                        if (((CacheEntry) e.getValue()).numAccessed <= threshold) {
+                    for (Iterator<Map.Entry<String, CacheEntry>> it = cache.entrySet().iterator();
it.hasNext(); ) {
+                        Map.Entry<String, CacheEntry> e = it.next();
+                        if (e.getValue().numAccessed <= threshold) {
                             // prune
                             it.remove();
                         } else {
                             // adjust
-                            CacheEntry ce = (CacheEntry) e.getValue();
+                            CacheEntry ce = e.getValue();
                             ce.numAccessed = (int) Math.sqrt(ce.numAccessed);
                         }
                     }
@@ -135,8 +140,7 @@
         if (entry.numAccessed < 10) {
             if (log.isDebugEnabled()) {
                 log.debug("#{} TermDocs({},{})",
-                        new Object[]{new Integer(entry.numAccessed),
-                                field, text});
+                        new Object[]{entry.numAccessed, field, text});
             }
             return reader.termDocs(t);
         }
@@ -167,8 +171,7 @@
         } else {
             if (log.isDebugEnabled()) {
                 log.debug("CachedTermDocs({},{},{}/{})", new Object[]{
-                        field, text, new Integer(entry.bits.cardinality()),
-                        new Integer(reader.maxDoc())});
+                        field, text, entry.bits.cardinality(), reader.maxDoc()});
             }
             return new CachedTermDocs(entry.bits);
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WeightedHighlighter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WeightedHighlighter.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WeightedHighlighter.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WeightedHighlighter.java
Thu Aug  6 09:32:38 2009
@@ -18,6 +18,7 @@
 
 import org.apache.lucene.index.TermPositionVector;
 import org.apache.lucene.index.TermVectorOffsetInfo;
+import org.apache.lucene.index.Term;
 import org.apache.lucene.util.PriorityQueue;
 
 import java.util.Set;
@@ -76,7 +77,7 @@
      *         highlighted
      */
     public static String highlight(TermPositionVector tvec,
-                                   Set queryTerms,
+                                   Set<Term> queryTerms,
                                    String text,
                                    String excerptStart,
                                    String excerptEnd,
@@ -102,7 +103,7 @@
      *         highlighted
      */
     public static String highlight(TermPositionVector tvec,
-                                   Set queryTerms,
+                                   Set<Term> queryTerms,
                                    String text,
                                    int maxFragments,
                                    int surround) throws IOException {
@@ -150,21 +151,21 @@
 
         // retrieve fragment infos from queue and fill into list, least
         // fragment comes out first
-        List infos = new LinkedList();
+        List<FragmentInfo> infos = new LinkedList<FragmentInfo>();
         while (bestFragments.size() > 0) {
             FragmentInfo fi = (FragmentInfo) bestFragments.pop();
             infos.add(0, fi);
         }
 
-        Map offsetInfos = new IdentityHashMap();
+        Map<TermVectorOffsetInfo, Object> offsetInfos = new IdentityHashMap<TermVectorOffsetInfo,
Object>();
         // remove overlapping fragment infos
-        Iterator it = infos.iterator();
+        Iterator<FragmentInfo> it = infos.iterator();
         while (it.hasNext()) {
-            FragmentInfo fi = (FragmentInfo) it.next();
+            FragmentInfo fi = it.next();
             boolean overlap = false;
-            Iterator fit = fi.iterator();
+            Iterator<TermVectorOffsetInfo> fit = fi.iterator();
             while (fit.hasNext() && !overlap) {
-                TermVectorOffsetInfo oi = (TermVectorOffsetInfo) fit.next();
+                TermVectorOffsetInfo oi = fit.next();
                 if (offsetInfos.containsKey(oi)) {
                     overlap = true;
                 }
@@ -172,7 +173,7 @@
             if (overlap) {
                 it.remove();
             } else {
-                Iterator oit = fi.iterator();
+                Iterator<TermVectorOffsetInfo> oit = fi.iterator();
                 while (oit.hasNext()) {
                     offsetInfos.put(oit.next(), null);
                 }
@@ -183,7 +184,7 @@
         StringBuffer sb = new StringBuffer(excerptStart);
         it = infos.iterator();
         while (it.hasNext()) {
-            FragmentInfo fi = (FragmentInfo) it.next();
+            FragmentInfo fi = it.next();
             sb.append(fragmentStart);
             int limit = Math.max(0, fi.getStartOffset() / 2 + fi.getEndOffset() / 2 - surround);
             int len = startFragment(sb, text, fi.getStartOffset(), limit);
@@ -271,14 +272,14 @@
     }
 
     private static class FragmentInfo {
-        ArrayList offsetInfosList;
+        List<TermVectorOffsetInfo> offsetInfosList;
         int startOffset;
         int endOffset;
         int maxFragmentSize;
         int quality;
 
         public FragmentInfo(TermVectorOffsetInfo offsetinfo, int maxFragmentSize) {
-            offsetInfosList = new ArrayList();
+            offsetInfosList = new ArrayList<TermVectorOffsetInfo>();
             offsetInfosList.add(offsetinfo);
             startOffset = offsetinfo.getStartOffset();
             endOffset = offsetinfo.getEndOffset();
@@ -313,7 +314,7 @@
             return true;
         }
 
-        public Iterator iterator() {
+        public Iterator<TermVectorOffsetInfo> iterator() {
             return offsetInfosList.iterator();
         }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
Thu Aug  6 09:32:38 2009
@@ -265,7 +265,7 @@
         /**
          * The map to store the results.
          */
-        private final Map resultMap;
+        private final Map<String, BitSet> resultMap;
 
         /**
          * Creates a new WildcardQueryScorer.
@@ -273,20 +273,21 @@
          * @param similarity the similarity implementation.
          * @param reader     the index reader to use.
          */
+        @SuppressWarnings({"unchecked"})
         WildcardQueryScorer(Similarity similarity, IndexReader reader) {
             super(similarity);
             this.reader = reader;
             this.cacheKey = field + '\uFFFF' + propName + '\uFFFF' + transform + '\uFFFF'
+ pattern;
             // check cache
             PerQueryCache cache = PerQueryCache.getInstance();
-            Map m = (Map) cache.get(WildcardQueryScorer.class, reader);
+            Map<String, BitSet> m = (Map<String, BitSet>) cache.get(WildcardQueryScorer.class,
reader);
             if (m == null) {
-                m = new HashMap();
+                m = new HashMap<String, BitSet>();
                 cache.put(WildcardQueryScorer.class, reader, m);
             }
             resultMap = m;
 
-            BitSet result = (BitSet) resultMap.get(cacheKey);
+            BitSet result = resultMap.get(cacheKey);
             if (result == null) {
                 result = new BitSet(reader.maxDoc());
             } else {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardTermEnum.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardTermEnum.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardTermEnum.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardTermEnum.java
Thu Aug  6 09:32:38 2009
@@ -163,12 +163,12 @@
         /**
          * The matching terms
          */
-        private final Map orderedTerms = new LinkedHashMap();
+        private final Map<Term, Integer> orderedTerms = new LinkedHashMap<Term,
Integer>();
 
         /**
          * Iterator over all matching terms
          */
-        private final Iterator it;
+        private final Iterator<Term> it;
 
         public LowerUpperCaseTermEnum(IndexReader reader,
                                       String field,
@@ -191,7 +191,7 @@
 
             if (!neverMatches) {
                 // create range scans
-                List rangeScans = new ArrayList(2);
+                List<RangeScan> rangeScans = new ArrayList<RangeScan>(2);
                 try {
                     int idx = 0;
                     while (idx < pattern.length()
@@ -228,14 +228,13 @@
                     }
 
                     // do range scans with pattern matcher
-                    for (Iterator it = rangeScans.iterator(); it.hasNext(); ) {
-                        RangeScan scan = (RangeScan) it.next();
+                    for (RangeScan scan : rangeScans) {
                         do {
                             Term t = scan.term();
                             if (t != null) {
                                 input.setBase(t.text());
                                 if (WildcardTermEnum.this.pattern.reset().matches()) {
-                                    orderedTerms.put(t, new Integer(scan.docFreq()));
+                                    orderedTerms.put(t, scan.docFreq());
                                 }
                             }
                         } while (scan.next());
@@ -243,9 +242,7 @@
 
                 } finally {
                     // close range scans
-                    Iterator it = rangeScans.iterator();
-                    while (it.hasNext()) {
-                        RangeScan scan = (RangeScan) it.next();
+                    for (RangeScan scan : rangeScans) {
                         try {
                             scan.close();
                         } catch (IOException e) {
@@ -283,8 +280,8 @@
          * {@inheritDoc}
          */
         public int docFreq() {
-            Integer docFreq = (Integer) orderedTerms.get(current);
-            return docFreq != null ? docFreq.intValue() : 0;
+            Integer docFreq = orderedTerms.get(current);
+            return docFreq != null ? docFreq : 0;
         }
 
         /**
@@ -299,7 +296,7 @@
          * <code>null</code> if there is no next.
          */
         private void getNext() {
-            current = it.hasNext() ? (Term) it.next() : null;
+            current = it.hasNext() ? it.next() : null;
         }
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/AncestorNodeJoin.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/AncestorNodeJoin.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/AncestorNodeJoin.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/AncestorNodeJoin.java
Thu Aug  6 09:32:38 2009
@@ -56,7 +56,7 @@
     /**
      * Reusable list of ancestor document numbers.
      */
-    private final List ancestors = new ArrayList();
+    private final List<Integer> ancestors = new ArrayList<Integer>();
 
     /**
      * Creates a new ancestor node join condition.
@@ -77,11 +77,10 @@
         int idx = getIndex(context, contextSelectorName);
         ScoreNode[] nodes;
         while ((nodes = context.nextScoreNodes()) != null) {
-            Integer docNum = new Integer(nodes[idx].getDoc(reader));
+            Integer docNum = nodes[idx].getDoc(reader);
             ancestors.clear();
-            collectAncestors(docNum.intValue());
-            for (int i = 0; i < ancestors.size(); i++) {
-                Integer doc = (Integer) ancestors.get(i);
+            collectAncestors(docNum);
+            for (Integer doc : ancestors) {
                 contextIndex.addScoreNodes(doc, nodes);
             }
         }
@@ -94,7 +93,7 @@
      */
     public ScoreNode[][] getMatchingScoreNodes(ScoreNode ancestor)
             throws IOException {
-        Integer doc = new Integer(ancestor.getDoc(reader));
+        Integer doc = ancestor.getDoc(reader);
         return contextIndex.getScoreNodes(doc);
     }
 
@@ -108,14 +107,13 @@
     private void collectAncestors(int doc) throws IOException {
         docNums = resolver.getParents(doc, docNums);
         if (docNums.length == 1) {
-            ancestors.add(new Integer(docNums[0]));
+            ancestors.add(docNums[0]);
             collectAncestors(docNums[0]);
         } else if (docNums.length > 1) {
             // clone because recursion uses docNums again
-            int[] tmp = (int[]) docNums.clone();
-            for (int i = 0; i < tmp.length; i++) {
-                ancestors.add(new Integer(tmp[i]));
-                collectAncestors(tmp[i]);
+            for (int docNum : docNums.clone()) {
+                ancestors.add(docNum);
+                collectAncestors(docNum);
             }
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ChildNodeJoin.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ChildNodeJoin.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ChildNodeJoin.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ChildNodeJoin.java
Thu Aug  6 09:32:38 2009
@@ -55,7 +55,7 @@
     /**
      * Reusable list of score nodes.
      */
-    private List tmpScoreNodes = new ArrayList();
+    private List<ScoreNode[]> tmpScoreNodes = new ArrayList<ScoreNode[]>();
 
     /**
      * Creates a new child node join condition.
@@ -77,7 +77,7 @@
         int idx = getIndex(parent, condition.getParentSelectorQName());
         ScoreNode[] nodes;
         while ((nodes = parent.nextScoreNodes()) != null) {
-            Integer docNum = new Integer(nodes[idx].getDoc(reader));
+            Integer docNum = nodes[idx].getDoc(reader);
             parentIndex.addScoreNodes(docNum, nodes);
         }
     }
@@ -90,18 +90,18 @@
     public ScoreNode[][] getMatchingScoreNodes(ScoreNode child) throws IOException {
         docNums = resolver.getParents(child.getDoc(reader), docNums);
         tmpScoreNodes.clear();
-        for (int i = 0; i < docNums.length; i++) {
-            ScoreNode[][] sn = parentIndex.getScoreNodes(new Integer(docNums[i]));
+        for (int docNum : docNums) {
+            ScoreNode[][] sn = parentIndex.getScoreNodes(docNum);
             if (sn != null) {
-                for (int j = 0; j < sn.length; j++) {
-                    tmpScoreNodes.add(sn[j]);
+                for (ScoreNode[] aSn : sn) {
+                    tmpScoreNodes.add(aSn);
                 }
             }
         }
         if (tmpScoreNodes.isEmpty()) {
             return null;
         } else {
-            return (ScoreNode[][]) tmpScoreNodes.toArray(new ScoreNode[tmpScoreNodes.size()][]);
+            return tmpScoreNodes.toArray(new ScoreNode[tmpScoreNodes.size()][]);
         }
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/DescendantNodeJoin.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/DescendantNodeJoin.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/DescendantNodeJoin.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/DescendantNodeJoin.java
Thu Aug  6 09:32:38 2009
@@ -55,12 +55,12 @@
     /**
      * Reusable list of document number.
      */
-    private final List ancestors = new ArrayList();
+    private final List<Integer> ancestors = new ArrayList<Integer>();
 
     /**
      * Reusable list of score nodes.
      */
-    private final List scoreNodes = new ArrayList();
+    private final List<ScoreNode[]> scoreNodes = new ArrayList<ScoreNode[]>();
 
     /**
      * Creates a new descendant node join condition.
@@ -81,7 +81,7 @@
         int idx = getIndex(context, contextSelectorName);
         ScoreNode[] nodes;
         while ((nodes = context.nextScoreNodes()) != null) {
-            Integer docNum = new Integer(nodes[idx].getDoc(reader));
+            Integer docNum = nodes[idx].getDoc(reader);
             contextIndex.addScoreNodes(docNum, nodes);
         }
     }
@@ -96,19 +96,18 @@
         ancestors.clear();
         collectAncestors(descendant.getDoc(reader));
         scoreNodes.clear();
-        for (int i = 0; i < ancestors.size(); i++) {
-            Integer ancestor = (Integer) ancestors.get(i);
+        for (Integer ancestor : ancestors) {
             ScoreNode[][] sn = contextIndex.getScoreNodes(ancestor);
             if (sn != null) {
-                for (int j = 0; j < sn.length; j++) {
-                    scoreNodes.add(sn[j]);
+                for (ScoreNode[] aSn : sn) {
+                    scoreNodes.add(aSn);
                 }
             }
         }
         if (scoreNodes.isEmpty()) {
             return null;
         } else {
-            return (ScoreNode[][]) scoreNodes.toArray(new ScoreNode[scoreNodes.size()][]);
+            return scoreNodes.toArray(new ScoreNode[scoreNodes.size()][]);
         }
     }
 
@@ -122,14 +121,13 @@
     private void collectAncestors(int doc) throws IOException {
         docNums = resolver.getParents(doc, docNums);
         if (docNums.length == 1) {
-            ancestors.add(new Integer(docNums[0]));
+            ancestors.add(docNums[0]);
             collectAncestors(docNums[0]);
         } else if (docNums.length > 1) {
             // clone because recursion uses docNums again
-            int[] tmp = (int[]) docNums.clone();
-            for (int i = 0; i < tmp.length; i++) {
-                ancestors.add(new Integer(tmp[i]));
-                collectAncestors(tmp[i]);
+            for (int docNum : docNums.clone()) {
+                ancestors.add(docNum);
+                collectAncestors(docNum);
             }
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/EquiJoin.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/EquiJoin.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/EquiJoin.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/EquiJoin.java
Thu Aug  6 09:32:38 2009
@@ -77,8 +77,7 @@
         ScoreNode[] nodes;
         // create lookup map
         while ((nodes = inner.nextScoreNodes()) != null) {
-            Integer doc = new Integer(nodes[innerScoreNodeIndex].getDoc(reader));
-            sDoc.doc = doc.intValue();
+            sDoc.doc = nodes[innerScoreNodeIndex].getDoc(reader);
             Comparable value = comparator.sortValue(sDoc);
             if (value != null) {
                 innerScoreNodes.addScoreNodes(value, nodes);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ParentNodeJoin.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ParentNodeJoin.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ParentNodeJoin.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ParentNodeJoin.java
Thu Aug  6 09:32:38 2009
@@ -60,8 +60,7 @@
         int[] docNums = new int[1];
         while ((nodes = child.nextScoreNodes()) != null) {
             docNums = resolver.getParents(nodes[idx].getDoc(reader), docNums);
-            for (int i = 0; i < docNums.length; i++) {
-                Integer parentId = new Integer(docNums[i]);
+            for (int parentId : docNums) {
                 childIndex.addScoreNodes(parentId, nodes);
             }
         }
@@ -73,6 +72,6 @@
      */
     public ScoreNode[][] getMatchingScoreNodes(ScoreNode parent)
             throws IOException {
-        return childIndex.getScoreNodes(new Integer(parent.getDoc(reader)));
+        return childIndex.getScoreNodes(parent.getDoc(reader));
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ScoreNodeMap.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ScoreNodeMap.java?rev=801565&r1=801564&r2=801565&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ScoreNodeMap.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/ScoreNodeMap.java
Thu Aug  6 09:32:38 2009
@@ -32,7 +32,7 @@
     /**
      * The internal map.
      */
-    private final Map map = new HashMap();
+    private final Map<Object, Object> map = new HashMap<Object, Object>();
 
     /**
      * Adds <code>scoreNodes</code> to this map under the given <code>key</code>.
@@ -62,8 +62,8 @@
             ((List) existing).add(nodes);
         } else {
             // ScoreNode[]
-            ArrayList tmp = new ArrayList();
-            tmp.add(existing);
+            List<ScoreNode[]> tmp = new ArrayList<ScoreNode[]>();
+            tmp.add((ScoreNode[]) existing);
             tmp.add(nodes);
             existing = tmp;
             map.put(key, existing);
@@ -83,8 +83,8 @@
         if (sn == null) {
             return null;
         } else if (sn instanceof List) {
-            List list = (List) sn;
-            return (ScoreNode[][]) list.toArray(new ScoreNode[list.size()][]);
+            List<ScoreNode[]> list = (List<ScoreNode[]>) sn;
+            return list.toArray(new ScoreNode[list.size()][]);
         } else {
             // ScoreNode[]
             return new ScoreNode[][]{(ScoreNode[]) sn};



Mime
View raw message