jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r201580 - in /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene: QueryImpl.java SearchIndex.java
Date Fri, 24 Jun 2005 07:40:54 GMT
Author: mreutegg
Date: Fri Jun 24 00:40:52 2005
New Revision: 201580

URL: http://svn.apache.org/viewcvs?rev=201580&view=rev
Log:
JCR-145: Document order of result nodes should be configurable

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java?rev=201580&r1=201579&r2=201580&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
Fri Jun 24 00:40:52 2005
@@ -88,6 +88,12 @@
     private final PropertyTypeRegistry propReg;
 
     /**
+     * If <code>true</code> the default ordering of the result nodes is in
+     * document order.
+     */
+    private boolean documentOrder = true;
+
+    /**
      * Creates a new query instance from a query string.
      *
      * @param session   the session of the user executing this query.
@@ -208,7 +214,34 @@
                 (Float[]) scores.toArray(new Float[scores.size()]),
                 (QName[]) selectProps.toArray(new QName[selectProps.size()]),
                 session.getNamespaceResolver(),
-                orderNode == null);
+                orderNode == null && documentOrder);
+    }
+
+    /**
+     * If set <code>true</code> the result nodes will be in document order
+     * per default (if no order by clause is specified). If set to
+     * <code>false</code> the result nodes are returned in whatever sequence
+     * the index has stored the nodes. That sequence is stable over multiple
+     * invocations of the same query, but will change when nodes get added or
+     * removed from the index.
+     * <p/>
+     * The default value for this property is <code>true</code>.
+     * @return the current value of this property.
+     */
+    public boolean getRespectDocumentOrder() {
+        return documentOrder;
+    }
+
+    /**
+     * Sets a new value for this property.
+     *
+     * @param documentOrder if <code>true</code> the result nodes are in
+     * document order per default.
+     *
+     * @see #getRespectDocumentOrder()
+     */
+    public void setRespectDocumentOrder(boolean documentOrder) {
+        this.documentOrder = documentOrder;
     }
 
     //-----------------------------< internal >---------------------------------

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=201580&r1=201579&r2=201580&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Fri Jun 24 00:40:52 2005
@@ -67,6 +67,11 @@
     private final FIFOReadWriteLock readWriteLock = new FIFOReadWriteLock();
 
     /**
+     * Flag indicating whether document order is enable as the default ordering.
+     */
+    private boolean documentOrder = true;
+
+    /**
      * Default constructor.
      */
     public SearchIndex() {
@@ -150,8 +155,10 @@
                                              String statement,
                                              String language)
             throws InvalidQueryException {
-        return new QueryImpl(session, itemMgr, this,
+        QueryImpl query = new QueryImpl(session, itemMgr, this,
                 getContext().getPropertyTypeRegistry(), statement, language);
+        query.setRespectDocumentOrder(documentOrder);
+        return query;
     }
 
     /**
@@ -275,5 +282,9 @@
 
     public void setBufferSize(int size) {
         index.setBufferSize(size);
+    }
+
+    public void setRespectDocumentOrder(boolean docOrder) {
+        documentOrder = docOrder;
     }
 }



Mime
View raw message