jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r169480 - in /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query: lucene/ChildAxisQuery.java lucene/DerefQuery.java lucene/DescendantSelfAxisQuery.java lucene/LuceneQueryBuilder.java xpath/XPathQueryBuilder.java
Date Tue, 10 May 2005 14:28:59 GMT
Author: mreutegg
Date: Tue May 10 07:28:59 2005
New Revision: 169480

URL: http://svn.apache.org/viewcvs?rev=169480&view=rev
Log:
- TermDocs in queries are not closed when not used anymore.
- Minor fix in LuceneQueryBuilder: coercing string into name did not work.
- Fix issue with order by jcr:score()

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java?rev=169480&r1=169479&r2=169480&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
Tue May 10 07:28:59 2005
@@ -166,23 +166,20 @@
          * {@inheritDoc}
          */
         public float getValue() {
-            // @todo implement properly
-            return 0;
+            return 1.0f;
         }
 
         /**
          * {@inheritDoc}
          */
         public float sumOfSquaredWeights() throws IOException {
-            // @todo implement properly
-            return 0;
+            return 1.0f;
         }
 
         /**
          * {@inheritDoc}
          */
         public void normalize(float norm) {
-            // @todo implement properly
         }
 
         /**
@@ -293,7 +290,6 @@
                 uuids = new ArrayList();
                 contextScorer.score(new HitCollector() {
                     public void collect(int doc, float score) {
-                        // @todo maintain cache of doc id hierarchy
                         hits.set(doc);
                     }
                 });
@@ -319,8 +315,12 @@
                 hits.clear();
                 for (Iterator it = uuids.iterator(); it.hasNext();) {
                     TermDocs children = reader.termDocs(new Term(FieldNames.PARENT, (String)
it.next()));
-                    while (children.next()) {
-                        hits.set(children.doc());
+                    try {
+                        while (children.next()) {
+                            hits.set(children.doc());
+                        }
+                    } finally {
+                        children.close();
                     }
                 }
                 // filter out the child nodes that do not match the name test

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java?rev=169480&r1=169479&r2=169480&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
Tue May 10 07:28:59 2005
@@ -290,8 +290,12 @@
                 hits.clear();
                 for (Iterator it = uuids.iterator(); it.hasNext();) {
                     TermDocs node = reader.termDocs(new Term(FieldNames.UUID, (String) it.next()));
-                    while (node.next()) {
-                        hits.set(node.doc());
+                    try {
+                        while (node.next()) {
+                            hits.set(node.doc());
+                        }
+                    } finally {
+                        node.close();
                     }
                 }
                 // filter out the target nodes that do not match the name test

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java?rev=169480&r1=169479&r2=169480&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
Tue May 10 07:28:59 2005
@@ -252,13 +252,17 @@
                 while (parentUUID != null && !contextUUIDs.contains(parentUUID))
{
                     // traverse
                     TermDocs ancestor = reader.termDocs(new Term(FieldNames.UUID, parentUUID));
-                    if (ancestor.next()) {
-                        parentUUID = reader.document(ancestor.doc()).get(FieldNames.PARENT);
-                        if (parentUUID.length() == 0) {
+                    try {
+                        if (ancestor.next()) {
+                            parentUUID = reader.document(ancestor.doc()).get(FieldNames.PARENT);
+                            if (parentUUID.length() == 0) {
+                                parentUUID = null;
+                            }
+                        } else {
                             parentUUID = null;
                         }
-                    } else {
-                        parentUUID = null;
+                    } finally {
+                        ancestor.close();
                     }
                 }
                 if (parentUUID != null) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java?rev=169480&r1=169479&r2=169480&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
Tue May 10 07:28:59 2005
@@ -784,7 +784,7 @@
             } else if (literal.indexOf(':') > -1) {
                 // might be a name
                 try {
-                    values.add(QName.fromJCRName(literal, session.getNamespaceResolver()));
+                    values.add(nsMappings.translatePropertyName(literal, session.getNamespaceResolver()));
                     log.debug("Coerced " + literal + " into NAME.");
                 } catch (Exception e) {
                     // not a name

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java?rev=169480&r1=169479&r2=169480&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
Tue May 10 07:28:59 2005
@@ -843,7 +843,13 @@
         SimpleNode child = (SimpleNode) node.jjtGetChild(0);
         OrderQueryNode.OrderSpec spec = null;
         try {
-            QName name = ISO9075.decode(QName.fromJCRName(child.getValue(), resolver));
+            String propName = child.getValue();
+            if (child.getId() == JJTQNAMELPAR) {
+                // function name
+                // cut off left parenthesis at end
+                propName.substring(0, propName.length() - 1);
+            }
+            QName name = ISO9075.decode(QName.fromJCRName(propName, resolver));
             spec = new OrderQueryNode.OrderSpec(name, true);
             queryNode.addOrderSpec(spec);
         } catch (IllegalNameException e) {



Mime
View raw message