lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/search IndexSearcher.java
Date Fri, 01 Oct 2004 16:10:45 GMT
cutting     2004/10/01 09:10:45

  Modified:    .        Tag: lucene_1_4_2_dev CHANGES.txt
               src/java/org/apache/lucene/search Tag: lucene_1_4_2_dev
                        IndexSearcher.java
  Log:
  In 1.4.2 branch, optimize IndexSearcher to not allocate a ScoreDoc for every non-zero hit.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.96.2.4  +5 -1      jakarta-lucene/CHANGES.txt
  
  Index: CHANGES.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/CHANGES.txt,v
  retrieving revision 1.96.2.3
  retrieving revision 1.96.2.4
  diff -u -r1.96.2.3 -r1.96.2.4
  --- CHANGES.txt	1 Oct 2004 10:01:48 -0000	1.96.2.3
  +++ CHANGES.txt	1 Oct 2004 16:10:45 -0000	1.96.2.4
  @@ -28,6 +28,10 @@
       to specify a minimum similarity for FuzzyQuery has been added.
       (Christoph Goller)
   
  + 6. IndexSearcher optimization: a new ScoreDoc is no longer allocated
  +    for every non-zero-scoring hit.  This makes 'OR' queries that
  +    contain common terms substantially faster.  (cutting)
  +
   
   1.4.1
   
  
  
  
  No                   revision
  No                   revision
  1.19.2.1  +5 -1      jakarta-lucene/src/java/org/apache/lucene/search/IndexSearcher.java
  
  Index: IndexSearcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/IndexSearcher.java,v
  retrieving revision 1.19
  retrieving revision 1.19.2.1
  diff -u -r1.19 -r1.19.2.1
  --- IndexSearcher.java	19 May 2004 23:05:27 -0000	1.19
  +++ IndexSearcher.java	1 Oct 2004 16:10:45 -0000	1.19.2.1
  @@ -90,11 +90,15 @@
       final HitQueue hq = new HitQueue(nDocs);
       final int[] totalHits = new int[1];
       scorer.score(new HitCollector() {
  +        private float minScore = 0.0f;
   	public final void collect(int doc, float score) {
   	  if (score > 0.0f &&			  // ignore zeroed buckets
   	      (bits==null || bits.get(doc))) {	  // skip docs not in bits
   	    totalHits[0]++;
  -            hq.insert(new ScoreDoc(doc, score));
  +            if (hq.size() < nDocs || score >= minScore) {
  +              hq.insert(new ScoreDoc(doc, score));
  +              minScore = ((ScoreDoc)hq.top()).score; // maintain minScore
  +            }
   	  }
   	}
         });
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message