You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by bu...@apache.org on 2007/06/23 17:56:35 UTC
svn commit: r550060 - in /lucene/java/trunk: CHANGES.txt
src/java/org/apache/lucene/analysis/CachingTokenFilter.java
Author: buschmi
Date: Sat Jun 23 08:56:34 2007
New Revision: 550060
URL: http://svn.apache.org/viewvc?view=rev&rev=550060
Log:
LUCENE-937: CachingTokenFilter now uses an iterator to access the Tokens that are cached in the LinkedList.
Modified:
lucene/java/trunk/CHANGES.txt
lucene/java/trunk/src/java/org/apache/lucene/analysis/CachingTokenFilter.java
Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?view=diff&rev=550060&r1=550059&r2=550060
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Sat Jun 23 08:56:34 2007
@@ -14,6 +14,11 @@
Optimizations
+ 1. LUCENE-937: CachingTokenFilter now uses an iterator to access the
+ Tokens that are cached in the LinkedList. This increases performance
+ significantly, especially when the number of Tokens is large.
+ (Mark Miller via Michael Busch)
+
Documentation
Build
Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/CachingTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/CachingTokenFilter.java?view=diff&rev=550060&r1=550059&r2=550060
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/CachingTokenFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/CachingTokenFilter.java Sat Jun 23 08:56:34 2007
@@ -18,6 +18,7 @@
*/
import java.io.IOException;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -33,7 +34,7 @@
*/
public class CachingTokenFilter extends TokenFilter {
private List cache;
- private int index;
+ private Iterator iterator;
public CachingTokenFilter(TokenStream input) {
super(input);
@@ -44,18 +45,21 @@
// fill cache lazily
cache = new LinkedList();
fillCache();
+ iterator = cache.iterator();
}
- if (index == cache.size()) {
+ if (!iterator.hasNext()) {
// the cache is exhausted, return null
return null;
}
- return (Token) cache.get(index++);
+ return (Token) iterator.next();
}
public void reset() throws IOException {
- index = 0;
+ if(cache != null) {
+ iterator = cache.iterator();
+ }
}
private void fillCache() throws IOException {