You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2014/11/12 15:11:53 UTC
svn commit: r1638796 - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/CHANGES.txt lucene/core/
lucene/core/src/java/org/apache/lucene/analysis/CachingTokenFilter.java
Author: dsmiley
Date: Wed Nov 12 14:11:52 2014
New Revision: 1638796
URL: http://svn.apache.org/r1638796
Log:
LUCENE-6033: CachingTokenFilter now uses ArrayList not LinkedList, and has new isCached() method
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/lucene/ (props changed)
lucene/dev/branches/branch_5x/lucene/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_5x/lucene/core/ (props changed)
lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/analysis/CachingTokenFilter.java
Modified: lucene/dev/branches/branch_5x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/CHANGES.txt?rev=1638796&r1=1638795&r2=1638796&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/lucene/CHANGES.txt Wed Nov 12 14:11:52 2014
@@ -296,6 +296,9 @@ Optimizations
* LUCENE-6040: Speed up EliasFanoDocIdSet through broadword bit selection.
(Paul Elschot)
+* LUCENE-6033: CachingTokenFilter now uses ArrayList not LinkedList, and has new
+ isCached() method. (David Smiley)
+
Build
* LUCENE-5909: Smoke tester now has better command line parsing and
Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/analysis/CachingTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/analysis/CachingTokenFilter.java?rev=1638796&r1=1638795&r2=1638796&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/analysis/CachingTokenFilter.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/analysis/CachingTokenFilter.java Wed Nov 12 14:11:52 2014
@@ -18,8 +18,8 @@ package org.apache.lucene.analysis;
*/
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import org.apache.lucene.util.AttributeSource;
@@ -27,7 +27,8 @@ import org.apache.lucene.util.AttributeS
/**
* This class can be used if the token attributes of a TokenStream
* are intended to be consumed more than once. It caches
- * all token attribute states locally in a List.
+ * all token attribute states locally in a List when the first call to
+ * {@link #incrementToken()} is called.
*
* <P>CachingTokenFilter implements the optional method
* {@link TokenStream#reset()}, which repositions the
@@ -51,7 +52,7 @@ public final class CachingTokenFilter ex
public final boolean incrementToken() throws IOException {
if (cache == null) {
// fill cache lazily
- cache = new LinkedList<>();
+ cache = new ArrayList<>(64);
fillCache();
iterator = cache.iterator();
}
@@ -81,13 +82,13 @@ public final class CachingTokenFilter ex
*/
@Override
public void reset() {
- if(cache != null) {
+ if (cache != null) {
iterator = cache.iterator();
}
}
private void fillCache() throws IOException {
- while(input.incrementToken()) {
+ while (input.incrementToken()) {
cache.add(captureState());
}
// capture final state
@@ -95,4 +96,9 @@ public final class CachingTokenFilter ex
finalState = captureState();
}
+ /** If the underlying token stream was consumed and cached. */
+ public boolean isCached() {
+ return cache != null;
+ }
+
}