jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1064058 [3/3] - in /jackrabbit/trunk: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/...
Date Thu, 27 Jan 2011 09:33:15 GMT
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java?rev=1064058&r1=1064057&r2=1064058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java
Thu Jan 27 09:33:13 2011
@@ -16,19 +16,20 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.Sort;
-import org.apache.lucene.search.TopFieldDocCollector;
+import org.apache.lucene.search.TopFieldCollector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * Wraps a lucene query result and adds a close method that allows to release
  * resources after a query has been executed and the results have been read
@@ -155,15 +156,14 @@ public final class SortedLuceneQueryHits
     //-------------------------------< internal >-------------------------------
 
     private void getHits() throws IOException {
-        TopFieldDocCollector collector = new TopFieldDocCollector(reader, sort, numHits);
+        TopFieldCollector collector = TopFieldCollector.create(sort, numHits, false, true,
false, false);
         searcher.search(query, collector);
-        this.size = collector.getTotalHits();
+        size = collector.getTotalHits();
         ScoreDoc[] docs = collector.topDocs().scoreDocs;
-        for (int i = scoreDocs.size(); i < docs.length; i++) {
-            scoreDocs.add(docs[i]);
-        }
+        scoreDocs.addAll(Arrays.asList(docs).subList(scoreDocs.size(), docs.length));
         log.debug("getHits() {}/{}", scoreDocs.size(), numHits);
         // double hits for next round
         numHits *= 2;
     }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedMultiColumnQueryHits.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedMultiColumnQueryHits.java?rev=1064058&r1=1064057&r2=1064058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedMultiColumnQueryHits.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedMultiColumnQueryHits.java
Thu Jan 27 09:33:13 2011
@@ -16,19 +16,19 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
+import org.apache.jackrabbit.spi.Name;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.FieldComparator;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.SortField;
+
 import java.io.IOException;
-import java.util.List;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.Arrays;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.SortField;
-import org.apache.lucene.search.ScoreDocComparator;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.jackrabbit.spi.Name;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * <code>SortedMultiColumnQueryHits</code> implements sorting of query hits
@@ -61,7 +61,7 @@ public class SortedMultiColumnQueryHits 
         }
         try {
             Collections.sort(sortedHits, new ScoreNodeComparator(
-                    reader, orderings, hits.getSelectorNames()));
+                    reader, orderings, hits.getSelectorNames(), sortedHits.size()));
         } catch (RuntimeException e) {
             // might be thrown by ScoreNodeComparator#compare
             throw Util.createIOException(e);
@@ -142,7 +142,8 @@ public class SortedMultiColumnQueryHits 
          */
         private ScoreNodeComparator(IndexReader reader,
                                     Ordering[] orderings,
-                                    Name[] selectorNames)
+                                    Name[] selectorNames,
+                                    int numHits)
                 throws IOException {
             this.reader = reader;
             this.orderings = orderings;
@@ -153,8 +154,11 @@ public class SortedMultiColumnQueryHits 
             for (int i = 0; i < orderings.length; i++) {
                 idx[i] = names.indexOf(orderings[i].getSelectorName());
                 SortField sf = orderings[i].getSortField();
-                if (sf.getFactory() != null) {
-                    comparators[i] = sf.getFactory().newComparator(reader, sf.getField());
+                if (sf.getComparatorSource() != null) {
+                    FieldComparator c = sf.getComparatorSource().newComparator(sf.getField(),
numHits, 0, false);
+                    assert c instanceof FieldComparatorBase;
+                    comparators[i] = new ScoreDocComparator((FieldComparatorBase) c);
+                    comparators[i].setNextReader(reader, 0);
                 }
                 isReverse[i] = sf.getReverse();
             }
@@ -184,7 +188,7 @@ public class SortedMultiColumnQueryHits 
                     } catch (IOException e) {
                         throw new RuntimeException(e.getMessage(), e);
                     }
-                    c = comparators[i].compare(doc1, doc2);
+                    c = comparators[i].compareDocs(doc1.doc, doc2.doc);
                 } else {
                     // compare score
                     c = new Float(n1.getScore()).compareTo(n2.getScore());
@@ -198,5 +202,19 @@ public class SortedMultiColumnQueryHits 
             }
             return 0;
         }
+
     }
+
+    private static final class ScoreDocComparator extends FieldComparatorDecorator {
+
+        public ScoreDocComparator(FieldComparatorBase base) {
+            super(base);
+        }
+
+        public int compareDocs(int doc1, int doc2) {
+            return compare(sortValue(doc1), sortValue(doc2));
+        }
+
+    }
+
 }

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=1064058&r1=1064057&r2=1064058&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 Jan 27 09:33:13 2011
@@ -94,7 +94,7 @@ public class TermDocsCache {
      * @throws IOException if an error occurs while reading from the index.
      */
     public TermDocs termDocs(final Term t) throws IOException {
-        if (t.field() != field) {
+        if (t == null || t.field() != field) {
             return reader.termDocs(t);
         }
 
@@ -270,14 +270,13 @@ public class TermDocsCache {
         }
     }
 
-    private static final class CacheEntry implements Comparable {
+    private static final class CacheEntry implements Comparable<CacheEntry> {
 
         private volatile int numAccessed = 1;
 
         private volatile BitSet bits;
 
-        public int compareTo(Object o) {
-            CacheEntry other = (CacheEntry) o;
+        public int compareTo(CacheEntry other) {
             return (numAccessed < other.numAccessed ? -1 : (numAccessed == other.numAccessed
? 0 : 1));
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/UpperCaseSortComparator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/UpperCaseSortComparator.java?rev=1064058&r1=1064057&r2=1064058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/UpperCaseSortComparator.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/UpperCaseSortComparator.java
Thu Jan 27 09:33:13 2011
@@ -16,71 +16,43 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.io.IOException;
+import org.apache.lucene.search.FieldComparator;
+import org.apache.lucene.search.FieldComparatorSource;
 
-import org.apache.lucene.search.ScoreDocComparator;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.SortField;
-import org.apache.lucene.search.SortComparatorSource;
-import org.apache.lucene.index.IndexReader;
+import java.io.IOException;
 
 /**
- * <code>UpperCaseSortComparator</code> implements a sort comparator that
+ * <code>UpperCaseSortComparator</code> implements a <code>FieldComparator</code>
which
  * compares the upper-cased string values of a base sort comparator.
  */
-public class UpperCaseSortComparator implements SortComparatorSource {
-
-    private static final long serialVersionUID = 2562371983498948119L;
+public class UpperCaseSortComparator extends FieldComparatorSource {
     
     /**
      * The base sort comparator.
      */
-    private final SortComparatorSource base;
+    private final FieldComparatorSource base;
 
     /**
      * Creates a new upper case sort comparator.
      *
      * @param base the base sort comparator source.
      */
-    public UpperCaseSortComparator(SortComparatorSource base) {
+    public UpperCaseSortComparator(FieldComparatorSource base) {
         this.base = base;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public ScoreDocComparator newComparator(IndexReader reader,
-                                            String fieldname)
-            throws IOException {
-        return new Comparator(base.newComparator(reader, fieldname));
-    }
-
-    private static final class Comparator implements ScoreDocComparator {
-
-        private ScoreDocComparator base;
-
-        private Comparator(ScoreDocComparator base) {
-            this.base = base;
-        }
-
-        /**
-         * @see Util#compare(Comparable, Comparable)
-         */
-        public int compare(ScoreDoc i, ScoreDoc j) {
-            return Util.compare(sortValue(i), sortValue(j));
-        }
-
-        public Comparable sortValue(ScoreDoc i) {
-            Comparable c = base.sortValue(i);
-            if (c != null) {
-                return c.toString().toUpperCase();
-            } else {
-                return null;
+    @Override
+    public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean
reversed) throws IOException {
+        FieldComparator comparator = base.newComparator(fieldname, numHits, sortPos, reversed);
+        assert comparator instanceof FieldComparatorBase;
+
+        return new FieldComparatorDecorator((FieldComparatorBase) comparator) {
+            @Override
+            protected Comparable sortValue(int doc) {
+                Comparable c = super.sortValue(doc);
+                return c == null ? null : c.toString().toUpperCase();
             }
-        }
-
-        public int sortType() {
-            return SortField.CUSTOM;
-        }
+        };
     }
-}
\ No newline at end of file
+
+}

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/VolatileIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/VolatileIndex.java?rev=1064058&r1=1064057&r2=1064058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/VolatileIndex.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/VolatileIndex.java
Thu Jan 27 09:33:13 2011
@@ -39,7 +39,8 @@ class VolatileIndex extends AbstractInde
     /**
      * Map of pending documents to add to the index
      */
-    private final Map pending = new LinkedMap();
+    @SuppressWarnings("unchecked")
+    private final Map<String, Document> pending = new LinkedMap();
 
     /**
      * Number of documents that are buffered before they are added to the index.

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=1064058&r1=1064057&r2=1064058&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 Jan 27 09:33:13 2011
@@ -140,7 +140,7 @@ public class WeightedHighlighter extends
                         break;
                     }
                 }
-                bestFragments.insert(fi);
+                bestFragments.insertWithOverflow(fi);
             }
         }
 
@@ -189,7 +189,7 @@ public class WeightedHighlighter extends
             int limit = Math.max(0, fi.getStartOffset() / 2 + fi.getEndOffset() / 2 - surround);
             int len = startFragment(sb, text, fi.getStartOffset(), limit);
             TermVectorOffsetInfo lastOffsetInfo = null;
-            Iterator fIt = fi.iterator();
+            Iterator<TermVectorOffsetInfo> fIt = fi.iterator();
             while (fIt.hasNext()) {
                 TermVectorOffsetInfo oi = (TermVectorOffsetInfo) fIt.next();
                 if (lastOffsetInfo != null) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardNameQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardNameQuery.java?rev=1064058&r1=1064057&r2=1064058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardNameQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardNameQuery.java
Thu Jan 27 09:33:13 2011
@@ -16,18 +16,9 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.io.IOException;
-
 import javax.jcr.NamespaceException;
 
-import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.FilteredTermEnum;
-import org.apache.lucene.search.MultiTermQuery;
-import org.apache.lucene.search.Query;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

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=1064058&r1=1064057&r2=1064058&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 Jan 27 09:33:13 2011
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core.query.lucene;
 
 import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermEnum;
 import org.apache.lucene.index.TermDocs;
 import org.apache.lucene.search.FilteredTermEnum;
@@ -29,6 +28,7 @@ import org.apache.lucene.search.Searcher
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.Similarity;
+import org.apache.lucene.util.ToStringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,6 +48,7 @@ import java.util.Set;
  * <li><code>_</code> : matches exactly one character</li>
  * </ul>
  */
+@SuppressWarnings("serial")
 public class WildcardQuery extends Query implements Transformable {
 
     /**
@@ -140,11 +141,22 @@ public class WildcardQuery extends Query
      * @return the rewritten query.
      * @throws IOException if an error occurs while reading from the index.
      */
+    @Override
     public Query rewrite(IndexReader reader) throws IOException {
-        Query stdWildcardQuery = new MultiTermQuery(new Term(field, pattern)) {
+        Query stdWildcardQuery = new MultiTermQuery() {
             protected FilteredTermEnum getEnum(IndexReader reader) throws IOException {
                 return new WildcardTermEnum(reader, field, tvf, pattern, transform);
             }
+
+            /** Prints a user-readable version of this query. */
+            @Override
+            public String toString(String field) {
+                StringBuffer buffer = new StringBuffer();
+                buffer.append(field);
+                buffer.append(':');
+                buffer.append(ToStringUtils.boost(getBoost()));
+                return buffer.toString();
+            }
         };
         try {
             multiTermQuery = stdWildcardQuery.rewrite(reader);
@@ -162,7 +174,8 @@ public class WildcardQuery extends Query
      * @param searcher the searcher to use for the <code>Weight</code>.
      * @return the <code>Weigth</code> for this query.
      */
-    protected Weight createWeight(Searcher searcher) {
+    @Override
+    public Weight createWeight(Searcher searcher) {
         return new WildcardQueryWeight(searcher, cache);
     }
 
@@ -172,13 +185,12 @@ public class WildcardQuery extends Query
      * @param field the field name for which to create a string representation.
      * @return a string representation of this query.
      */
+    @Override
     public String toString(String field) {
         return field + ":" + tvf.createValue(pattern);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    @Override
     public void extractTerms(Set terms) {
         if (multiTermQuery != null) {
             multiTermQuery.extractTerms(terms);
@@ -209,7 +221,8 @@ public class WildcardQuery extends Query
          * @param reader index reader
          * @return a {@link WildcardQueryScorer} instance
          */
-        protected Scorer createScorer(IndexReader reader) {
+        protected Scorer createScorer(IndexReader reader, boolean scoreDocsInOrder,
+                boolean topScorer) {
             return new WildcardQueryScorer(searcher.getSimilarity(), reader, cache);
         }
 
@@ -218,33 +231,26 @@ public class WildcardQuery extends Query
          *
          * @return this <code>WildcardQuery</code>.
          */
+        @Override
         public Query getQuery() {
             return WildcardQuery.this;
         }
 
-        /**
-         * {@inheritDoc}
-         */
+        @Override
         public float getValue() {
             return 1.0f;
         }
 
-        /**
-         * {@inheritDoc}
-         */
+        @Override
         public float sumOfSquaredWeights() throws IOException {
             return 1.0f;
         }
 
-        /**
-         * {@inheritDoc}
-         */
+        @Override
         public void normalize(float norm) {
         }
 
-        /**
-         * {@inheritDoc}
-         */
+        @Override
         public Explanation explain(IndexReader reader, int doc) throws IOException {
             return new Explanation();
         }
@@ -315,44 +321,42 @@ public class WildcardQuery extends Query
             hits = result;
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean next() throws IOException {
+        @Override
+        public int nextDoc() throws IOException {
+            if (nextDoc == NO_MORE_DOCS) {
+                return nextDoc;
+            }
+
             calculateHits();
             nextDoc = hits.nextSetBit(nextDoc + 1);
-            return nextDoc > -1;
+            if (nextDoc < 0) {
+                nextDoc = NO_MORE_DOCS;
+            }
+            return nextDoc;
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public int doc() {
+        @Override
+        public int docID() {
             return nextDoc;
         }
 
-        /**
-         * {@inheritDoc}
-         */
+        @Override
         public float score() {
             return 1.0f;
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean skipTo(int target) throws IOException {
+        @Override
+        public int advance(int target) throws IOException {
+            if (nextDoc == NO_MORE_DOCS) {
+                return nextDoc;
+            }
+
             calculateHits();
             nextDoc = hits.nextSetBit(target);
-            return nextDoc > -1;
-        }
-
-        /**
-         * Returns an empty Explanation object.
-         * @return an empty Explanation object.
-         */
-        public Explanation explain(int doc) {
-            return new Explanation();
+            if (nextDoc < 0) {
+                nextDoc = NO_MORE_DOCS;
+            }
+            return nextDoc;
         }
 
         /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/directory/FSDirectoryManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/directory/FSDirectoryManager.java?rev=1064058&r1=1064057&r2=1064058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/directory/FSDirectoryManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/directory/FSDirectoryManager.java
Thu Jan 27 09:33:13 2011
@@ -16,10 +16,6 @@
  */
 package org.apache.jackrabbit.core.query.lucene.directory;
 
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-
 import org.apache.jackrabbit.core.query.lucene.IOCounters;
 import org.apache.jackrabbit.core.query.lucene.SearchIndex;
 import org.apache.lucene.store.Directory;
@@ -30,6 +26,10 @@ import org.apache.lucene.store.Lock;
 import org.apache.lucene.store.LockFactory;
 import org.apache.lucene.store.NativeFSLockFactory;
 
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+
 /**
  * <code>FSDirectoryManager</code> implements a directory manager for
  * {@link FSDirectory} instances.
@@ -141,11 +141,17 @@ public class FSDirectoryManager implemen
         private final FSDirectory directory;
 
         public FSDir(File dir) throws IOException {
-            directory = FSDirectory.getDirectory(dir,
+            if (!dir.mkdirs()) {
+                if (!dir.isDirectory()) {
+                    throw new IOException("Unable to create directory: '" + dir + "'");
+                }
+            }
+            directory = FSDirectory.open(dir,
                     new NativeFSLockFactory(dir));
         }
 
-        public String[] list() throws IOException {
+        @Override
+        public String[] listAll() throws IOException {
             File[] files = directory.getFile().listFiles(FILTER);
             if (files == null) {
                 return null;
@@ -157,71 +163,81 @@ public class FSDirectoryManager implemen
             return names;
         }
 
+        @Override
         public boolean fileExists(String name) throws IOException {
             return directory.fileExists(name);
         }
 
+        @Override
         public long fileModified(String name) throws IOException {
             return directory.fileModified(name);
         }
 
+        @Override
         public void touchFile(String name) throws IOException {
             directory.touchFile(name);
         }
 
+        @Override
         public void deleteFile(String name) throws IOException {
             directory.deleteFile(name);
         }
 
-        public void renameFile(String from, String to) throws IOException {
-            directory.renameFile(from, to);
-        }
-
+        @Override
         public long fileLength(String name) throws IOException {
             return directory.fileLength(name);
         }
 
+        @Override
         public IndexOutput createOutput(String name) throws IOException {
             return directory.createOutput(name);
         }
 
+        @Override
         public IndexInput openInput(String name) throws IOException {
             IndexInput in = directory.openInput(name);
             return new IndexInputLogWrapper(in);
         }
 
+        @Override
         public void close() throws IOException {
             directory.close();
         }
 
+        @Override
         public IndexInput openInput(String name, int bufferSize)
                 throws IOException {
             IndexInput in = directory.openInput(name, bufferSize);
             return new IndexInputLogWrapper(in);
         }
 
+        @Override
         public Lock makeLock(String name) {
             return directory.makeLock(name);
         }
 
+        @Override
         public void clearLock(String name) throws IOException {
             directory.clearLock(name);
         }
 
+        @Override
         public void setLockFactory(LockFactory lockFactory) {
             directory.setLockFactory(lockFactory);
         }
 
+        @Override
         public LockFactory getLockFactory() {
             return directory.getLockFactory();
         }
 
+        @Override
         public String getLockID() {
             return directory.getLockID();
         }
 
         public String toString() {
-            return this.getClass().getName() + "@" + directory;
+            return getClass().getName() + '@' + directory;
         }
     }
 
@@ -237,27 +253,33 @@ public class FSDirectoryManager implemen
             this.in = in;
         }
 
+        @Override
         public byte readByte() throws IOException {
             return in.readByte();
         }
 
+        @Override
         public void readBytes(byte[] b, int offset, int len) throws IOException {
             IOCounters.incrRead();
             in.readBytes(b, offset, len);
         }
 
+        @Override
         public void close() throws IOException {
             in.close();
         }
 
+        @Override
         public long getFilePointer() {
             return in.getFilePointer();
         }
 
+        @Override
         public void seek(long pos) throws IOException {
             in.seek(pos);
         }
 
+        @Override
         public long length() {
             return in.length();
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/hits/ScorerHits.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/hits/ScorerHits.java?rev=1064058&r1=1064057&r2=1064058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/hits/ScorerHits.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/hits/ScorerHits.java
Thu Jan 27 09:33:13 2011
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.core.query
 
 import java.io.IOException;
 
+import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.Scorer;
 
 /**
@@ -42,8 +43,9 @@ public class ScorerHits implements Hits 
      * {@inheritDoc}
      */
     public int next() throws IOException {
-        if (scorer.next()) {
-            return scorer.doc();
+        int docId = scorer.nextDoc();
+        if (docId != DocIdSetIterator.NO_MORE_DOCS) {
+            return docId;
         } else {
             return -1;
         }
@@ -53,8 +55,9 @@ public class ScorerHits implements Hits 
      * {@inheritDoc}
      */
     public int skipTo(int target) throws IOException {
-        if (scorer.skipTo(target)) {
-            return scorer.doc();
+        int docId = scorer.advance(target);
+        if (docId != DocIdSetIterator.NO_MORE_DOCS) {
+            return docId;
         } else {
             return -1;
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/SameNodeJoinMerger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/SameNodeJoinMerger.java?rev=1064058&r1=1064057&r2=1064058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/SameNodeJoinMerger.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/SameNodeJoinMerger.java
Thu Jan 27 09:33:13 2011
@@ -33,8 +33,6 @@ import javax.jcr.query.qom.PropertyValue
 import javax.jcr.query.qom.QueryObjectModelFactory;
 import javax.jcr.query.qom.SameNodeJoinCondition;
 
-import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
-
 class SameNodeJoinMerger extends JoinMerger {
 
     private final String selector1;

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=1064058&r1=1064057&r2=1064058&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 Jan 27 09:33:13 2011
@@ -59,7 +59,9 @@ public final class ScoreNodeMap {
             existing = nodes;
             map.put(key, existing);
         } else if (existing instanceof List) {
-            ((List) existing).add(nodes);
+            @SuppressWarnings("unchecked")
+            List<ScoreNode[]> existingNodes = (List<ScoreNode[]>) existing;
+            existingNodes.add(nodes);
         } else {
             // ScoreNode[]
             List<ScoreNode[]> tmp = new ArrayList<ScoreNode[]>();
@@ -83,6 +85,7 @@ public final class ScoreNodeMap {
         if (sn == null) {
             return null;
         } else if (sn instanceof List) {
+            @SuppressWarnings("unchecked")
             List<ScoreNode[]> list = (List<ScoreNode[]>) sn;
             return list.toArray(new ScoreNode[list.size()][]);
         } else {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java?rev=1064058&r1=1064057&r2=1064058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java
Thu Jan 27 09:33:13 2011
@@ -16,12 +16,7 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
+import junit.framework.TestCase;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -31,8 +26,13 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermEnum;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
 
-import junit.framework.TestCase;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
 
 /**
  * <code>ChainedTermEnumTest</code> implements a test for JCR-2410.
@@ -61,7 +61,7 @@ public class ChainedTermEnumTest extends
     protected TermEnum createTermEnum(String prefix, int numTerms)
             throws IOException {
         Directory dir = new RAMDirectory();
-        IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(),
+        IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_24),
                 true, IndexWriter.MaxFieldLength.UNLIMITED);
         for (int i = 0; i < numTerms; i++) {
             Document doc = new Document();
@@ -70,7 +70,7 @@ public class ChainedTermEnumTest extends
             writer.addDocument(doc);
         }
         writer.close();
-        IndexReader reader = IndexReader.open(dir);
+        IndexReader reader = IndexReader.open(dir, false);
         TermEnum terms = reader.terms();
         if (terms.term() == null) {
             // position at first term

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java?rev=1064058&r1=1064057&r2=1064058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java
Thu Jan 27 09:33:13 2011
@@ -16,10 +16,7 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
+import junit.framework.TestCase;
 import org.apache.jackrabbit.core.query.lucene.directory.DirectoryManager;
 import org.apache.jackrabbit.core.query.lucene.directory.RAMDirectoryManager;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
@@ -27,8 +24,11 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.search.Similarity;
 import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
 
-import junit.framework.TestCase;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
 
 /**
  * <code>IndexMigrationTest</code> contains a test case for JCR-2393.
@@ -50,7 +50,7 @@ public class IndexMigrationTest extends 
         DirectoryManager dirMgr = new RAMDirectoryManager();
 
         PersistentIndex idx = new PersistentIndex("index",
-                new StandardAnalyzer(), Similarity.getDefault(),
+                new StandardAnalyzer(Version.LUCENE_24), Similarity.getDefault(),
                 new DocNumberCache(100),
                 new IndexingQueue(new IndexingQueueStore(new RAMDirectory())),
                 dirMgr, 0);

Modified: jackrabbit/trunk/jackrabbit-parent/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-parent/pom.xml?rev=1064058&r1=1064057&r2=1064058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-parent/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-parent/pom.xml Thu Jan 27 09:33:13 2011
@@ -257,7 +257,7 @@
       <dependency>
         <groupId>org.apache.lucene</groupId>
         <artifactId>lucene-core</artifactId>
-        <version>2.4.1</version>
+        <version>3.0.3</version>
       </dependency>
       <dependency>
         <groupId>org.apache.tika</groupId>



Mime
View raw message