lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r776252 - in /lucene/java/trunk/contrib: CHANGES.txt collation/src/java/org/apache/lucene/collation/ICUCollationKeyFilter.java
Date Tue, 19 May 2009 09:50:25 GMT
Author: mikemccand
Date: Tue May 19 09:50:24 2009
New Revision: 776252

URL: http://svn.apache.org/viewvc?rev=776252&view=rev
Log:
LUCENE-1643: use reusable RawCollationKey for better performance

Modified:
    lucene/java/trunk/contrib/CHANGES.txt
    lucene/java/trunk/contrib/collation/src/java/org/apache/lucene/collation/ICUCollationKeyFilter.java

Modified: lucene/java/trunk/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/CHANGES.txt?rev=776252&r1=776251&r2=776252&view=diff
==============================================================================
--- lucene/java/trunk/contrib/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/CHANGES.txt Tue May 19 09:50:24 2009
@@ -61,6 +61,11 @@
     Model to tokenize Chinese words in a more intelligent way.
     (Xiaoping Gao via Mike McCandless)
   
+Optimizations
+
+  1. LUCENE-1643: Re-use the collation key (RawCollationKey) for
+     better performance, in ICUCollationKeyFilter.  (Robert Muir via
+     Mike McCandless)
 
 Documentation
 

Modified: lucene/java/trunk/contrib/collation/src/java/org/apache/lucene/collation/ICUCollationKeyFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/collation/src/java/org/apache/lucene/collation/ICUCollationKeyFilter.java?rev=776252&r1=776251&r2=776252&view=diff
==============================================================================
--- lucene/java/trunk/contrib/collation/src/java/org/apache/lucene/collation/ICUCollationKeyFilter.java
(original)
+++ lucene/java/trunk/contrib/collation/src/java/org/apache/lucene/collation/ICUCollationKeyFilter.java
Tue May 19 09:50:24 2009
@@ -19,6 +19,8 @@
 
 
 import com.ibm.icu.text.Collator;
+import com.ibm.icu.text.RawCollationKey;
+
 import org.apache.lucene.analysis.TokenFilter;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.Token;
@@ -61,6 +63,7 @@
  */
 public class ICUCollationKeyFilter extends TokenFilter {
   private Collator collator = null;
+  private RawCollationKey reusableKey = new RawCollationKey();
 
   /**
    * 
@@ -78,8 +81,8 @@
     if (nextToken != null) {
       char[] termBuffer = nextToken.termBuffer();
       String termText = new String(termBuffer, 0, nextToken.termLength());
-      byte[] collationKey = collator.getCollationKey(termText).toByteArray();
-      ByteBuffer collationKeyBuf = ByteBuffer.wrap(collationKey);
+      collator.getRawCollationKey(termText, reusableKey);
+      ByteBuffer collationKeyBuf = ByteBuffer.wrap(reusableKey.bytes, 0, reusableKey.size);
       int encodedLength
         = IndexableBinaryStringTools.getEncodedLength(collationKeyBuf);
       if (encodedLength > termBuffer.length) {



Mime
View raw message