You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by cu...@apache.org on 2004/09/22 20:18:27 UTC

cvs commit: jakarta-lucene/src/java/org/apache/lucene/search Similarity.java TermScorer.java

cutting     2004/09/22 11:18:27

  Modified:    src/java/org/apache/lucene/search Similarity.java
                        TermScorer.java
  Log:
  Inline decodeNorm() in TermQuery to make searches faster in Java implementations, like GCJ, where simple methods are not inlined.
  
  Revision  Changes    Path
  1.14      +7 -0      jakarta-lucene/src/java/org/apache/lucene/search/Similarity.java
  
  Index: Similarity.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/Similarity.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Similarity.java	15 Aug 2004 11:37:36 -0000	1.13
  +++ Similarity.java	22 Sep 2004 18:18:27 -0000	1.14
  @@ -102,6 +102,13 @@
       return NORM_TABLE[b & 0xFF];
     }
   
  +  /** Returns a table for decoding normalization bytes.
  +   * @see #encodeNorm(float)
  +   */
  +  public static float[] getNormDecoder() {
  +    return NORM_TABLE;
  +  }
  +
     /** Computes the normalization value for a field given the total number of
      * terms contained in a field.  These values, together with field boosts, are
      * stored in an index and multipled into scores for hits on each field by the
  
  
  
  1.14      +2 -1      jakarta-lucene/src/java/org/apache/lucene/search/TermScorer.java
  
  Index: TermScorer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/TermScorer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TermScorer.java	22 Sep 2004 17:56:00 -0000	1.13
  +++ TermScorer.java	22 Sep 2004 18:18:27 -0000	1.14
  @@ -62,6 +62,7 @@
   
     protected boolean score(HitCollector c, int end) throws IOException {
       Similarity similarity = getSimilarity();      // cache sim in local
  +    float[] normDecoder = similarity.getNormDecoder();
       while (doc < end) {                           // for docs in window
         int f = freqs[pointer];
         float score =                               // compute tf(f)*weight
  @@ -69,7 +70,7 @@
            ? scoreCache[f]                          // cache hit
            : similarity.tf(f)*weightValue;          // cache miss
   
  -      score *= Similarity.decodeNorm(norms[doc]); // normalize for field
  +      score *= normDecoder[norms[doc] & 0xFF];    // normalize for field
   
         c.collect(doc, score);                      // collect score
   
  
  
  

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