You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2006/01/23 11:44:18 UTC

svn commit: r371520 - /incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java

Author: mreutegg
Date: Mon Jan 23 02:44:15 2006
New Revision: 371520

URL: http://svn.apache.org/viewcvs?rev=371520&view=rev
Log: (empty)

Modified:
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java?rev=371520&r1=371519&r2=371520&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java Mon Jan 23 02:44:15 2006
@@ -27,6 +27,8 @@
 
 import java.io.IOException;
 import java.util.BitSet;
+import java.util.Map;
+import java.util.HashMap;
 
 /**
  * Implements a lucene <code>Query</code> which filters a sub query by checking
@@ -36,6 +38,11 @@
 class DescendantSelfAxisQuery extends Query {
 
     /**
+     * Default score is 1.0f.
+     */
+    private static final Float DEFAULT_SCORE = new Float(1.0f);
+
+    /**
      * The context query
      */
     private final Query contextQuery;
@@ -205,6 +212,15 @@
         private final BitSet subHits;
 
         /**
+         * Map that contains the scores for the sub hits. 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 sub query<br>
+         * value=[Float] score for that document
+         */
+        private final Map scores = new HashMap();
+
+        /**
          * The next document id to return
          */
         private int nextDoc = -1;
@@ -278,7 +294,11 @@
          * {@inheritDoc}
          */
         public float score() throws IOException {
-            return 1.0f;
+            Float score = (Float) scores.get(new Integer(nextDoc));
+            if (score == null) {
+                score = DEFAULT_SCORE;
+            }
+            return score.floatValue();
         }
 
         /**
@@ -304,6 +324,9 @@
                     subScorer.score(new HitCollector() {
                         public void collect(int doc, float score) {
                             subHits.set(doc);
+                            if (score != DEFAULT_SCORE.floatValue()) {
+                                scores.put(new Integer(doc), new Float(score));
+                            }
                         }
                     });
                 }