jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r544263 - in /jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene: ChildAxisQuery.java DefaultXMLExcerpt.java DerefQuery.java DescendantSelfAxisQuery.java NotQuery.java ParentAxisQuery.java
Date Mon, 04 Jun 2007 21:00:08 GMT
Author: jukka
Date: Mon Jun  4 14:00:05 2007
New Revision: 544263

URL: http://svn.apache.org/viewvc?view=rev&rev=544263
Log:
1.3: Merged revision 536145 (JCR-900)

Modified:
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultXMLExcerpt.java
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java?view=diff&rev=544263&r1=544262&r2=544263
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
Mon Jun  4 14:00:05 2007
@@ -56,7 +56,7 @@
     /**
      * The context query
      */
-    private final Query contextQuery;
+    private Query contextQuery;
 
     /**
      * The nameTest to apply on the child axis, or <code>null</code> if all
@@ -127,6 +127,18 @@
      */
     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 ChildAxisQuery(itemMgr, cQuery, nameTest, position);
+        }
     }
 
     /**

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultXMLExcerpt.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultXMLExcerpt.java?view=diff&rev=544263&r1=544262&r2=544263
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultXMLExcerpt.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DefaultXMLExcerpt.java
Mon Jun  4 14:00:05 2007
@@ -54,6 +54,11 @@
     private Query query;
 
     /**
+     * Indicates whether the query is already rewritten.
+     */
+    private boolean rewritten = false;
+
+    /**
      * {@inheritDoc}
      */
     public void init(Query query, SearchIndex index) throws IOException {
@@ -68,6 +73,10 @@
             throws IOException {
         IndexReader reader = index.getIndexReader();
         try {
+            if (!rewritten) {
+                query = query.rewrite(reader);
+                rewritten = true;
+            }
             Term idTerm = new Term(FieldNames.UUID, id.getUUID().toString());
             TermDocs tDocs = reader.termDocs(idTerm);
             int docNumber;

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java?view=diff&rev=544263&r1=544262&r2=544263
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
Mon Jun  4 14:00:05 2007
@@ -101,6 +101,18 @@
         return "DerefQuery";
     }
 
+    /**
+     * {@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);
+        }
+    }
+
     //-------------------< DerefWeight >------------------------------------
 
     /**

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java?view=diff&rev=544263&r1=544262&r2=544263
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
Mon Jun  4 14:00:05 2007
@@ -117,6 +117,19 @@
         subQuery.extractTerms(terms);
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public Query rewrite(IndexReader reader) throws IOException {
+        Query cQuery = contextQuery.rewrite(reader);
+        Query sQuery = subQuery.rewrite(reader);
+        if (cQuery == contextQuery && sQuery == subQuery) {
+            return this;
+        } else {
+            return new DescendantSelfAxisQuery(cQuery, sQuery, includeSelf);
+        }
+    }
+
     //------------------------< DescendantSelfAxisWeight >--------------------------
 
     /**

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java?view=diff&rev=544263&r1=544262&r2=544263
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
Mon Jun  4 14:00:05 2007
@@ -67,6 +67,18 @@
     }
 
     /**
+     * {@inheritDoc}
+     */
+    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 {

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java?view=diff&rev=544263&r1=544262&r2=544263
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
Mon Jun  4 14:00:05 2007
@@ -90,6 +90,18 @@
     }
 
     /**
+     * {@inheritDoc}
+     */
+    public Query rewrite(IndexReader reader) throws IOException {
+        Query cQuery = contextQuery.rewrite(reader);
+        if (cQuery == contextQuery) {
+            return this;
+        } else {
+            return new ParentAxisQuery(cQuery, nameTest);
+        }
+    }
+
+    /**
      * Always returns 'ParentAxisQuery'.
      *
      * @param field the name of a field.



Mime
View raw message