jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1062799 - in /jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/query/lucene/ test/java/org/apache/jackrabbit/core/query/lucene/
Date Mon, 24 Jan 2011 14:32:06 GMT
Author: mduerig
Date: Mon Jan 24 14:32:05 2011
New Revision: 1062799

URL: http://svn.apache.org/viewvc?rev=1062799&view=rev
Log:
JCR-2415 Update Lucene to 3.0
- closing token stream
- removed usage of deprecated methods of DocIdSetIterator
- removed deprecated usage of Token class
- eomved deprecated usage of StandardAnalyzer
- various minor improvements

Modified:
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MoreLikeThis.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ReadOnlyIndexReader.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingletonTokenStream.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java
    jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java Mon Jan 24 14:32:05 2011
@@ -250,6 +250,7 @@ public abstract class AbstractExcerpt im
                 termMap.put(termText, info);
             }
             ts.end();
+            ts.close();
         } catch (IOException e) {
             // should never happen, we are reading from a string
         }

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java Mon Jan 24 14:32:05 2011
@@ -387,52 +387,48 @@ class ChildAxisQuery extends Query imple
             this.hResolver = hResolver;
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean next() throws IOException {
+        @Override
+        public int nextDoc() throws IOException {
+            if (nextDoc == NO_MORE_DOCS) {
+                return nextDoc;
+            }
+
             calculateChildren();
             do {
                 nextDoc = hits.next();
             } while (nextDoc > -1 && !indexIsValid(nextDoc));
 
-            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() throws IOException {
             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;
+            }
+
             calculateChildren();
             nextDoc = hits.skipTo(target);
             while (nextDoc > -1 && !indexIsValid(nextDoc)) {
-                next();
+                nextDoc();
             }
-            return nextDoc > -1;
-        }
-
-        /**
-         * {@inheritDoc}
-         *
-         * @throws UnsupportedOperationException this implementation always
-         *                                       throws an <code>UnsupportedOperationException</code>.
-         */
-        public Explanation explain(int doc) throws IOException {
-            throw new UnsupportedOperationException();
+            if (nextDoc < 0) {
+                nextDoc = NO_MORE_DOCS;
+            }
+            return nextDoc;
         }
 
         private void calculateChildren() throws IOException {

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java Mon Jan 24 14:32:05 2011
@@ -258,46 +258,42 @@ class DerefQuery extends Query {
             this.hits = new BitSet(reader.maxDoc());
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean next() throws IOException {
+        @Override
+        public int nextDoc() throws IOException {
+            if (nextDoc == NO_MORE_DOCS) {
+                return nextDoc;
+            }
+
             calculateChildren();
             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() throws IOException {
             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;
+            }
+
             calculateChildren();
             nextDoc = hits.nextSetBit(target);
-            return nextDoc > -1;
-        }
-
-        /**
-         * {@inheritDoc}
-         *
-         * @throws UnsupportedOperationException this implementation always
-         *                                       throws an <code>UnsupportedOperationException</code>.
-         */
-        public Explanation explain(int doc) throws IOException {
-            throw new UnsupportedOperationException();
+            if (nextDoc < 0) {
+                nextDoc = NO_MORE_DOCS;
+            }
+            return nextDoc;
         }
 
         /**

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java Mon Jan 24 14:32:05 2011
@@ -16,17 +16,16 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
 import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Searcher;
 import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.Weight;
 import org.apache.lucene.search.Sort;
-import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
+import org.apache.lucene.search.Weight;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,10 +33,10 @@ import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import java.io.IOException;
 import java.util.BitSet;
-import java.util.Set;
+import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeMap;
-import java.util.Iterator;
 
 /**
  * Implements a lucene <code>Query</code> which filters a sub query by checking
@@ -432,6 +431,11 @@ class DescendantSelfAxisQuery extends Qu
         private final int[] singleDoc = new int[1];
 
         /**
+         * The next document id to be returned
+         */
+        private int currentDoc = -1;
+
+        /**
          * Creates a new <code>DescendantSelfAxisScorer</code>.
          *
          * @param similarity the <code>Similarity</code> instance to use.
@@ -447,51 +451,50 @@ class DescendantSelfAxisQuery extends Qu
             this.contextHits = new BitSet(reader.maxDoc());
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean next() throws IOException {
-            collectContextHits();
-            int nextDoc = subScorer.nextDoc();
-            if (nextDoc == DocIdSetIterator.NO_MORE_DOCS || contextHits.isEmpty()) {
-                return false;
+        @Override
+        public int nextDoc() throws IOException {
+            if (currentDoc == NO_MORE_DOCS) {
+                return currentDoc;
             }
-            while (nextDoc != DocIdSetIterator.NO_MORE_DOCS) {
 
-                if (isValid(nextDoc)) {
-                    return true;
+            collectContextHits();
+            currentDoc = subScorer.nextDoc();
+            if (contextHits.isEmpty()) {
+                currentDoc = NO_MORE_DOCS;
+            }
+            while (currentDoc != NO_MORE_DOCS) {
+                if (isValid(currentDoc)) {
+                    return currentDoc;
                 }
 
                 // try next
-                nextDoc = subScorer.nextDoc();
+                currentDoc = subScorer.nextDoc();
             }
-            return false;
+            return currentDoc;
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public int doc() {
-            return subScorer.docID();
+        @Override
+        public int docID() {
+            return currentDoc;
         }
 
-        /**
-         * {@inheritDoc}
-         */
+        @Override
         public float score() throws IOException {
             return subScorer.score();
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean skipTo(int target) throws IOException {
-            int docId = subScorer.nextDoc();
-            if (docId != DocIdSetIterator.NO_MORE_DOCS) {
-                collectContextHits();
-                return isValid(docId) || next();
+        @Override
+        public int advance(int target) throws IOException {
+            if (currentDoc == NO_MORE_DOCS) {
+                return currentDoc;
+            }
+
+            currentDoc = subScorer.nextDoc();
+            if (currentDoc == NO_MORE_DOCS) {
+                return NO_MORE_DOCS;
             } else {
-                return false;
+                collectContextHits();
+                return isValid(currentDoc) ? currentDoc : nextDoc();
             }
         }
 
@@ -518,14 +521,6 @@ class DescendantSelfAxisQuery extends Qu
         }
 
         /**
-         * @throws UnsupportedOperationException this implementation always
-         *                                       throws an <code>UnsupportedOperationException</code>.
-         */
-        public Explanation explain(int doc) throws IOException {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
          * Returns <code>true</code> if <code>doc</code> is a valid match from
          * the sub scorer against the context hits. The caller must ensure
          * that the context hits are calculated before this method is called!

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java Mon Jan 24 14:32:05 2011
@@ -21,14 +21,13 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermDocs;
 import org.apache.lucene.index.TermEnum;
 import org.apache.lucene.search.Collector;
-import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Similarity;
 
 import java.io.IOException;
 import java.util.BitSet;
-import java.util.Map;
 import java.util.HashMap;
+import java.util.Map;
 
 /**
  * The MatchAllScorer implements a Scorer that scores / collects all
@@ -57,11 +56,6 @@ class MatchAllScorer extends Scorer {
     private BitSet docFilter;
 
     /**
-     * Explanation object. the same for all docs
-     */
-    private final Explanation matchExpl;
-
-    /**
      * Creates a new MatchAllScorer.
      *
      * @param reader the IndexReader
@@ -74,59 +68,49 @@ class MatchAllScorer extends Scorer {
         super(Similarity.getDefault());
         this.reader = reader;
         this.field = field;
-        matchExpl
-                = new Explanation(Similarity.getDefault().idf(reader.maxDoc(),
-                        reader.maxDoc()),
-                        "matchAll");
         calculateDocFilter(cache);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    @Override
     public void score(Collector collector) throws IOException {
         collector.setScorer(this);
 
-        while (next()) {
-            collector.collect(doc());
+        while (nextDoc() != NO_MORE_DOCS) {
+            collector.collect(docID());
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean next() throws IOException {
+    @Override
+    public int nextDoc() throws IOException {
+        if (nextDoc == NO_MORE_DOCS) {
+            return nextDoc;
+        }
+
         nextDoc = docFilter.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() throws IOException {
         return 1.0f;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean skipTo(int target) throws IOException {
-        nextDoc = target - 1;
-        return next();
-    }
+    @Override
+    public int advance(int target) throws IOException {
+        if (nextDoc == NO_MORE_DOCS) {
+            return nextDoc;
+        }
 
-    /**
-     * {@inheritDoc}
-     */
-    public Explanation explain(int doc) {
-        return matchExpl;
+        nextDoc = target - 1;
+        return nextDoc();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MoreLikeThis.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MoreLikeThis.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MoreLikeThis.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MoreLikeThis.java Mon Jan 24 14:32:05 2011
@@ -755,6 +755,8 @@ public final class MoreLikeThis {
                 cnt.x++;
             }
         }
+        ts.end();
+        ts.close();
     }
 
     /** determines if the passed term is likely to be of interest in "more like" comparisons

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java Mon Jan 24 14:32:05 2011
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Similarity;
 
@@ -42,12 +41,12 @@ class MultiScorer extends Scorer {
     /**
      * Index of the current scorer.
      */
-    private int current = 0;
+    private int currentScorer;
 
     /**
-     * Indicates if there are more documents.
+     * The next document id to be returned
      */
-    private boolean hasNext = true;
+    private int currentDoc = -1;
 
     /**
      * Creates a new <code>MultiScorer</code> that spans multiple
@@ -63,52 +62,52 @@ class MultiScorer extends Scorer {
         this.starts = starts;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean next() throws IOException {
-        while (hasNext) {
-            if (scorers[current].nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
-                return true;
-            } else if (++current < scorers.length) {
+    @Override
+    public int nextDoc() throws IOException {
+        while (currentDoc != NO_MORE_DOCS) {
+            if (scorers[currentScorer].nextDoc() != NO_MORE_DOCS) {
+                currentDoc = scorers[currentScorer].docID() + starts[currentScorer];
+                return currentDoc;
+            } else if (++currentScorer < scorers.length) {
                 // advance to next scorer
             } else {
                 // no more scorers
-                hasNext = false;
+                currentDoc = NO_MORE_DOCS;
             }
         }
-        return hasNext;
+
+        return currentDoc;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public int doc() {
-        return scorers[current].docID() + starts[current];
+    @Override
+    public int docID() {
+        return currentDoc;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    @Override
     public float score() throws IOException {
-        return scorers[current].score();
+        return scorers[currentScorer].score();
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean skipTo(int target) throws IOException {
-        current = scorerIndex(target);
-        if (scorers[current].advance(target - starts[current]) != DocIdSetIterator.NO_MORE_DOCS) {
-            return true;
+    @Override
+    public int advance(int target) throws IOException {
+        if (currentDoc == NO_MORE_DOCS) {
+            return currentDoc;
+        }
+
+        currentScorer = scorerIndex(target);
+        if (scorers[currentScorer].advance(target - starts[currentScorer]) != NO_MORE_DOCS) {
+            currentDoc = scorers[currentScorer].docID() + starts[currentScorer];
+            return currentDoc;
         } else {
-            if (++current < scorers.length) {
+            if (++currentScorer < scorers.length) {
                 // simply move to the next if there is any
-                return next();
+                currentDoc = nextDoc();
+                return currentDoc;
             } else {
                 // no more document
-                hasNext = false;
-                return hasNext;
+                currentDoc = NO_MORE_DOCS;
+                return currentDoc;
             }
         }
     }

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java Mon Jan 24 14:32:05 2011
@@ -16,19 +16,6 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.math.BigDecimal;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.Executor;
-
-import javax.jcr.NamespaceException;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
@@ -50,6 +37,18 @@ import org.apache.tika.parser.Parser;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.NamespaceException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import java.math.BigDecimal;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Executor;
+
 /**
  * Creates a lucene <code>Document</code> object from a {@link javax.jcr.Node}.
  */
@@ -369,7 +368,7 @@ public class NodeIndexer {
                     // never fulltext index jcr:uuid String
                     if (name.equals(NameConstants.JCR_UUID)) {
                         addStringValue(doc, fieldName, value.getString(),
-                                false, false, DEFAULT_BOOST);
+                                false, false, DEFAULT_BOOST, true);
                     } else {
                         addStringValue(doc, fieldName, value.getString(),
                                 true, isIncludedInNodeIndex(name),
@@ -666,7 +665,7 @@ public class NodeIndexer {
      *             addStringValue(Document, String, Object, boolean)} instead.
      */
     protected void addStringValue(Document doc, String fieldName, Object internalValue) {
-        addStringValue(doc, fieldName, internalValue, true, true, DEFAULT_BOOST);
+        addStringValue(doc, fieldName, internalValue, true, true, DEFAULT_BOOST, true);
     }
 
     /**
@@ -682,7 +681,7 @@ public class NodeIndexer {
      */
     protected void addStringValue(Document doc, String fieldName,
                                   Object internalValue, boolean tokenized) {
-        addStringValue(doc, fieldName, internalValue, tokenized, true, DEFAULT_BOOST);
+        addStringValue(doc, fieldName, internalValue, tokenized, true, DEFAULT_BOOST, true);
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java Mon Jan 24 14:32:05 2011
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core.query.lucene;
 
 import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Scorer;
@@ -180,14 +179,16 @@ class NotQuery extends Query {
             this.reader = reader;
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean next() throws IOException {
+        @Override
+        public int nextDoc() throws IOException {
+            if (docNo == NO_MORE_DOCS) {
+                return docNo;
+            }
+
             if (docNo == -1) {
                 // get first doc of context scorer
                 int docId = contextScorer.nextDoc();
-                if (docId != DocIdSetIterator.NO_MORE_DOCS) {
+                if (docId != NO_MORE_DOCS) {
                     contextNo = docId;
                 }
             }
@@ -200,50 +201,37 @@ class NotQuery extends Query {
             while (contextNo != -1 && contextNo == docNo) {
                 docNo++;
                 int docId = contextScorer.nextDoc();
-                if (docId != DocIdSetIterator.NO_MORE_DOCS) {
-                    contextNo = docId;
-                } else {
-                    contextNo = -1;
-                }
+                contextNo = docId == NO_MORE_DOCS ? -1 : docId;
             }
-            return docNo < reader.maxDoc();
+            if (docNo >= reader.maxDoc()) {
+                docNo = NO_MORE_DOCS;
+            }
+            return docNo;
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public int doc() {
+        @Override
+        public int docID() {
             return docNo;
         }
 
-        /**
-         * {@inheritDoc}
-         */
+        @Override
         public float score() throws IOException {
             return 1.0f;
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean skipTo(int target) throws IOException {
+        @Override
+        public int advance(int target) throws IOException {
+            if (docNo == NO_MORE_DOCS) {
+                return docNo;
+            }
+
             if (contextNo != -1 && contextNo < target) {
                 int docId = contextScorer.advance(target);
-                if (docId != DocIdSetIterator.NO_MORE_DOCS) {
-                    contextNo = docId;
-                } else {
-                    contextNo = -1;
-                }
+                contextNo = docId == NO_MORE_DOCS ? -1 : docId;
             }
             docNo = target - 1;
-            return next();
+            return nextDoc();
         }
 
-        /**
-         * @throws UnsupportedOperationException always
-         */
-        public Explanation explain(int doc) throws IOException {
-            throw new UnsupportedOperationException();
-        }
     }
 }

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java Mon Jan 24 14:32:05 2011
@@ -16,12 +16,6 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.io.IOException;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
 import org.apache.jackrabbit.core.query.lucene.hits.Hits;
 import org.apache.jackrabbit.core.query.lucene.hits.ScorerHits;
@@ -34,6 +28,12 @@ import org.apache.lucene.search.Searcher
 import org.apache.lucene.search.Similarity;
 import org.apache.lucene.search.Weight;
 
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * <code>ParentAxisQuery</code> selects the parent nodes of a context query.
  */
@@ -268,25 +268,26 @@ class ParentAxisQuery extends Query {
             this.hResolver = resolver;
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean next() throws IOException {
+        @Override
+        public int nextDoc() throws IOException {
+            if (nextDoc == NO_MORE_DOCS) {
+                return nextDoc;
+            }
+
             calculateParent();
             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() throws IOException {
             Float score = scores.get(nextDoc);
             if (score == null) {
@@ -295,23 +296,18 @@ class ParentAxisQuery extends Query {
             return score;
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean skipTo(int target) throws IOException {
+        @Override
+        public int advance(int target) throws IOException {
+            if (nextDoc == NO_MORE_DOCS) {
+                return nextDoc;
+            }
+
             calculateParent();
             nextDoc = hits.nextSetBit(target);
-            return nextDoc > -1;
-        }
-
-        /**
-         * {@inheritDoc}
-         *
-         * @throws UnsupportedOperationException this implementation always
-         *                                       throws an <code>UnsupportedOperationException</code>.
-         */
-        public Explanation explain(int doc) throws IOException {
-            throw new UnsupportedOperationException();
+            if (nextDoc < 0) {
+                nextDoc = NO_MORE_DOCS;
+            }
+            return nextDoc;
         }
 
         private void calculateParent() throws IOException {

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java Mon Jan 24 14:32:05 2011
@@ -16,10 +16,6 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.io.IOException;
-import java.util.BitSet;
-import java.util.Set;
-
 import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.lucene.index.IndexReader;
@@ -32,6 +28,10 @@ import org.apache.lucene.search.Searcher
 import org.apache.lucene.search.Similarity;
 import org.apache.lucene.search.Weight;
 
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.Set;
+
 /**
  * Implements a Lucene <code>Query</code> which returns the nodes which have a 
  * reference property which matches the nodes of the subquery.
@@ -258,49 +258,44 @@ public class PredicateDerefQuery extends
             this.subQueryHits = new BitSet(reader.maxDoc());
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean next() throws IOException {
+        @Override
+        public int nextDoc() throws IOException {
+            if (nextDoc == NO_MORE_DOCS) {
+                return nextDoc;
+            }
+
             calculateChildren();
             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() throws IOException {
             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;
+            }
+
             calculateChildren();
             nextDoc = hits.nextSetBit(target);
-            return nextDoc > -1;
-        }
-
-        /**
-         * {@inheritDoc}
-         *
-         * @throws UnsupportedOperationException this implementation always
-         *                                       throws an <code>UnsupportedOperationException</code>.
-         */
-        public Explanation explain(int doc) throws IOException {
-            throw new UnsupportedOperationException();
+            if (nextDoc < 0) {
+                nextDoc = NO_MORE_DOCS;
+            }
+            return nextDoc;
         }
 
-
         /**
          * Perform the sub query
          * For each reference property UUID

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java Mon Jan 24 14:32:05 2011
@@ -214,48 +214,39 @@ public class QueryHitsQuery extends Quer
             docs = sortedDocs.iterator();
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean next() throws IOException {
-            if (docs.hasNext()) {
-                currentDoc = docs.next();
-                return true;
+        @Override
+        public int nextDoc() throws IOException {
+            if (currentDoc == NO_MORE_DOCS) {
+                return currentDoc;
             }
-            return false;
-        }
 
-        /**
-         * {@inheritDoc}
-         */
-        public int doc() {
+            currentDoc = docs.hasNext() ? docs.next() : NO_MORE_DOCS;
             return currentDoc;
         }
 
-        /**
-         * {@inheritDoc}
-         */
+        @Override
+        public int docID() {
+            return currentDoc == null ? -1 : currentDoc;
+        }
+
+        @Override
         public float score() throws IOException {
             return scores.get(currentDoc);
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean skipTo(int target) throws IOException {
+        @Override
+        public int advance(int target) throws IOException {
+            if (currentDoc == NO_MORE_DOCS) {
+                return currentDoc;
+            }
+
             do {
-                if (!next()) {
-                    return false;
+                if (nextDoc() == NO_MORE_DOCS) {
+                    return NO_MORE_DOCS;
                 }
-            } while (target > doc());
-            return true;
+            } while (target > docID());
+            return docID();
         }
 
-        /**
-         * {@inheritDoc}
-         */
-        public Explanation explain(int doc) throws IOException {
-            return new Explanation();
-        }
     }
 }

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java Mon Jan 24 14:32:05 2011
@@ -16,14 +16,6 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermDocs;
@@ -39,6 +31,14 @@ import org.apache.lucene.search.Weight;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * Implements a variant of the lucene class {@link org.apache.lucene.search.RangeQuery}.
  * This class does not rewrite to basic {@link org.apache.lucene.search.TermQuery}
@@ -358,44 +358,42 @@ public class RangeQuery extends Query im
             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/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ReadOnlyIndexReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ReadOnlyIndexReader.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ReadOnlyIndexReader.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ReadOnlyIndexReader.java Mon Jan 24 14:32:05 2011
@@ -16,13 +16,14 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.io.IOException;
-import java.util.BitSet;
-
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermDocs;
 import org.apache.lucene.index.TermPositions;
 
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.Map;
+
 /**
  * Overwrites the methods that would modify the index and throws an
  * {@link UnsupportedOperationException} in each of those methods. A
@@ -175,7 +176,8 @@ class ReadOnlyIndexReader extends RefCou
     /**
      * @exception UnsupportedOperationException always
      */
-    protected final void doCommit() {
+    @Override
+    protected void doCommit(Map commitUserData) throws IOException { 
         throw new UnsupportedOperationException("IndexReader is read-only");
     }
 

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java Mon Jan 24 14:32:05 2011
@@ -16,27 +16,6 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.query.InvalidQueryException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
 import org.apache.jackrabbit.core.HierarchyManager;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.fs.FileSystem;
@@ -50,6 +29,7 @@ import org.apache.jackrabbit.core.query.
 import org.apache.jackrabbit.core.query.QueryHandlerContext;
 import org.apache.jackrabbit.core.query.lucene.directory.DirectoryManager;
 import org.apache.jackrabbit.core.query.lucene.directory.FSDirectoryManager;
+import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
 import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.ItemStateManager;
@@ -63,15 +43,17 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.query.DefaultQueryNodeFactory;
 import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl;
 import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.Token;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.Fieldable;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.MultiReader;
+import org.apache.lucene.index.Payload;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermDocs;
-import org.apache.lucene.search.HitCollector;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Similarity;
@@ -85,6 +67,26 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
+import javax.jcr.RepositoryException;
+import javax.jcr.query.InvalidQueryException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * Implements a {@link org.apache.jackrabbit.core.query.QueryHandler} using
  * Lucene.
@@ -691,7 +693,8 @@ public class SearchIndex extends Abstrac
             try {
                 Query q = new TermQuery(new Term(
                         FieldNames.WEAK_REFS, id.toString()));
-                searcher.search(q, new HitCollector() {
+                searcher.search(q, new AbstractHitCollector() {
+                    @Override
                     public void collect(int doc, float score) {
                         docs.add(doc);
                     }
@@ -1376,11 +1379,15 @@ public class SearchIndex extends Abstrac
                             try {
                                 // find the right fields to transfer
                                 Fieldable[] fields = aDoc.getFieldables(FieldNames.PROPERTIES);
-                                Token t = new Token();
                                 for (Fieldable field : fields) {
+
                                     // assume properties fields use SingleTokenStream
-                                    t = field.tokenStreamValue().next(t);
-                                    String value = new String(t.termBuffer(), 0, t.termLength());
+                                    TokenStream tokenStream = field.tokenStreamValue();
+                                    TermAttribute termAttribute = (TermAttribute) tokenStream.addAttribute(TermAttribute.class);
+                                    PayloadAttribute payloadAttribute = (PayloadAttribute) tokenStream.addAttribute(PayloadAttribute.class);
+                                    tokenStream.incrementToken();
+
+                                    String value = new String(termAttribute.termBuffer(), 0, termAttribute.termLength());
                                     if (value.startsWith(namePrefix)) {
                                         // extract value
                                         value = value.substring(namePrefix.length());
@@ -1388,9 +1395,11 @@ public class SearchIndex extends Abstrac
                                         Path p = getRelativePath(state, propState);
                                         String path = getNamespaceMappings().translatePath(p);
                                         value = FieldNames.createNamedValue(path, value);
-                                        t.setTermBuffer(value);
-                                        doc.add(new Field(field.name(), new SingletonTokenStream(t)));
-                                        doc.add(new Field(FieldNames.AGGREGATED_NODE_UUID, parent.getNodeId().toString(), Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS));
+                                        termAttribute.setTermBuffer(value);
+                                        doc.add(new Field(field.name(),
+                                                new SingletonTokenStream(value, (Payload) payloadAttribute.getPayload().clone())));
+                                        doc.add(new Field(FieldNames.AGGREGATED_NODE_UUID,
+                                                parent.getNodeId().toString(), Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS));
                                     }
                                 }
                             } finally {

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingletonTokenStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingletonTokenStream.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingletonTokenStream.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingletonTokenStream.java Mon Jan 24 14:32:05 2011
@@ -16,12 +16,13 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import java.io.IOException;
-
-import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
 import org.apache.lucene.index.Payload;
 
+import java.io.IOException;
+
 /**
  * <code>SingletonTokenStream</code> implements a token stream that wraps a
  * single value with a given property type. The property type is stored as a
@@ -40,40 +41,50 @@ public final class SingletonTokenStream 
     private final Payload payload;
 
     /**
-     * Creates a new SingleTokenStream with the given value and a property
-     * <code>type</code>.
+     * The term attribute of the current token
+     */
+    private TermAttribute termAttribute;
+
+    /**
+     * The payload attribute of the current token
+     */
+    private PayloadAttribute payloadAttribute;
+
+    /**
+     * Creates a new SingleTokenStream with the given value and payload.
      *
      * @param value the string value that will be returned with the token.
-     * @param type the JCR property type.
+     * @param payload the payload that will be attached to this token
      */
-    public SingletonTokenStream(String value, int type) {
+    public SingletonTokenStream(String value, Payload payload) {
         this.value = value;
-        this.payload = new Payload(new PropertyMetaData(type).toByteArray());
+        this.payload = payload;
+        termAttribute = (TermAttribute) addAttribute(TermAttribute.class);
+        payloadAttribute = (PayloadAttribute) addAttribute(PayloadAttribute.class);
     }
 
     /**
-     * Creates a new SingleTokenStream with the given token.
+     * Creates a new SingleTokenStream with the given value and a property
+     * <code>type</code>.
      *
-     * @param t the token.
+     * @param value the string value that will be returned with the token.
+     * @param type the JCR property type.
      */
-    public SingletonTokenStream(Token t) {
-        this.value = t.term();
-        this.payload = t.getPayload();
+    public SingletonTokenStream(String value, int type) {
+        this(value, new Payload(new PropertyMetaData(type).toByteArray()));
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public Token next(Token reusableToken) throws IOException {
+    @Override
+    public boolean incrementToken() throws IOException {
         if (value == null) {
-            return null;
+            return false;
         }
-        reusableToken.clear();
-        reusableToken.setTermBuffer(value);
-        reusableToken.setPayload(payload);
-        reusableToken.setStartOffset(0);
-        reusableToken.setEndOffset(value.length());
+
+        clearAttributes();
+        termAttribute.setTermBuffer(value);
+        payloadAttribute.setPayload(payload);
+
         value = null;
-        return reusableToken;
+        return true;
     }
 }

Modified: jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java Mon Jan 24 14:32:05 2011
@@ -316,44 +316,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/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java Mon Jan 24 14:32:05 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/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java?rev=1062799&r1=1062798&r2=1062799&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java (original)
+++ jackrabbit/sandbox/JCR-2415-lucene-3.0/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java Mon Jan 24 14:32:05 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);



Mime
View raw message