jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r831851 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java
Date Mon, 02 Nov 2009 10:33:32 GMT
Author: mreutegg
Date: Mon Nov  2 10:33:32 2009
New Revision: 831851

URL: http://svn.apache.org/viewvc?rev=831851&view=rev
Log:
JCR-2375: Create ScoreNode on demand in SortedLuceneQueryHits

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java?rev=831851&r1=831850&r2=831851&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java
Mon Nov  2 10:33:32 2009
@@ -77,9 +77,9 @@
     private int hitIndex = -1;
 
     /**
-     * The score nodes.
+     * The score docs.
      */
-    private final List<ScoreNode> scoreNodes = new ArrayList<ScoreNode>();
+    private final List<ScoreDoc> scoreDocs = new ArrayList<ScoreDoc>();
 
     /**
      * The total number of hits.
@@ -130,12 +130,16 @@
         if (++hitIndex >= size) {
             // no more score nodes
             return null;
-        } else if (hitIndex >= scoreNodes.size()) {
+        } else if (hitIndex >= scoreDocs.size()) {
             // refill at least numHits or twice hitIndex
             this.numHits = Math.max(this.numHits, hitIndex * 2);
             getHits();
         }
-        return scoreNodes.get(hitIndex);
+        ScoreDoc doc = scoreDocs.get(hitIndex);
+        String uuid = reader.document(doc.doc,
+                FieldSelectors.UUID).get(FieldNames.UUID);
+        NodeId id = new NodeId(uuid);
+        return new ScoreNode(id, doc.score, doc.doc);
     }
 
     /**
@@ -155,13 +159,10 @@
         searcher.search(query, collector);
         this.size = collector.getTotalHits();
         ScoreDoc[] docs = collector.topDocs().scoreDocs;
-        for (int i = scoreNodes.size(); i < docs.length; i++) {
-            String uuid = reader.document(docs[i].doc,
-                    FieldSelectors.UUID).get(FieldNames.UUID);
-            NodeId id = new NodeId(uuid);
-            scoreNodes.add(new ScoreNode(id, docs[i].score, docs[i].doc));
+        for (int i = scoreDocs.size(); i < docs.length; i++) {
+            scoreDocs.add(docs[i]);
         }
-        log.debug("getHits() {}/{}", scoreNodes.size(), numHits);
+        log.debug("getHits() {}/{}", scoreDocs.size(), numHits);
         // double hits for next round
         numHits *= 2;
     }



Mime
View raw message