[exo-jcr-commits] exo-jcr SVN: r2440 - in jcr/branches/1.12-LIC-709/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri May 28 02:54:19 EDT 2010


Author: nzamosenchuk
Date: 2010-05-28 02:54:18 -0400 (Fri, 28 May 2010)
New Revision: 2440

Modified:
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractWeight.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DerefQuery.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexSearcher.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTermQuery.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryHits.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllQuery.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllWeight.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NotQuery.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ParentAxisQuery.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryHitsQuery.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RangeQuery.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RefCountingIndexReader.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingleIndex.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WildcardQuery.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java
   jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/directory/DirectoryManagerTest.java
Log:
EXOJCR-744 : upgrading to Lucene 2.9:

1. Query class: changed definition (visibility modifier) of createWeight(..) method.
2. Interface Weight replaced with it's abstract type.
3. Weight.score(IndexReader) replaced with Weight.score(IndexReader, boolean, boolean)  [should be reviewed if upgrading to 2.9 on trunk]. 
4. IndexReader.getSequenceReaders() introduced and used in LucenInternals for per-segment search and caching. In our custom IndexReader should be overridden and return null (This is safe solution confirmed within lucene's mailing list by Simon Willnauer).
5. FSdirectory.getDirectory(...) replaced with FSdirectory.open(...). But open(...) doesn't create a directory structure anymore. 

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractWeight.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractWeight.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractWeight.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,72 +16,81 @@
  */
 package org.exoplatform.services.jcr.impl.core.query.lucene;
 
-import java.io.IOException;
-
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Searcher;
 import org.apache.lucene.search.Weight;
 
+import java.io.IOException;
+
 /**
  * <code>AbstractWeight</code> implements base functionality for custom lucene
  * weights in jackrabbit.
  */
-abstract class AbstractWeight implements Weight {
+abstract class AbstractWeight extends Weight
+{
 
-    /**
-     * The searcher for this weight.
-     */
-    protected final Searcher searcher;
+   /**
+    * The searcher for this weight.
+    */
+   protected final Searcher searcher;
 
-    /**
-     * Creates a new <code>AbstractWeight</code> for the given
-     * <code>searcher</code>.
-     *
-     * @param searcher the searcher instance for this weight.
-     */
-    public AbstractWeight(Searcher searcher) {
-        this.searcher = searcher;
-    }
+   /**
+    * Creates a new <code>AbstractWeight</code> for the given
+    * <code>searcher</code>.
+    *
+    * @param searcher the searcher instance for this weight.
+    */
+   public AbstractWeight(Searcher searcher)
+   {
+      this.searcher = searcher;
+   }
 
-    /**
-     * Abstract factory method for crating a scorer instance for the
-     * specified reader.
-     *
-     * @param reader the index reader the created scorer instance should use
-     * @return the scorer instance
-     * @throws IOException if an error occurs while reading from the index
-     */
-    protected abstract Scorer createScorer(IndexReader reader)
-            throws IOException;
+   /**
+    * Abstract factory method for crating a scorer instance for the
+    * specified reader.
+    *
+    * @param reader the index reader the created scorer instance should use
+    * @return the scorer instance
+    * @throws IOException if an error occurs while reading from the index
+    */
+   protected abstract Scorer createScorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer)
+      throws IOException;
 
-    /**
-     * {@inheritDoc}
-     * <p/>
-     * Returns a {@link MultiScorer} if the passed <code>reader</code> is of
-     * type {@link MultiIndexReader}.
-     */
-    public Scorer scorer(IndexReader reader) throws IOException {
-        if (reader instanceof MultiIndexReader) {
-            MultiIndexReader mir = (MultiIndexReader) reader;
-            IndexReader[] readers = mir.getIndexReaders();
-            int[] starts = new int[readers.length + 1];
-            int maxDoc = 0;
-            for (int i = 0; i < readers.length; i++) {
-                starts[i] = maxDoc;
-                maxDoc += readers[i].maxDoc();
-            }
+   /**
+    * {@inheritDoc}
+    * <p/>
+    * Returns a {@link MultiScorer} if the passed <code>reader</code> is of
+    * type {@link MultiIndexReader}.
+    */
+   @Override
+   public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException
+   {
+      if (reader instanceof MultiIndexReader)
+      {
+         MultiIndexReader mir = (MultiIndexReader)reader;
+         IndexReader[] readers = mir.getIndexReaders();
+         int[] starts = new int[readers.length + 1];
+         int maxDoc = 0;
+         for (int i = 0; i < readers.length; i++)
+         {
+            starts[i] = maxDoc;
+            maxDoc += readers[i].maxDoc();
+         }
 
-            starts[readers.length] = maxDoc;
-            Scorer[] scorers = new Scorer[readers.length];
-            for (int i = 0; i < readers.length; i++) {
-                scorers[i] = scorer(readers[i]);
-            }
+         starts[readers.length] = maxDoc;
+         Scorer[] scorers = new Scorer[readers.length];
+         for (int i = 0; i < readers.length; i++)
+         {
+            scorers[i] = scorer(readers[i], scoreDocsInOrder, topScorer);
+         }
 
-            return new MultiScorer(searcher.getSimilarity(), scorers, starts);
-        } else {
-            return createScorer(reader);
-        }
-    }
+         return new MultiScorer(searcher.getSimilarity(), scorers, starts);
+      }
+      else
+      {
+         return createScorer(reader, scoreDocsInOrder, topScorer);
+      }
+   }
 
 }

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -192,7 +192,8 @@
     * @param searcher the <code>Searcher</code> instance to use.
     * @return a <code>ChildAxisWeight</code>.
     */
-   protected Weight createWeight(Searcher searcher)
+   @Override
+   public Weight createWeight(Searcher searcher)
    {
       return new ChildAxisWeight(searcher);
    }
@@ -200,6 +201,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public void extractTerms(Set terms)
    {
       contextQuery.extractTerms(terms);
@@ -208,6 +210,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public Query rewrite(IndexReader reader) throws IOException
    {
       Query cQuery = contextQuery.rewrite(reader);
@@ -247,6 +250,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public String toString(String field)
    {
       StringBuffer sb = new StringBuffer();
@@ -286,7 +290,7 @@
    /**
     * The <code>Weight</code> implementation for this <code>ChildAxisQuery</code>.
     */
-   private class ChildAxisWeight implements Weight
+   private class ChildAxisWeight extends Weight
    {
 
       /**
@@ -310,6 +314,7 @@
        *
        * @return this <code>ChildAxisQuery</code>.
        */
+      @Override
       public Query getQuery()
       {
          return ChildAxisQuery.this;
@@ -318,6 +323,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public float getValue()
       {
          return 1.0f;
@@ -326,6 +332,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public float sumOfSquaredWeights() throws IOException
       {
          return 1.0f;
@@ -334,6 +341,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public void normalize(float norm)
       {
       }
@@ -345,12 +353,15 @@
        * @return a <code>ChildAxisScorer</code>.
        * @throws IOException if an error occurs while reading from the index.
        */
-      public Scorer scorer(IndexReader reader) throws IOException
+      @Override
+      public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException
       {
-         contextScorer = contextQuery.weight(searcher).scorer(reader);
+         contextScorer = contextQuery.weight(searcher).scorer(reader, scoreDocsInOrder, topScorer);
          if (nameTest != null)
          {
-            nameTestScorer = new NameQuery(nameTest, version, nsMappings).weight(searcher).scorer(reader);
+            nameTestScorer =
+               new NameQuery(nameTest, version, nsMappings).weight(searcher)
+                  .scorer(reader, scoreDocsInOrder, topScorer);
          }
          return new ChildAxisScorer(searcher.getSimilarity(), reader, (HierarchyResolver)reader);
       }
@@ -358,6 +369,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public Explanation explain(IndexReader reader, int doc) throws IOException
       {
          return new Explanation();
@@ -409,6 +421,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public boolean next() throws IOException
       {
          calculateChildren();
@@ -424,6 +437,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public int doc()
       {
          return nextDoc;
@@ -432,6 +446,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public float score() throws IOException
       {
          return 1.0f;
@@ -440,6 +455,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public boolean skipTo(int target) throws IOException
       {
          calculateChildren();
@@ -457,6 +473,7 @@
        * @throws UnsupportedOperationException this implementation always
        *                                       throws an <code>UnsupportedOperationException</code>.
        */
+      @Override
       public Explanation explain(int doc) throws IOException
       {
          throw new UnsupportedOperationException();
@@ -474,6 +491,7 @@
                calc[0] = new SimpleChildrenCalculator(reader, hResolver);
                contextScorer.score(new HitCollector()
                {
+                  @Override
                   public void collect(int doc, float score)
                   {
                      calc[0].collectContextHit(doc);
@@ -489,6 +507,7 @@
 
                   private List docIds = new ArrayList();
 
+                  @Override
                   public void collect(int doc, float score)
                   {
                      calc[0].collectContextHit(doc);
@@ -583,7 +602,9 @@
                      else
                      {
                         if (nodeData.getQPath().getIndex() != position)
+                        {
                            return false;
+                        }
                      }
                   }
                }
@@ -667,6 +688,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       protected void collectContextHit(int doc)
       {
          contextHits.set(doc);
@@ -675,6 +697,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public Hits getHits() throws IOException
       {
          // read the uuids of the context nodes
@@ -709,7 +732,9 @@
                      for (NodeData nodeData : childs)
                      {
                         if (nameTest.equals(nodeData.getQPath().getName()))
+                        {
                            datas.add(nodeData);
+                        }
                      }
 
                   }
@@ -775,6 +800,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       protected void collectContextHit(int doc)
       {
          docIds.add(new Integer(doc));
@@ -783,6 +809,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public Hits getHits() throws IOException
       {
          long time = System.currentTimeMillis();

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DerefQuery.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DerefQuery.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DerefQuery.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,13 +16,6 @@
  */
 package org.exoplatform.services.jcr.impl.core.query.lucene;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermDocs;
@@ -35,315 +28,383 @@
 import org.apache.lucene.search.Weight;
 import org.exoplatform.services.jcr.datamodel.InternalQName;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
 /**
  * Implements a lucene <code>Query</code> which returns the nodes selected by
  * a reference property of the context node.
  */
-class DerefQuery extends Query {
+class DerefQuery extends Query
+{
 
-    /**
-     * The context query
-     */
-    private final Query contextQuery;
+   /**
+    * The context query
+    */
+   private final Query contextQuery;
 
-    /**
-     * The name of the reference property.
-     */
-    private final String refProperty;
+   /**
+    * The name of the reference property.
+    */
+   private final String refProperty;
 
-    /**
-     * The nameTest to apply on target node, or <code>null</code> if all
-     * target nodes should be selected.
-     */
-    private final InternalQName nameTest;
+   /**
+    * The nameTest to apply on target node, or <code>null</code> if all
+    * target nodes should be selected.
+    */
+   private final InternalQName nameTest;
 
-    /**
-     * The index format version.
-     */
-    private final IndexFormatVersion version;
+   /**
+    * The index format version.
+    */
+   private final IndexFormatVersion version;
 
-    /**
-     * The internal namespace mappings.
-     */
-    private final NamespaceMappings nsMappings;
+   /**
+    * The internal namespace mappings.
+    */
+   private final NamespaceMappings nsMappings;
 
-    /**
-     * The scorer of the context query
-     */
-    private Scorer contextScorer;
+   /**
+    * The scorer of the context query
+    */
+   private Scorer contextScorer;
 
-    /**
-     * The scorer of the name test query
-     */
-    private Scorer nameTestScorer;
+   /**
+    * The scorer of the name test query
+    */
+   private Scorer nameTestScorer;
 
-    /**
-     * Creates a new <code>DerefQuery</code> based on a <code>context</code>
-     * query.
-     *
-     * @param context the context for this query.
-     * @param refProperty the name of the reference property.
-     * @param nameTest a name test or <code>null</code> if any node is
-     *  selected.
-     * @param version the index format version.
-     * @param nsMappings the namespace mappings.
-     */
-    DerefQuery(Query context, String refProperty, InternalQName nameTest,
-               IndexFormatVersion version, NamespaceMappings nsMappings) {
-        this.contextQuery = context;
-        this.refProperty = refProperty;
-        this.nameTest = nameTest;
-        this.version = version;
-        this.nsMappings = nsMappings;
-    }
+   /**
+    * Creates a new <code>DerefQuery</code> based on a <code>context</code>
+    * query.
+    *
+    * @param context the context for this query.
+    * @param refProperty the name of the reference property.
+    * @param nameTest a name test or <code>null</code> if any node is
+    *  selected.
+    * @param version the index format version.
+    * @param nsMappings the namespace mappings.
+    */
+   DerefQuery(Query context, String refProperty, InternalQName nameTest, IndexFormatVersion version,
+      NamespaceMappings nsMappings)
+   {
+      this.contextQuery = context;
+      this.refProperty = refProperty;
+      this.nameTest = nameTest;
+      this.version = version;
+      this.nsMappings = nsMappings;
+   }
 
-    /**
-     * Creates a <code>Weight</code> instance for this query.
-     *
-     * @param searcher the <code>Searcher</code> instance to use.
-     * @return a <code>DerefWeight</code>.
-     */
-    protected Weight createWeight(Searcher searcher) {
-        return new DerefWeight(searcher);
-    }
+   /**
+    * Creates a <code>Weight</code> instance for this query.
+    *
+    * @param searcher the <code>Searcher</code> instance to use.
+    * @return a <code>DerefWeight</code>.
+    */
+   @Override
+   public Weight createWeight(Searcher searcher)
+   {
+      return new DerefWeight(searcher);
+   }
 
-    /**
-     * Always returns 'DerefQuery'.
-     *
-     * @param field the name of a field.
-     * @return 'DerefQuery'.
-     */
-    public String toString(String field) {
-        return "DerefQuery";
-    }
+   /**
+    * Always returns 'DerefQuery'.
+    *
+    * @param field the name of a field.
+    * @return 'DerefQuery'.
+    */
+   @Override
+   public String toString(String field)
+   {
+      return "DerefQuery";
+   }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void extractTerms(Set terms) {
-        // no terms to extract
-    }
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void extractTerms(Set terms)
+   {
+      // no terms to extract
+   }
 
-    /**
-     * {@inheritDoc}
-     */
-    public Query rewrite(IndexReader reader) throws IOException {
-        Query cQuery = contextQuery.rewrite(reader);
-        if (cQuery == contextQuery) {
-            return this;
-        } else {
-            return new DerefQuery(cQuery, refProperty, nameTest, version, nsMappings);
-        }
-    }
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Query rewrite(IndexReader reader) throws IOException
+   {
+      Query cQuery = contextQuery.rewrite(reader);
+      if (cQuery == contextQuery)
+      {
+         return this;
+      }
+      else
+      {
+         return new DerefQuery(cQuery, refProperty, nameTest, version, nsMappings);
+      }
+   }
 
-    //-------------------< DerefWeight >------------------------------------
+   //-------------------< DerefWeight >------------------------------------
 
-    /**
-     * The <code>Weight</code> implementation for this <code>DerefQuery</code>.
-     */
-    private class DerefWeight implements Weight {
+   /**
+    * The <code>Weight</code> implementation for this <code>DerefQuery</code>.
+    */
+   private class DerefWeight extends Weight
+   {
 
-        /**
-         * The searcher in use
-         */
-        private final Searcher searcher;
+      /**
+       * The searcher in use
+       */
+      private final Searcher searcher;
 
-        /**
-         * Creates a new <code>DerefWeight</code> instance using
-         * <code>searcher</code>.
-         *
-         * @param searcher a <code>Searcher</code> instance.
-         */
-        private DerefWeight(Searcher searcher) {
-            this.searcher = searcher;
-        }
+      /**
+       * Creates a new <code>DerefWeight</code> instance using
+       * <code>searcher</code>.
+       *
+       * @param searcher a <code>Searcher</code> instance.
+       */
+      private DerefWeight(Searcher searcher)
+      {
+         this.searcher = searcher;
+      }
 
-        /**
-         * Returns this <code>DerefQuery</code>.
-         *
-         * @return this <code>DerefQuery</code>.
-         */
-        public Query getQuery() {
-            return DerefQuery.this;
-        }
+      /**
+       * Returns this <code>DerefQuery</code>.
+       *
+       * @return this <code>DerefQuery</code>.
+       */
+      @Override
+      public Query getQuery()
+      {
+         return DerefQuery.this;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public float getValue() {
-            return 1.0f;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public float getValue()
+      {
+         return 1.0f;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public float sumOfSquaredWeights() throws IOException {
-            return 1.0f;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public float sumOfSquaredWeights() throws IOException
+      {
+         return 1.0f;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public void normalize(float norm) {
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public void normalize(float norm)
+      {
+      }
 
-        /**
-         * Creates a scorer for this <code>DerefQuery</code>.
-         *
-         * @param reader a reader for accessing the index.
-         * @return a <code>DerefScorer</code>.
-         * @throws IOException if an error occurs while reading from the index.
-         */
-        public Scorer scorer(IndexReader reader) throws IOException {
-            contextScorer = contextQuery.weight(searcher).scorer(reader);
-            if (nameTest != null) {
-                nameTestScorer = new NameQuery(nameTest, version, nsMappings).weight(searcher).scorer(reader);
-            }
-            return new DerefScorer(searcher.getSimilarity(), reader);
-        }
+      /**
+       * Creates a scorer for this <code>DerefQuery</code>.
+       *
+       * @param reader a reader for accessing the index.
+       * @return a <code>DerefScorer</code>.
+       * @throws IOException if an error occurs while reading from the index.
+       */
+      @Override
+      public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException
+      {
+         contextScorer = contextQuery.weight(searcher).scorer(reader, scoreDocsInOrder, topScorer);
+         if (nameTest != null)
+         {
+            nameTestScorer =
+               new NameQuery(nameTest, version, nsMappings).weight(searcher)
+                  .scorer(reader, scoreDocsInOrder, topScorer);
+         }
+         return new DerefScorer(searcher.getSimilarity(), reader);
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public Explanation explain(IndexReader reader, int doc) throws IOException {
-            return new Explanation();
-        }
-    }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public Explanation explain(IndexReader reader, int doc) throws IOException
+      {
+         return new Explanation();
+      }
+   }
 
-    //----------------------< DerefScorer >---------------------------------
+   //----------------------< DerefScorer >---------------------------------
 
-    /**
-     * Implements a <code>Scorer</code> for this <code>DerefQuery</code>.
-     */
-    private class DerefScorer extends Scorer {
+   /**
+    * Implements a <code>Scorer</code> for this <code>DerefQuery</code>.
+    */
+   private class DerefScorer extends Scorer
+   {
 
-        /**
-         * An <code>IndexReader</code> to access the index.
-         */
-        private final IndexReader reader;
+      /**
+       * An <code>IndexReader</code> to access the index.
+       */
+      private final IndexReader reader;
 
-        /**
-         * BitSet storing the id's of selected documents
-         */
-        private final BitSet hits;
+      /**
+       * BitSet storing the id's of selected documents
+       */
+      private final BitSet hits;
 
-        /**
-         * List of UUIDs of selected nodes
-         */
-        private List uuids = null;
+      /**
+       * List of UUIDs of selected nodes
+       */
+      private List uuids = null;
 
-        /**
-         * The next document id to return
-         */
-        private int nextDoc = -1;
+      /**
+       * The next document id to return
+       */
+      private int nextDoc = -1;
 
-        /**
-         * Creates a new <code>DerefScorer</code>.
-         *
-         * @param similarity the <code>Similarity</code> instance to use.
-         * @param reader     for index access.
-         */
-        protected DerefScorer(Similarity similarity, IndexReader reader) {
-            super(similarity);
-            this.reader = reader;
-            this.hits = new BitSet(reader.maxDoc());
-        }
+      /**
+       * Creates a new <code>DerefScorer</code>.
+       *
+       * @param similarity the <code>Similarity</code> instance to use.
+       * @param reader     for index access.
+       */
+      protected DerefScorer(Similarity similarity, IndexReader reader)
+      {
+         super(similarity);
+         this.reader = reader;
+         this.hits = new BitSet(reader.maxDoc());
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean next() throws IOException {
-            calculateChildren();
-            nextDoc = hits.nextSetBit(nextDoc + 1);
-            return nextDoc > -1;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public boolean next() throws IOException
+      {
+         calculateChildren();
+         nextDoc = hits.nextSetBit(nextDoc + 1);
+         return nextDoc > -1;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public int doc() {
-            return nextDoc;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public int doc()
+      {
+         return nextDoc;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public float score() throws IOException {
-            return 1.0f;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public float score() throws IOException
+      {
+         return 1.0f;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean skipTo(int target) throws IOException {
-            calculateChildren();
-            nextDoc = hits.nextSetBit(target);
-            return nextDoc > -1;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public boolean skipTo(int target) throws IOException
+      {
+         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();
-        }
+      /**
+       * {@inheritDoc}
+       *
+       * @throws UnsupportedOperationException this implementation always
+       *                                       throws an <code>UnsupportedOperationException</code>.
+       */
+      @Override
+      public Explanation explain(int doc) throws IOException
+      {
+         throw new UnsupportedOperationException();
+      }
 
-        private void calculateChildren() throws IOException {
-            if (uuids == null) {
-                uuids = new ArrayList();
-                contextScorer.score(new HitCollector() {
-                    public void collect(int doc, float score) {
-                        hits.set(doc);
-                    }
-                });
+      private void calculateChildren() throws IOException
+      {
+         if (uuids == null)
+         {
+            uuids = new ArrayList();
+            contextScorer.score(new HitCollector()
+            {
+               @Override
+               public void collect(int doc, float score)
+               {
+                  hits.set(doc);
+               }
+            });
 
-                // collect nameTest hits
-                final BitSet nameTestHits = new BitSet();
-                if (nameTestScorer != null) {
-                    nameTestScorer.score(new HitCollector() {
-                        public void collect(int doc, float score) {
-                            nameTestHits.set(doc);
-                        }
-                    });
-                }
+            // collect nameTest hits
+            final BitSet nameTestHits = new BitSet();
+            if (nameTestScorer != null)
+            {
+               nameTestScorer.score(new HitCollector()
+               {
+                  @Override
+                  public void collect(int doc, float score)
+                  {
+                     nameTestHits.set(doc);
+                  }
+               });
+            }
 
-                // retrieve uuids of target nodes
-                String prefix = FieldNames.createNamedValue(refProperty, "");
-                for (int i = hits.nextSetBit(0); i >= 0; i = hits.nextSetBit(i + 1)) {
-                    String[] values = reader.document(i).getValues(FieldNames.PROPERTIES);
-                    if (values == null) {
-                        // no reference properties at all on this node
-                        continue;
-                    }
-                    for (int v = 0; v < values.length; v++) {
-                        if (values[v].startsWith(prefix)) {
-                            uuids.add(values[v].substring(prefix.length()));
-                        }
-                    }
-                }
+            // retrieve uuids of target nodes
+            String prefix = FieldNames.createNamedValue(refProperty, "");
+            for (int i = hits.nextSetBit(0); i >= 0; i = hits.nextSetBit(i + 1))
+            {
+               String[] values = reader.document(i).getValues(FieldNames.PROPERTIES);
+               if (values == null)
+               {
+                  // no reference properties at all on this node
+                  continue;
+               }
+               for (int v = 0; v < values.length; v++)
+               {
+                  if (values[v].startsWith(prefix))
+                  {
+                     uuids.add(values[v].substring(prefix.length()));
+                  }
+               }
+            }
 
-                // collect the doc ids of all target nodes. we reuse the existing
-                // bitset.
-                hits.clear();
-                for (Iterator it = uuids.iterator(); it.hasNext();) {
-                    TermDocs node = reader.termDocs(new Term(FieldNames.UUID, (String) it.next()));
-                    try {
-                        while (node.next()) {
-                            hits.set(node.doc());
-                        }
-                    } finally {
-                        node.close();
-                    }
-                }
-                // filter out the target nodes that do not match the name test
-                // if there is any name test at all.
-                if (nameTestScorer != null) {
-                    hits.and(nameTestHits);
-                }
+            // collect the doc ids of all target nodes. we reuse the existing
+            // bitset.
+            hits.clear();
+            for (Iterator it = uuids.iterator(); it.hasNext();)
+            {
+               TermDocs node = reader.termDocs(new Term(FieldNames.UUID, (String)it.next()));
+               try
+               {
+                  while (node.next())
+                  {
+                     hits.set(node.doc());
+                  }
+               }
+               finally
+               {
+                  node.close();
+               }
             }
-        }
-    }
+            // filter out the target nodes that do not match the name test
+            // if there is any name test at all.
+            if (nameTestScorer != null)
+            {
+               hits.and(nameTestHits);
+            }
+         }
+      }
+   }
 }

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -181,7 +181,8 @@
     * @param searcher the <code>Searcher</code> instance to use.
     * @return a <code>DescendantSelfAxisWeight</code>.
     */
-   protected Weight createWeight(Searcher searcher)
+   @Override
+   public Weight createWeight(Searcher searcher)
    {
       return new DescendantSelfAxisWeight(searcher);
    }
@@ -189,6 +190,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public String toString(String field)
    {
       StringBuffer sb = new StringBuffer();
@@ -205,6 +207,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public void extractTerms(Set terms)
    {
       contextQuery.extractTerms(terms);
@@ -214,6 +217,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public Query rewrite(IndexReader reader) throws IOException
    {
       Query cQuery = contextQuery.rewrite(reader);
@@ -314,6 +318,7 @@
                fetchNextTraversal();
             }
 
+            @Override
             public void close() throws IOException
             {
                if (currentTraversal != null)
@@ -379,7 +384,7 @@
     * The <code>Weight</code> implementation for this
     * <code>DescendantSelfAxisWeight</code>.
     */
-   private class DescendantSelfAxisWeight implements Weight
+   private class DescendantSelfAxisWeight extends Weight
    {
 
       /**
@@ -405,6 +410,7 @@
        *
        * @return this <code>DescendantSelfAxisQuery</code>.
        */
+      @Override
       public Query getQuery()
       {
          return DescendantSelfAxisQuery.this;
@@ -413,6 +419,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public float getValue()
       {
          return 1.0f;
@@ -421,6 +428,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public float sumOfSquaredWeights() throws IOException
       {
          return 1.0f;
@@ -429,6 +437,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public void normalize(float norm)
       {
       }
@@ -440,10 +449,11 @@
        * @return a <code>DescendantSelfAxisScorer</code>.
        * @throws IOException if an error occurs while reading from the index.
        */
-      public Scorer scorer(IndexReader reader) throws IOException
+      @Override
+      public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException
       {
-         contextScorer = contextQuery.weight(searcher).scorer(reader);
-         subScorer = subQuery.weight(searcher).scorer(reader);
+         contextScorer = contextQuery.weight(searcher).scorer(reader, scoreDocsInOrder, topScorer);
+         subScorer = subQuery.weight(searcher).scorer(reader, scoreDocsInOrder, topScorer);
          HierarchyResolver resolver = (HierarchyResolver)reader;
          return new DescendantSelfAxisScorer(searcher.getSimilarity(), reader, resolver);
       }
@@ -451,6 +461,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public Explanation explain(IndexReader reader, int doc) throws IOException
       {
          return new Explanation();
@@ -513,6 +524,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public boolean next() throws IOException
       {
          collectContextHits();
@@ -538,6 +550,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public int doc()
       {
          return subScorer.doc();
@@ -546,6 +559,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public float score() throws IOException
       {
          return subScorer.score();
@@ -554,6 +568,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public boolean skipTo(int target) throws IOException
       {
          boolean match = subScorer.skipTo(target);
@@ -575,6 +590,7 @@
             long time = System.currentTimeMillis();
             contextScorer.score(new HitCollector()
             {
+               @Override
                public void collect(int doc, float score)
                {
                   contextHits.set(doc);
@@ -594,6 +610,7 @@
        * @throws UnsupportedOperationException this implementation always
        *                                       throws an <code>UnsupportedOperationException</code>.
        */
+      @Override
       public Explanation explain(int doc) throws IOException
       {
          throw new UnsupportedOperationException();

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexSearcher.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexSearcher.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexSearcher.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,8 +16,6 @@
  */
 package org.exoplatform.services.jcr.impl.core.query.lucene;
 
-import java.io.IOException;
-
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
@@ -27,6 +25,8 @@
 import org.exoplatform.services.jcr.impl.core.SessionImpl;
 import org.exoplatform.services.jcr.impl.core.query.lucene.constraint.EvaluationContext;
 
+import java.io.IOException;
+
 /**
  * <code>JackrabbitIndexSearcher</code> implements an index searcher with
  * jackrabbit specific optimizations.
@@ -103,7 +103,7 @@
         }
         if (hits == null) {
             if (sort == null) {
-                hits = new LuceneQueryHits(reader, this, query);
+                hits = new LuceneQueryHits(reader, this, query, true, false);
             } else {
                 hits = new SortedLuceneQueryHits(
                         reader, this, query, sort, resultFetchHint);

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTermQuery.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTermQuery.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTermQuery.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,8 +16,6 @@
  */
 package org.exoplatform.services.jcr.impl.core.query.lucene;
 
-import java.io.IOException;
-
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Explanation;
@@ -27,80 +25,99 @@
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.Weight;
 
+import java.io.IOException;
+
 /**
  * <code>JackrabbitTermQuery</code> implements a {@link TermQuery} where score
  * values are retrieved on a per index segment basis using {@link MultiScorer}.
  */
-public class JcrTermQuery extends TermQuery {
+public class JcrTermQuery extends TermQuery
+{
 
-    private static final long serialVersionUID = 4244799812287335957L;
+   private static final long serialVersionUID = 4244799812287335957L;
 
-    public JcrTermQuery(Term t) {
-        super(t);
-    }
+   public JcrTermQuery(Term t)
+   {
+      super(t);
+   }
 
-    protected Weight createWeight(Searcher searcher) throws IOException {
-        return new JackrabbitTermWeight(searcher, super.createWeight(searcher));
-    }
+   @Override
+   public Weight createWeight(Searcher searcher) throws IOException
+   {
+      return new JackrabbitTermWeight(searcher, super.createWeight(searcher));
+   }
 
-    /**
-     * The weight implementation.
-     */
-    protected class JackrabbitTermWeight extends AbstractWeight {
+   /**
+    * The weight implementation.
+    */
+   protected class JackrabbitTermWeight extends AbstractWeight
+   {
 
-        private static final long serialVersionUID = -2070964510010945854L;
+      private static final long serialVersionUID = -2070964510010945854L;
 
-        /**
-         * The default lucene TermQuery weight.
-         */
-        private final Weight weight;
+      /**
+       * The default lucene TermQuery weight.
+       */
+      private final Weight weight;
 
-        public JackrabbitTermWeight(Searcher searcher, Weight weight) {
-            super(searcher);
-            this.weight = weight;
-        }
+      public JackrabbitTermWeight(Searcher searcher, Weight weight)
+      {
+         super(searcher);
+         this.weight = weight;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        protected Scorer createScorer(IndexReader reader) throws IOException {
-            return weight.scorer(reader);
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      protected Scorer createScorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException
+      {
+         return weight.scorer(reader, scoreDocsInOrder, topScorer);
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public Query getQuery() {
-            return JcrTermQuery.this;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public Query getQuery()
+      {
+         return JcrTermQuery.this;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public float getValue() {
-            return weight.getValue();
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public float getValue()
+      {
+         return weight.getValue();
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public float sumOfSquaredWeights() throws IOException {
-            return weight.sumOfSquaredWeights();
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public float sumOfSquaredWeights() throws IOException
+      {
+         return weight.sumOfSquaredWeights();
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public void normalize(float norm) {
-            weight.normalize(norm);
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public void normalize(float norm)
+      {
+         weight.normalize(norm);
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public Explanation explain(IndexReader reader, int doc) throws
-                IOException {
-            return weight.explain(reader, doc);
-        }
-    }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public Explanation explain(IndexReader reader, int doc) throws IOException
+      {
+         return weight.explain(reader, doc);
+      }
+   }
 }

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryHits.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryHits.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryHits.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -23,67 +23,72 @@
 
 import java.io.IOException;
 
-
 /**
  * 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
  * completely.
  */
-public class LuceneQueryHits implements QueryHits {
+public class LuceneQueryHits implements QueryHits
+{
 
-    /**
-     * The IndexReader in use by the lucene hits.
-     */
-    private final IndexReader reader;
+   /**
+    * The IndexReader in use by the lucene hits.
+    */
+   private final IndexReader reader;
 
-    /**
-     * The scorer for the query.
-     */
-    private final Scorer scorer;
+   /**
+    * The scorer for the query.
+    */
+   private final Scorer scorer;
 
-    public LuceneQueryHits(IndexReader reader,
-                           IndexSearcher searcher,
-                           Query query)
-            throws IOException {
-        this.reader = reader;
-        this.scorer = query.weight(searcher).scorer(reader);
-    }
+   public LuceneQueryHits(IndexReader reader, IndexSearcher searcher, Query query, boolean scoreDocsInOrder, boolean topScorer) throws IOException
+   {
+      this.reader = reader;
+      this.scorer = query.weight(searcher).scorer(reader, scoreDocsInOrder, topScorer);
+   }
 
-    /**
-     * {@inheritDoc}
-     */
-    public ScoreNode nextScoreNode() throws IOException {
-        if (!scorer.next()) {
-            return null;
-        }
-        int doc = scorer.doc();
-        String uuid = reader.document(doc).get(FieldNames.UUID);
-        return new ScoreNode(uuid, scorer.score(), doc);
-    }
+   /**
+    * {@inheritDoc}
+    */
+   public ScoreNode nextScoreNode() throws IOException
+   {
+      if (!scorer.next())
+      {
+         return null;
+      }
+      int doc = scorer.doc();
+      String uuid = reader.document(doc).get(FieldNames.UUID);
+      return new ScoreNode(uuid, scorer.score(), doc);
+   }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void close() throws IOException {
-        // make sure scorer frees resources
-        scorer.skipTo(Integer.MAX_VALUE);
-    }
+   /**
+    * {@inheritDoc}
+    */
+   public void close() throws IOException
+   {
+      // make sure scorer frees resources
+      scorer.skipTo(Integer.MAX_VALUE);
+   }
 
-    /**
-     * @return always -1.
-     */
-    public int getSize() {
-        return -1;
-    }
+   /**
+    * @return always -1.
+    */
+   public int getSize()
+   {
+      return -1;
+   }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void skip(int n) throws IOException {
-        while (n-- > 0) {
-            if (nextScoreNode() == null) {
-                return;
-            }
-        }
-    }
+   /**
+    * {@inheritDoc}
+    */
+   public void skip(int n) throws IOException
+   {
+      while (n-- > 0)
+      {
+         if (nextScoreNode() == null)
+         {
+            return;
+         }
+      }
+   }
 }

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllQuery.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllQuery.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllQuery.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,12 +16,12 @@
  */
 package org.exoplatform.services.jcr.impl.core.query.lucene;
 
-import java.util.Set;
-
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Searcher;
 import org.apache.lucene.search.Weight;
 
+import java.util.Set;
+
 /**
  * Specialized query that returns / scores all pages in the search index.
  * <p>Use this Query to perform a match '*'.
@@ -50,7 +50,8 @@
      * @param searcher the current searcher.
      * @return the <code>Weight</code> for this Query.
      */
-    protected Weight createWeight(Searcher searcher) {
+    @Override
+   public Weight createWeight(Searcher searcher) {
         return new MatchAllWeight(this, searcher, field);
     }
 
@@ -60,13 +61,15 @@
      * @param field default field for the query.
      * @return the String "%".
      */
-    public String toString(String field) {
+    @Override
+   public String toString(String field) {
         return "%";
     }
 
     /**
      * Does nothing but simply returns. There are no terms to extract.
      */
-    public void extractTerms(Set terms) {
+    @Override
+   public void extractTerms(Set terms) {
     }
 }

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllWeight.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllWeight.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllWeight.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,8 +16,6 @@
  */
 package org.exoplatform.services.jcr.impl.core.query.lucene;
 
-import java.io.IOException;
-
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.Query;
@@ -25,6 +23,8 @@
 import org.apache.lucene.search.Searcher;
 import org.apache.lucene.search.Similarity;
 
+import java.io.IOException;
+
 /**
  * This class implements the Weight calculation for the MatchAllQuery.
  */
@@ -72,28 +72,32 @@
      * @param reader index reader
      * @return a {@link MatchAllScorer} instance
      */
-    protected Scorer createScorer(IndexReader reader) throws IOException {
+    @Override
+   protected Scorer createScorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
         return new MatchAllScorer(reader, field);
     }
 
     /**
      * {@inheritDoc}
      */
-    public Query getQuery() {
+    @Override
+   public Query getQuery() {
         return query;
     }
 
     /**
      * {@inheritDoc}
      */
-    public float getValue() {
+    @Override
+   public float getValue() {
         return value;
     }
 
     /**
      * {@inheritDoc}
      */
-    public float sumOfSquaredWeights() throws IOException {
+    @Override
+   public float sumOfSquaredWeights() throws IOException {
         idf = searcher.getSimilarity().idf(searcher.maxDoc(), searcher.maxDoc()); // compute idf
         queryWeight = idf * 1.0f; // boost         // compute query weight
         return queryWeight * queryWeight;           // square it
@@ -102,7 +106,8 @@
     /**
      * {@inheritDoc}
      */
-    public void normalize(float queryNorm) {
+    @Override
+   public void normalize(float queryNorm) {
         queryWeight *= queryNorm;                   // normalize query weight
         value = queryWeight * idf;                  // idf for document
     }
@@ -110,7 +115,8 @@
     /**
      * {@inheritDoc}
      */
-    public Explanation explain(IndexReader reader, int doc) throws IOException {
+    @Override
+   public Explanation explain(IndexReader reader, int doc) throws IOException {
         return new Explanation(Similarity.getDefault().idf(reader.maxDoc(), reader.maxDoc()),
                 "matchAll");
     }

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NotQuery.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NotQuery.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NotQuery.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,9 +16,6 @@
  */
 package org.exoplatform.services.jcr.impl.core.query.lucene;
 
-import java.io.IOException;
-import java.util.Set;
-
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.Query;
@@ -27,217 +24,271 @@
 import org.apache.lucene.search.Similarity;
 import org.apache.lucene.search.Weight;
 
+import java.io.IOException;
+import java.util.Set;
+
 /**
  * Implements a query that negates documents of a context query. Documents
  * that matched the context query will not match the <code>NotQuery</code> and
  * Documents that did not match the context query will be selected by this
  * <code>NotQuery</code>.
  */
-class NotQuery extends Query {
+class NotQuery extends Query
+{
 
-    /**
-     * The context query to invert.
-     */
-    private final Query context;
+   /**
+    * The context query to invert.
+    */
+   private final Query context;
 
-    /**
-     * The context scorer to invert.
-     */
-    private Scorer contextScorer;
+   /**
+    * The context scorer to invert.
+    */
+   private Scorer contextScorer;
 
-    /**
-     * Creates a new <code>NotQuery</code>.
-     * @param context the context query.
-     */
-    NotQuery(Query context) {
-        this.context = context;
-    }
+   /**
+    * Creates a new <code>NotQuery</code>.
+    * @param context the context query.
+    */
+   NotQuery(Query context)
+   {
+      this.context = context;
+   }
 
-    /**
-     * {@inheritDoc}
-     */
-    protected Weight createWeight(Searcher searcher) {
-        return new NotQueryWeight(searcher);
-    }
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Weight createWeight(Searcher searcher)
+   {
+      return new NotQueryWeight(searcher);
+   }
 
-    /**
-     * {@inheritDoc}
-     */
-    public String toString(String field) {
-        return "NotQuery";
-    }
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public String toString(String field)
+   {
+      return "NotQuery";
+   }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void extractTerms(Set terms) {
-        context.extractTerms(terms);
-    }
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void extractTerms(Set terms)
+   {
+      context.extractTerms(terms);
+   }
 
-    /**
-     * {@inheritDoc}
-     */
-    public Query rewrite(IndexReader reader) throws IOException {
-        Query cQuery = context.rewrite(reader);
-        if (cQuery == context) {
-            return this;
-        } else {
-            return new NotQuery(cQuery);
-        }
-    }
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Query rewrite(IndexReader reader) throws IOException
+   {
+      Query cQuery = context.rewrite(reader);
+      if (cQuery == context)
+      {
+         return this;
+      }
+      else
+      {
+         return new NotQuery(cQuery);
+      }
+   }
 
-    /**
-     * Implements a weight for this <code>NotQuery</code>.
-     */
-    private class NotQueryWeight implements Weight {
+   /**
+    * Implements a weight for this <code>NotQuery</code>.
+    */
+   private class NotQueryWeight extends Weight
+   {
 
-        /**
-         * The searcher to access the index.
-         */
-        private final Searcher searcher;
+      /**
+       * The searcher to access the index.
+       */
+      private final Searcher searcher;
 
-        /**
-         * Creates a new NotQueryWeight with a searcher.
-         * @param searcher the searcher.
-         */
-        NotQueryWeight(Searcher searcher) {
-            this.searcher = searcher;
-        }
+      /**
+       * Creates a new NotQueryWeight with a searcher.
+       * @param searcher the searcher.
+       */
+      NotQueryWeight(Searcher searcher)
+      {
+         this.searcher = searcher;
+      }
 
-        /**
-         * @inheritDoc
-         */
-        public Query getQuery() {
-            return NotQuery.this;
-        }
+      /**
+       * @inheritDoc
+       */
+      @Override
+      public Query getQuery()
+      {
+         return NotQuery.this;
+      }
 
-        /**
-         * @inheritDoc
-         */
-        public float getValue() {
-            return 1.0f;
-        }
+      /**
+       * @inheritDoc
+       */
+      @Override
+      public float getValue()
+      {
+         return 1.0f;
+      }
 
-        /**
-         * @inheritDoc
-         */
-        public float sumOfSquaredWeights() throws IOException {
-            return 1.0f;
-        }
+      /**
+       * @inheritDoc
+       */
+      @Override
+      public float sumOfSquaredWeights() throws IOException
+      {
+         return 1.0f;
+      }
 
-        /**
-         * @inheritDoc
-         */
-        public void normalize(float norm) {
-        }
+      /**
+       * @inheritDoc
+       */
+      @Override
+      public void normalize(float norm)
+      {
+      }
 
-        /**
-         * @inheritDoc
-         */
-        public Scorer scorer(IndexReader reader) throws IOException {
-            contextScorer = context.weight(searcher).scorer(reader);
-            return new NotQueryScorer(reader);
-        }
+      /**
+       * @inheritDoc
+       */
+      @Override
+      public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException
+      {
+         contextScorer = context.weight(searcher).scorer(reader, scoreDocsInOrder, topScorer);
+         return new NotQueryScorer(reader);
+      }
 
-        /**
-         * @throws UnsupportedOperationException always
-         */
-        public Explanation explain(IndexReader reader, int doc) throws IOException {
-            throw new UnsupportedOperationException();
-        }
-    }
+      /**
+       * @throws UnsupportedOperationException always
+       */
+      @Override
+      public Explanation explain(IndexReader reader, int doc) throws IOException
+      {
+         throw new UnsupportedOperationException();
+      }
+   }
 
-    /**
-     * Implements a scorer that inverts the document matches of the context
-     * scorer.
-     */
-    private class NotQueryScorer extends Scorer {
+   /**
+    * Implements a scorer that inverts the document matches of the context
+    * scorer.
+    */
+   private class NotQueryScorer extends Scorer
+   {
 
-        /**
-         * The index reader.
-         */
-        private final IndexReader reader;
+      /**
+       * The index reader.
+       */
+      private final IndexReader reader;
 
-        /**
-         * Current document number.
-         */
-        private int docNo = -1;
+      /**
+       * Current document number.
+       */
+      private int docNo = -1;
 
-        /**
-         * Current document number of the context scorer;
-         */
-        private int contextNo = -1;
+      /**
+       * Current document number of the context scorer;
+       */
+      private int contextNo = -1;
 
-        /**
-         * Creates a new scorer
-         * @param reader
-         */
-        NotQueryScorer(IndexReader reader) {
-            super(Similarity.getDefault());
-            this.reader = reader;
-        }
+      /**
+       * Creates a new scorer
+       * @param reader
+       */
+      NotQueryScorer(IndexReader reader)
+      {
+         super(Similarity.getDefault());
+         this.reader = reader;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean next() throws IOException {
-            if (docNo == -1) {
-                // get first doc of context scorer
-                if (contextScorer.next()) {
-                    contextNo = contextScorer.doc();
-                }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public boolean next() throws IOException
+      {
+         if (docNo == -1)
+         {
+            // get first doc of context scorer
+            if (contextScorer.next())
+            {
+               contextNo = contextScorer.doc();
             }
-            // move to next candidate
-            do {
-                docNo++;
-            } while (reader.isDeleted(docNo) && docNo < reader.maxDoc());
+         }
+         // move to next candidate
+         do
+         {
+            docNo++;
+         }
+         while (reader.isDeleted(docNo) && docNo < reader.maxDoc());
 
-            // check with contextScorer
-            while (contextNo != -1 && contextNo == docNo) {
-                docNo++;
-                if (contextScorer.next()) {
-                    contextNo = contextScorer.doc();
-                } else {
-                    contextNo = -1;
-                }
+         // check with contextScorer
+         while (contextNo != -1 && contextNo == docNo)
+         {
+            docNo++;
+            if (contextScorer.next())
+            {
+               contextNo = contextScorer.doc();
             }
-            return docNo < reader.maxDoc();
-        }
+            else
+            {
+               contextNo = -1;
+            }
+         }
+         return docNo < reader.maxDoc();
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public int doc() {
-            return docNo;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public int doc()
+      {
+         return docNo;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public float score() throws IOException {
-            return 1.0f;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public float score() throws IOException
+      {
+         return 1.0f;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean skipTo(int target) throws IOException {
-            if (contextNo != -1 && contextNo < target) {
-                if (contextScorer.skipTo(target)) {
-                    contextNo = contextScorer.doc();
-                } else {
-                    contextNo = -1;
-                }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public boolean skipTo(int target) throws IOException
+      {
+         if (contextNo != -1 && contextNo < target)
+         {
+            if (contextScorer.skipTo(target))
+            {
+               contextNo = contextScorer.doc();
             }
-            docNo = target - 1;
-            return next();
-        }
+            else
+            {
+               contextNo = -1;
+            }
+         }
+         docNo = target - 1;
+         return next();
+      }
 
-        /**
-         * @throws UnsupportedOperationException always
-         */
-        public Explanation explain(int doc) throws IOException {
-            throw new UnsupportedOperationException();
-        }
-    }
+      /**
+       * @throws UnsupportedOperationException always
+       */
+      @Override
+      public Explanation explain(int doc) throws IOException
+      {
+         throw new UnsupportedOperationException();
+      }
+   }
 }

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ParentAxisQuery.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ParentAxisQuery.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ParentAxisQuery.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,12 +16,6 @@
  */
 package org.exoplatform.services.jcr.impl.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.lucene.index.IndexReader;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.HitCollector;
@@ -30,339 +24,402 @@
 import org.apache.lucene.search.Searcher;
 import org.apache.lucene.search.Similarity;
 import org.apache.lucene.search.Weight;
-
 import org.exoplatform.services.jcr.datamodel.InternalQName;
 import org.exoplatform.services.jcr.impl.core.query.lucene.hits.Hits;
 import org.exoplatform.services.jcr.impl.core.query.lucene.hits.ScorerHits;
 
+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.
  */
-class ParentAxisQuery extends Query {
+class ParentAxisQuery extends Query
+{
 
-    /**
-     * Default score is 1.0f.
-     */
-    private static final Float DEFAULT_SCORE = new Float(1.0f);
+   /**
+    * Default score is 1.0f.
+    */
+   private static final Float DEFAULT_SCORE = new Float(1.0f);
 
-    /**
-     * The context query
-     */
-    private final Query contextQuery;
+   /**
+    * The context query
+    */
+   private final Query contextQuery;
 
-    /**
-     * The nameTest to apply on the parent axis, or <code>null</code> if any
-     * parent node should be selected.
-     */
-    private final InternalQName nameTest;
+   /**
+    * The nameTest to apply on the parent axis, or <code>null</code> if any
+    * parent node should be selected.
+    */
+   private final InternalQName nameTest;
 
-    /**
-     * The index format version.
-     */
-    private final IndexFormatVersion version;
+   /**
+    * The index format version.
+    */
+   private final IndexFormatVersion version;
 
-    /**
-     * The internal namespace mappings.
-     */
-    private final NamespaceMappings nsMappings;
+   /**
+    * The internal namespace mappings.
+    */
+   private final NamespaceMappings nsMappings;
 
-    /**
-     * The scorer of the context query
-     */
-    private Scorer contextScorer;
+   /**
+    * The scorer of the context query
+    */
+   private Scorer contextScorer;
 
-    /**
-     * Creates a new <code>ParentAxisQuery</code> based on a
-     * <code>context</code> query.
-     *
-     * @param context  the context for this query.
-     * @param nameTest a name test or <code>null</code> if any parent node is
-     *                 selected.
-     * @param version the index format version.
-     * @param nsMappings the internal namespace mappings.
-     */
-    ParentAxisQuery(Query context, InternalQName nameTest,
-                   IndexFormatVersion version, NamespaceMappings nsMappings) {
-        this.contextQuery = context;
-        this.nameTest = nameTest;
-        this.version = version;
-        this.nsMappings = nsMappings;
-    }
+   /**
+    * Creates a new <code>ParentAxisQuery</code> based on a
+    * <code>context</code> query.
+    *
+    * @param context  the context for this query.
+    * @param nameTest a name test or <code>null</code> if any parent node is
+    *                 selected.
+    * @param version the index format version.
+    * @param nsMappings the internal namespace mappings.
+    */
+   ParentAxisQuery(Query context, InternalQName nameTest, IndexFormatVersion version, NamespaceMappings nsMappings)
+   {
+      this.contextQuery = context;
+      this.nameTest = nameTest;
+      this.version = version;
+      this.nsMappings = nsMappings;
+   }
 
-    /**
-     * Creates a <code>Weight</code> instance for this query.
-     *
-     * @param searcher the <code>Searcher</code> instance to use.
-     * @return a <code>ParentAxisWeight</code>.
-     */
-    protected Weight createWeight(Searcher searcher) {
-        return new ParentAxisWeight(searcher);
-    }
+   /**
+    * Creates a <code>Weight</code> instance for this query.
+    *
+    * @param searcher the <code>Searcher</code> instance to use.
+    * @return a <code>ParentAxisWeight</code>.
+    */
+   @Override
+   public Weight createWeight(Searcher searcher)
+   {
+      return new ParentAxisWeight(searcher);
+   }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void extractTerms(Set terms) {
-        contextQuery.extractTerms(terms);
-    }
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void extractTerms(Set terms)
+   {
+      contextQuery.extractTerms(terms);
+   }
 
-    /**
-     * {@inheritDoc}
-     */
-    public Query rewrite(IndexReader reader) throws IOException {
-        Query cQuery = contextQuery.rewrite(reader);
-        if (cQuery == contextQuery) {
-            return this;
-        } else {
-            return new ParentAxisQuery(cQuery, nameTest, version, nsMappings);
-        }
-    }
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Query rewrite(IndexReader reader) throws IOException
+   {
+      Query cQuery = contextQuery.rewrite(reader);
+      if (cQuery == contextQuery)
+      {
+         return this;
+      }
+      else
+      {
+         return new ParentAxisQuery(cQuery, nameTest, version, nsMappings);
+      }
+   }
 
-    /**
-     * Always returns 'ParentAxisQuery'.
-     *
-     * @param field the name of a field.
-     * @return 'ParentAxisQuery'.
-     */
-    public String toString(String field) {
-       return "ParentAxisQuery "+"nameTest="+(nameTest!=null?nameTest.toString():"null")+" contextQuery="+contextQuery.toString();
-    }
+   /**
+    * Always returns 'ParentAxisQuery'.
+    *
+    * @param field the name of a field.
+    * @return 'ParentAxisQuery'.
+    */
+   @Override
+   public String toString(String field)
+   {
+      return "ParentAxisQuery " + "nameTest=" + (nameTest != null ? nameTest.toString() : "null") + " contextQuery="
+         + contextQuery.toString();
+   }
 
-    //-----------------------< ParentAxisWeight >-------------------------------
+   //-----------------------< ParentAxisWeight >-------------------------------
 
-    /**
-     * The <code>Weight</code> implementation for this <code>ParentAxisQuery</code>.
-     */
-    private class ParentAxisWeight implements Weight {
+   /**
+    * The <code>Weight</code> implementation for this <code>ParentAxisQuery</code>.
+    */
+   private class ParentAxisWeight extends Weight
+   {
 
-        /**
-         * The searcher in use
-         */
-        private final Searcher searcher;
+      /**
+       * The searcher in use
+       */
+      private final Searcher searcher;
 
-        /**
-         * Creates a new <code>ParentAxisWeight</code> instance using
-         * <code>searcher</code>.
-         *
-         * @param searcher a <code>Searcher</code> instance.
-         */
-        private ParentAxisWeight(Searcher searcher) {
-            this.searcher = searcher;
-        }
+      /**
+       * Creates a new <code>ParentAxisWeight</code> instance using
+       * <code>searcher</code>.
+       *
+       * @param searcher a <code>Searcher</code> instance.
+       */
+      private ParentAxisWeight(Searcher searcher)
+      {
+         this.searcher = searcher;
+      }
 
-        /**
-         * Returns this <code>ParentAxisQuery</code>.
-         *
-         * @return this <code>ParentAxisQuery</code>.
-         */
-        public Query getQuery() {
-            return ParentAxisQuery.this;
-        }
+      /**
+       * Returns this <code>ParentAxisQuery</code>.
+       *
+       * @return this <code>ParentAxisQuery</code>.
+       */
+      @Override
+      public Query getQuery()
+      {
+         return ParentAxisQuery.this;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public float getValue() {
-            return 1.0f;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public float getValue()
+      {
+         return 1.0f;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public float sumOfSquaredWeights() throws IOException {
-            return 1.0f;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public float sumOfSquaredWeights() throws IOException
+      {
+         return 1.0f;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public void normalize(float norm) {
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public void normalize(float norm)
+      {
+      }
 
-        /**
-         * Creates a scorer for this <code>ParentAxisQuery</code>.
-         *
-         * @param reader a reader for accessing the index.
-         * @return a <code>ParentAxisScorer</code>.
-         * @throws IOException if an error occurs while reading from the index.
-         */
-        public Scorer scorer(IndexReader reader) throws IOException {
-            contextScorer = contextQuery.weight(searcher).scorer(reader);
-            HierarchyResolver resolver = (HierarchyResolver) reader;
-            return new ParentAxisScorer(searcher.getSimilarity(),
-                    reader, searcher, resolver);
-        }
+      /**
+       * Creates a scorer for this <code>ParentAxisQuery</code>.
+       *
+       * @param reader a reader for accessing the index.
+       * @return a <code>ParentAxisScorer</code>.
+       * @throws IOException if an error occurs while reading from the index.
+       */
+      @Override
+      public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException
+      {
+         contextScorer = contextQuery.weight(searcher).scorer(reader, scoreDocsInOrder, topScorer);
+         HierarchyResolver resolver = (HierarchyResolver)reader;
+         return new ParentAxisScorer(searcher.getSimilarity(), reader, searcher, resolver);
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public Explanation explain(IndexReader reader, int doc) throws IOException {
-            return new Explanation();
-        }
-    }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public Explanation explain(IndexReader reader, int doc) throws IOException
+      {
+         return new Explanation();
+      }
+   }
 
-    //--------------------------< ParentAxisScorer >----------------------------
+   //--------------------------< ParentAxisScorer >----------------------------
 
-    /**
-     * Implements a <code>Scorer</code> for this <code>ParentAxisQuery</code>.
-     */
-    private class ParentAxisScorer extends Scorer {
+   /**
+    * Implements a <code>Scorer</code> for this <code>ParentAxisQuery</code>.
+    */
+   private class ParentAxisScorer extends Scorer
+   {
 
-        /**
-         * An <code>IndexReader</code> to access the index.
-         */
-        private final IndexReader reader;
+      /**
+       * An <code>IndexReader</code> to access the index.
+       */
+      private final IndexReader reader;
 
-        /**
-         * The <code>HierarchyResolver</code> of the index.
-         */
-        private final HierarchyResolver hResolver;
+      /**
+       * The <code>HierarchyResolver</code> of the index.
+       */
+      private final HierarchyResolver hResolver;
 
-        /**
-         * The searcher instance.
-         */
-        private final Searcher searcher;
+      /**
+       * The searcher instance.
+       */
+      private final Searcher searcher;
 
-        /**
-         * BitSet storing the id's of selected documents
-         */
-        private BitSet hits;
+      /**
+       * BitSet storing the id's of selected documents
+       */
+      private BitSet hits;
 
-        /**
-         * Map that contains the scores from matching documents from the context
-         * query. To save memory only scores that are not equal to 1.0f are put
-         * to this map.
-         * <p/>
-         * key=[Integer] id of selected document from context query<br>
-         * value=[Float] score for that document
-         */
-        private final Map scores = new HashMap();
+      /**
+       * Map that contains the scores from matching documents from the context
+       * query. To save memory only scores that are not equal to 1.0f are put
+       * to this map.
+       * <p/>
+       * key=[Integer] id of selected document from context query<br>
+       * value=[Float] score for that document
+       */
+      private final Map scores = new HashMap();
 
-        /**
-         * The next document id to return
-         */
-        private int nextDoc = -1;
+      /**
+       * The next document id to return
+       */
+      private int nextDoc = -1;
 
-        /**
-         * Creates a new <code>ParentAxisScorer</code>.
-         *
-         * @param similarity the <code>Similarity</code> instance to use.
-         * @param reader     for index access.
-         * @param searcher   the index searcher.
-         * @param resolver   the hierarchy resolver.
-         */
-        protected ParentAxisScorer(Similarity similarity,
-                                   IndexReader reader,
-                                   Searcher searcher,
-                                   HierarchyResolver resolver) {
-            super(similarity);
-            this.reader = reader;
-            this.searcher = searcher;
-            this.hResolver = resolver;
-        }
+      /**
+       * Creates a new <code>ParentAxisScorer</code>.
+       *
+       * @param similarity the <code>Similarity</code> instance to use.
+       * @param reader     for index access.
+       * @param searcher   the index searcher.
+       * @param resolver   the hierarchy resolver.
+       */
+      protected ParentAxisScorer(Similarity similarity, IndexReader reader, Searcher searcher,
+         HierarchyResolver resolver)
+      {
+         super(similarity);
+         this.reader = reader;
+         this.searcher = searcher;
+         this.hResolver = resolver;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean next() throws IOException {
-            calculateParent();
-            nextDoc = hits.nextSetBit(nextDoc + 1);
-            return nextDoc > -1;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public boolean next() throws IOException
+      {
+         calculateParent();
+         nextDoc = hits.nextSetBit(nextDoc + 1);
+         return nextDoc > -1;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public int doc() {
-            return nextDoc;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public int doc()
+      {
+         return nextDoc;
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public float score() throws IOException {
-            Float score = (Float) scores.get(new Integer(nextDoc));
-            if (score == null) {
-                score = DEFAULT_SCORE;
-            }
-            return score.floatValue();
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public float score() throws IOException
+      {
+         Float score = (Float)scores.get(new Integer(nextDoc));
+         if (score == null)
+         {
+            score = DEFAULT_SCORE;
+         }
+         return score.floatValue();
+      }
 
-        /**
-         * {@inheritDoc}
-         */
-        public boolean skipTo(int target) throws IOException {
-            calculateParent();
-            nextDoc = hits.nextSetBit(target);
-            return nextDoc > -1;
-        }
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public boolean skipTo(int target) throws IOException
+      {
+         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();
-        }
+      /**
+       * {@inheritDoc}
+       *
+       * @throws UnsupportedOperationException this implementation always
+       *                                       throws an <code>UnsupportedOperationException</code>.
+       */
+      @Override
+      public Explanation explain(int doc) throws IOException
+      {
+         throw new UnsupportedOperationException();
+      }
 
-        private void calculateParent() throws IOException {
-            if (hits == null) {
-                hits = new BitSet(reader.maxDoc());
+      private void calculateParent() throws IOException
+      {
+         if (hits == null)
+         {
+            hits = new BitSet(reader.maxDoc());
 
-                final IOException[] ex = new IOException[1];
-                contextScorer.score(new HitCollector() {
+            final IOException[] ex = new IOException[1];
+            contextScorer.score(new HitCollector()
+            {
 
-                    private int[] docs = new int[1];
+               private int[] docs = new int[1];
 
-                    public void collect(int doc, float score) {
-                        try {
-                            docs = hResolver.getParents(doc, docs);
-                            if (docs.length == 1) {
-                                // optimize single value
-                                hits.set(docs[0]);
-                                if (score != DEFAULT_SCORE.floatValue()) {
-                                    scores.put(new Integer(docs[0]), new Float(score));
-                                }
-                            } else {
-                                for (int i = 0; i < docs.length; i++) {
-                                    hits.set(docs[i]);
-                                    if (score != DEFAULT_SCORE.floatValue()) {
-                                        scores.put(new Integer(docs[i]), new Float(score));
-                                    }
-                                }
-                            }
-                        } catch (IOException e) {
-                            ex[0] = e;
+               @Override
+               public void collect(int doc, float score)
+               {
+                  try
+                  {
+                     docs = hResolver.getParents(doc, docs);
+                     if (docs.length == 1)
+                     {
+                        // optimize single value
+                        hits.set(docs[0]);
+                        if (score != DEFAULT_SCORE.floatValue())
+                        {
+                           scores.put(new Integer(docs[0]), new Float(score));
                         }
-                    }
-                });
+                     }
+                     else
+                     {
+                        for (int i = 0; i < docs.length; i++)
+                        {
+                           hits.set(docs[i]);
+                           if (score != DEFAULT_SCORE.floatValue())
+                           {
+                              scores.put(new Integer(docs[i]), new Float(score));
+                           }
+                        }
+                     }
+                  }
+                  catch (IOException e)
+                  {
+                     ex[0] = e;
+                  }
+               }
+            });
 
-                if (ex[0] != null) {
-                    throw ex[0];
-                }
+            if (ex[0] != null)
+            {
+               throw ex[0];
+            }
 
-                // filter out documents that do not match the name test
-                if (nameTest != null) {
-                    Query nameQuery = new NameQuery(nameTest, version, nsMappings);
-                    Hits nameHits = new ScorerHits(nameQuery.weight(searcher).scorer(reader));
-                    for (int i = hits.nextSetBit(0); i >= 0; i = hits.nextSetBit(i + 1)) {
-                        int doc = nameHits.skipTo(i);
-                        if (doc == -1) {
-                            // no more name tests, clear remaining
-                            hits.clear(i, hits.length());
-                        } else {
-                            // assert doc >= i
-                            if (doc > i) {
-                                // clear hits
-                                hits.clear(i, doc);
-                                i = doc;
-                            }
-                        }
-                    }
-                }
+            // filter out documents that do not match the name test
+            if (nameTest != null)
+            {
+               Query nameQuery = new NameQuery(nameTest, version, nsMappings);
+               Hits nameHits = new ScorerHits(nameQuery.weight(searcher).scorer(reader, true, false));
+               for (int i = hits.nextSetBit(0); i >= 0; i = hits.nextSetBit(i + 1))
+               {
+                  int doc = nameHits.skipTo(i);
+                  if (doc == -1)
+                  {
+                     // no more name tests, clear remaining
+                     hits.clear(i, hits.length());
+                  }
+                  else
+                  {
+                     // assert doc >= i
+                     if (doc > i)
+                     {
+                        // clear hits
+                        hits.clear(i, doc);
+                        i = doc;
+                     }
+                  }
+               }
             }
-        }
-    }
+         }
+      }
+   }
 }

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryHitsQuery.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryHitsQuery.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryHitsQuery.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,13 +16,6 @@
  */
 package org.exoplatform.services.jcr.impl.core.query.lucene;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermDocs;
@@ -35,6 +28,13 @@
 import org.apache.lucene.search.Weight;
 import org.exoplatform.services.jcr.impl.core.SessionImpl;
 
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
 /**
  * <code>QueryHitsQuery</code> exposes a {@link QueryHits} implementation again
  * as a Lucene Query.
@@ -58,21 +58,24 @@
     /**
      * {@inheritDoc}
      */
-    protected Weight createWeight(Searcher searcher) throws IOException {
+    @Override
+   public Weight createWeight(Searcher searcher) throws IOException {
         return new QueryHitsQueryWeight(searcher.getSimilarity());
     }
 
     /**
      * {@inheritDoc}
      */
-    public String toString(String field) {
+    @Override
+   public String toString(String field) {
         return "QueryHitsQuery";
     }
 
     /**
      * {@inheritDoc}
      */
-    public void extractTerms(Set terms) {
+    @Override
+   public void extractTerms(Set terms) {
         // no terms
     }
 
@@ -96,7 +99,7 @@
     /**
      * The Weight implementation for this query.
      */
-    public class QueryHitsQueryWeight implements Weight {
+    public class QueryHitsQueryWeight extends Weight {
 
         /**
          * The similarity.
@@ -115,41 +118,48 @@
         /**
          * {@inheritDoc}
          */
-        public Query getQuery() {
+        @Override
+      public Query getQuery() {
             return QueryHitsQuery.this;
         }
 
         /**
          * {@inheritDoc}
          */
-        public float getValue() {
+        @Override
+      public float getValue() {
             return 1.0f;
         }
 
         /**
          * {@inheritDoc}
          */
-        public float sumOfSquaredWeights() throws IOException {
+        @Override
+      public float sumOfSquaredWeights() throws IOException {
             return 1.0f;
         }
 
         /**
          * {@inheritDoc}
          */
-        public void normalize(float norm) {
+        @Override
+      public void normalize(float norm) {
         }
 
         /**
          * {@inheritDoc}
          */
-        public Scorer scorer(IndexReader reader) throws IOException {
+        @Override
+      public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
+           // TODO: use arguments!
             return new QueryHitsQueryScorer(reader, similarity);
         }
 
         /**
          * {@inheritDoc}
          */
-        public Explanation explain(IndexReader reader, int doc) throws IOException {
+        @Override
+      public Explanation explain(IndexReader reader, int doc) throws IOException {
             return new Explanation();
         }
     }
@@ -215,7 +225,8 @@
         /**
          * {@inheritDoc}
          */
-        public boolean next() throws IOException {
+        @Override
+      public boolean next() throws IOException {
             if (docs.hasNext()) {
                 currentDoc = (Integer) docs.next();
                 return true;
@@ -226,21 +237,24 @@
         /**
          * {@inheritDoc}
          */
-        public int doc() {
+        @Override
+      public int doc() {
             return currentDoc.intValue();
         }
 
         /**
          * {@inheritDoc}
          */
-        public float score() throws IOException {
+        @Override
+      public float score() throws IOException {
             return ((Float) scores.get(currentDoc)).floatValue();
         }
 
         /**
          * {@inheritDoc}
          */
-        public boolean skipTo(int target) throws IOException {
+        @Override
+      public boolean skipTo(int target) throws IOException {
             do {
                 if (!next()) {
                     return false;
@@ -252,7 +266,8 @@
         /**
          * {@inheritDoc}
          */
-        public Explanation explain(int doc) throws IOException {
+        @Override
+      public Explanation explain(int doc) throws IOException {
             return new Explanation();
         }
     }

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RangeQuery.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RangeQuery.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RangeQuery.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,15 +16,6 @@
  */
 package org.exoplatform.services.jcr.impl.core.query.lucene;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.Iterator;
-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;
@@ -37,6 +28,15 @@
 import org.apache.lucene.search.Similarity;
 import org.apache.lucene.search.Weight;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * Implements a lucene range query.
  */
@@ -121,7 +121,8 @@
      * @return the rewritten query or this query if rewriting is not possible.
      * @throws IOException if an error occurs.
      */
-    public Query rewrite(IndexReader reader) throws IOException {
+    @Override
+   public Query rewrite(IndexReader reader) throws IOException {
         if (transform == TRANSFORM_NONE) {
             return new ConstantScoreRangeQuery(lowerTerm.field(),
                     lowerTerm.text(), upperTerm.text(), inclusive,
@@ -139,7 +140,8 @@
      * @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 RangeQueryWeight(searcher);
     }
 
@@ -148,7 +150,8 @@
      * @param field the field name for which to create a string representation.
      * @return a string representation of this query.
      */
-    public String toString(String field) {
+    @Override
+   public String toString(String field) {
         StringBuffer buffer = new StringBuffer();
         if (!getField().equals(field)) {
             buffer.append(getField());
@@ -169,7 +172,8 @@
     /**
      * {@inheritDoc}
      */
-    public void extractTerms(Set terms) {
+    @Override
+   public void extractTerms(Set terms) {
         // cannot extract terms
     }
 
@@ -203,7 +207,8 @@
          * @param reader index reader
          * @return a {@link RangeQueryScorer} instance
          */
-        protected Scorer createScorer(IndexReader reader) {
+        @Override
+      protected Scorer createScorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) {
             return new RangeQueryScorer(searcher.getSimilarity(), reader);
         };
 
@@ -212,34 +217,39 @@
          *
          * @return this <code>RangeQuery</code>.
          */
-        public Query getQuery() {
+        @Override
+      public Query getQuery() {
             return RangeQuery.this;
         }
 
         /**
          * {@inheritDoc}
          */
-        public float getValue() {
+        @Override
+      public float getValue() {
             return 1.0f;
         }
 
         /**
          * {@inheritDoc}
          */
-        public float sumOfSquaredWeights() throws IOException {
+        @Override
+      public float sumOfSquaredWeights() throws IOException {
             return 1.0f;
         }
 
         /**
          * {@inheritDoc}
          */
-        public void normalize(float norm) {
+        @Override
+      public void normalize(float norm) {
         }
 
         /**
          * {@inheritDoc}
          */
-        public Explanation explain(IndexReader reader, int doc) throws IOException {
+        @Override
+      public Explanation explain(IndexReader reader, int doc) throws IOException {
             return new Explanation();
         }
     }
@@ -321,7 +331,8 @@
         /**
          * {@inheritDoc}
          */
-        public boolean next() throws IOException {
+        @Override
+      public boolean next() throws IOException {
             calculateHits();
             nextDoc = hits.nextSetBit(nextDoc + 1);
             return nextDoc > -1;
@@ -330,21 +341,24 @@
         /**
          * {@inheritDoc}
          */
-        public int doc() {
+        @Override
+      public int doc() {
             return nextDoc;
         }
 
         /**
          * {@inheritDoc}
          */
-        public float score() {
+        @Override
+      public float score() {
             return 1.0f;
         }
 
         /**
          * {@inheritDoc}
          */
-        public boolean skipTo(int target) throws IOException {
+        @Override
+      public boolean skipTo(int target) throws IOException {
             calculateHits();
             nextDoc = hits.nextSetBit(target);
             return nextDoc > -1;
@@ -354,7 +368,8 @@
          * Returns an empty Explanation object.
          * @return an empty Explanation object.
          */
-        public Explanation explain(int doc) {
+        @Override
+      public Explanation explain(int doc) {
             return new Explanation();
         }
 

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RefCountingIndexReader.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RefCountingIndexReader.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RefCountingIndexReader.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,11 +16,11 @@
  */
 package org.exoplatform.services.jcr.impl.core.query.lucene;
 
-import java.io.IOException;
-
 import org.apache.lucene.index.FilterIndexReader;
 import org.apache.lucene.index.IndexReader;
 
+import java.io.IOException;
+
 /**
  * <code>RefCountingIndexReader</code>...
  */
@@ -48,7 +48,8 @@
     /**
      * @return the current reference count value.
      */
-    synchronized int getRefCount() {
+    @Override
+   public synchronized int getRefCount() {
         return refCount;
     }
 
@@ -65,7 +66,8 @@
 
     //-----------------------< FilterIndexReader >--------------------------
 
-    protected void doClose() throws IOException {
+    @Override
+   protected void doClose() throws IOException {
         Util.closeOrRelease(in);
     }
 }

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -2745,7 +2745,7 @@
       IndexSearcher searcher = new IndexSearcher(reader);
       searcher.setSimilarity(getSimilarity());
 
-      return new LuceneQueryHits(reader, searcher, query);
+      return new LuceneQueryHits(reader, searcher, query, true, false);
    }
 
    /**

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingleIndex.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingleIndex.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingleIndex.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -27,11 +27,9 @@
 import org.apache.lucene.index.TermDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
-import org.apache.lucene.store.RAMDirectory;
 import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
 import org.exoplatform.services.jcr.datamodel.NodeData;
 import org.exoplatform.services.jcr.impl.core.query.IndexingTree;
-
 import org.exoplatform.services.jcr.util.IdGenerator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,9 +39,7 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
-import java.util.concurrent.CountDownLatch;
 
-import javax.jcr.ItemNotFoundException;
 import javax.jcr.RepositoryException;
 
 /**
@@ -99,6 +95,7 @@
       log.info(dir);
       //FSDirectory.getDirectory(indexDirectory2);
       this.writer = new IndexWriter(directory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
+      this.writer.setRAMBufferSizeMB(1);
       this.reader = IndexReader.open(directory, true);
       this.cache = new DocNumberCache(handler.getCacheSize());
 
@@ -175,6 +172,16 @@
 
    private class JcrSingleIndexReader extends FilterIndexReader implements HierarchyResolver
    {
+      @Override
+      public IndexReader[] getSequentialSubReaders()
+      {
+         // This method returns null, so Lucene internals doesn't explode this reader on it's subreaders.
+         // This is used to retrieve this index reader as HierarchyResolver in ChildAxisQuery. If this method
+         // is not overridden with null-returning one, then ClassCast exception is thrown.
+         // This solution confirmed via Lucene mailing-list on May 27 2010.
+         return null;
+      }
+
       /**
        * @param reader
        */

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WildcardQuery.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WildcardQuery.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WildcardQuery.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -129,10 +129,12 @@
     * @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))
       {
+         @Override
          protected FilteredTermEnum getEnum(IndexReader reader) throws IOException
          {
             return new WildcardTermEnum(reader, field, propName, pattern, transform);
@@ -157,7 +159,8 @@
     * @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);
    }
@@ -168,6 +171,7 @@
     * @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 propName + ":" + pattern;
@@ -176,6 +180,7 @@
    /**
     * {@inheritDoc}
     */
+   @Override
    public void extractTerms(Set terms)
    {
       if (multiTermQuery != null)
@@ -207,7 +212,8 @@
        * @param reader index reader
        * @return a {@link WildcardQueryScorer} instance
        */
-      protected Scorer createScorer(IndexReader reader)
+      @Override
+      protected Scorer createScorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer)
       {
          return new WildcardQueryScorer(searcher.getSimilarity(), reader);
       }
@@ -217,6 +223,7 @@
        *
        * @return this <code>WildcardQuery</code>.
        */
+      @Override
       public Query getQuery()
       {
          return WildcardQuery.this;
@@ -225,6 +232,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public float getValue()
       {
          return 1.0f;
@@ -233,6 +241,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public float sumOfSquaredWeights() throws IOException
       {
          return 1.0f;
@@ -241,6 +250,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public void normalize(float norm)
       {
       }
@@ -248,6 +258,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public Explanation explain(IndexReader reader, int doc) throws IOException
       {
          return new Explanation();
@@ -326,6 +337,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public boolean next() throws IOException
       {
          calculateHits();
@@ -336,6 +348,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public int doc()
       {
          return nextDoc;
@@ -344,6 +357,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public float score()
       {
          return 1.0f;
@@ -352,6 +366,7 @@
       /**
        * {@inheritDoc}
        */
+      @Override
       public boolean skipTo(int target) throws IOException
       {
          calculateHits();
@@ -363,6 +378,7 @@
        * Returns an empty Explanation object.
        * @return an empty Explanation object.
        */
+      @Override
       public Explanation explain(int doc)
       {
          return new Explanation();

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -16,15 +16,15 @@
  */
 package org.exoplatform.services.jcr.impl.core.query.lucene.directory;
 
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.store.NativeFSLockFactory;
 import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
 
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+
 /**
  * <code>FSDirectoryManager</code> implements a directory manager for
  * {@link FSDirectory} instances.
@@ -61,7 +61,15 @@
         } else {
             dir = new File(baseDir, name);
         }
-        return FSDirectory.getDirectory(dir, new NativeFSLockFactory(dir));
+        // FSDirectory itself doesnt create dirs now
+        if (!dir.exists())
+        {
+           if (!dir.mkdirs())
+           {
+              throw new IOException("Cannot create directory: " + dir);
+           }
+        }
+        return FSDirectory.open(dir, new NativeFSLockFactory(dir));
     }
 
     /**

Modified: jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/directory/DirectoryManagerTest.java
===================================================================
--- jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/directory/DirectoryManagerTest.java	2010-05-26 14:43:44 UTC (rev 2439)
+++ jcr/branches/1.12-LIC-709/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/directory/DirectoryManagerTest.java	2010-05-28 06:54:18 UTC (rev 2440)
@@ -33,88 +33,105 @@
  * <code>DirectoryManagerTest</code> performs tests on directory manager
  * implementations.
  */
-public class DirectoryManagerTest extends TestCase {
+public class DirectoryManagerTest extends TestCase
+{
 
-    private static final Collection IMPLEMENTATIONS = Arrays
-	    .asList(new Class[] { FSDirectoryManager.class,
-		    RAMDirectoryManager.class });
+   private static final Collection IMPLEMENTATIONS =
+      Arrays.asList(new Class[]{FSDirectoryManager.class, RAMDirectoryManager.class});
 
-    private static final SearchIndex INDEX = new SearchIndex();
+   private static final SearchIndex INDEX = new SearchIndex();
 
-    private static final String TEST = "test";
+   private static final String TEST = "test";
 
-    private static final String RENAMED = "renamed";
+   private static final String RENAMED = "renamed";
 
-    static {
-	INDEX.setPath(new File(new File("target"), "directory-factory-test")
-		.getAbsolutePath());
-    }
+   static
+   {
+      File dst = new File(new File("target"), "directory-factory-test");
+      dst.mkdirs();
+      INDEX.setPath(dst.getAbsolutePath());
+   }
 
-    protected void tearDown() throws Exception {
-	new File(INDEX.getPath(), TEST).delete();
-	new File(INDEX.getPath(), RENAMED).delete();
-    }
+   @Override
+   protected void tearDown() throws Exception
+   {
+//      new File(INDEX.getPath(), TEST).delete();
+//      new File(INDEX.getPath(), RENAMED).delete();
+   }
 
-    public void testHasDirectory() throws Exception {
-	execute(new Callable() {
-	    public void call(DirectoryManager directoryManager)
-		    throws Exception {
-		Directory dir = directoryManager.getDirectory(TEST);
-		assertTrue(directoryManager.hasDirectory(TEST));
-		dir.close();
-	    }
-	});
-    }
+   public void testHasDirectory() throws Exception
+   {
+      execute(new Callable()
+      {
+         public void call(DirectoryManager directoryManager) throws Exception
+         {
+            Directory dir = directoryManager.getDirectory(TEST);
+            assertTrue("Impl:" + directoryManager.getClass().getName(), directoryManager.hasDirectory(TEST));
+            dir.close();
+         }
+      });
+   }
 
-    public void testDelete() throws Exception {
-	execute(new Callable() {
-	    public void call(DirectoryManager directoryManager)
-		    throws Exception {
-		directoryManager.getDirectory(TEST).close();
-		directoryManager.delete(TEST);
-		assertFalse(directoryManager.hasDirectory(TEST));
-	    }
-	});
-    }
+   public void testDelete() throws Exception
+   {
+      execute(new Callable()
+      {
+         public void call(DirectoryManager directoryManager) throws Exception
+         {
+            directoryManager.getDirectory(TEST).close();
+            directoryManager.delete(TEST);
+            assertFalse("Impl:" + directoryManager.getClass().getName(), directoryManager.hasDirectory(TEST));
+         }
+      });
+   }
 
-    public void testGetDirectoryNames() throws Exception {
-	execute(new Callable() {
-	    public void call(DirectoryManager directoryManager)
-		    throws Exception {
-		directoryManager.getDirectory(TEST).close();
-		assertTrue(Arrays.asList(directoryManager.getDirectoryNames())
-			.contains(TEST));
-	    }
-	});
-    }
+   public void testGetDirectoryNames() throws Exception
+   {
+      execute(new Callable()
+      {
+         public void call(DirectoryManager directoryManager) throws Exception
+         {
+            directoryManager.getDirectory(TEST).close();
+            assertTrue("Impl:" + directoryManager.getClass().getName(), Arrays.asList(directoryManager.getDirectoryNames()).contains(TEST));
+         }
+      });
+   }
 
-    public void testRename() throws Exception {
-	execute(new Callable() {
-	    public void call(DirectoryManager directoryManager)
-		    throws Exception {
-		directoryManager.getDirectory(TEST).close();
-		directoryManager.rename(TEST, RENAMED);
-		assertTrue(directoryManager.hasDirectory(RENAMED));
-		assertFalse(directoryManager.hasDirectory(TEST));
-	    }
-	});
-    }
+   public void testRename() throws Exception
+   {
+      execute(new Callable()
+      {
+         public void call(DirectoryManager directoryManager) throws Exception
+         {
+            directoryManager.getDirectory(TEST).close();
+            directoryManager.rename(TEST, RENAMED);
+            assertTrue("Impl:" + directoryManager.getClass().getName(), directoryManager.hasDirectory(RENAMED));
+            assertFalse("Impl:" + directoryManager.getClass().getName(), directoryManager.hasDirectory(TEST));
+         }
+      });
+   }
 
-    private void execute(Callable callable) throws Exception {
-	for (Iterator it = IMPLEMENTATIONS.iterator(); it.hasNext();) {
-	    Class clazz = (Class) it.next();
-	    DirectoryManager dirMgr = (DirectoryManager) clazz.newInstance();
-	    dirMgr.init(INDEX);
-	    try {
-		callable.call(dirMgr);
-	    } finally {
-		dirMgr.dispose();
-	    }
-	}
-    }
+   private void execute(Callable callable) throws Exception
+   {
+      for (Iterator it = IMPLEMENTATIONS.iterator(); it.hasNext();)
+      {
+         Class clazz = (Class)it.next();
+         DirectoryManager dirMgr = (DirectoryManager)clazz.newInstance();
+         dirMgr.init(INDEX);
+         try
+         {
+            callable.call(dirMgr);
+         }
+         finally
+         {
+            dirMgr.dispose();
+         }
+      }
+   }
 
-    private interface Callable {
+   private interface Callable
+   {
 
-	public void call(DirectoryManager directoryManager) throws Exception;
-    }
+      public void call(DirectoryManager directoryManager) throws Exception;
+   }
 }



More information about the exo-jcr-commits mailing list