[ 
https://issues.apache.org/jira/browse/LUCENE-6033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14251078#comment-14251078
 ] 

David Smiley commented on LUCENE-6033:
--------------------------------------

bq. I mostly agree with this. Except i think this filter should propogate 
reset() from its own reset(), only once (then once cached, it obviously doesnt 
propogate any such call).

+1 totally fine with me.  That was actually my first cut... but then I wondered 
if some un-knowning (don't even know it's a CachingTokenFilter) downstream code 
doesn't call reset due to a bug (on their part) or who knows why.  So delaying 
until the last point possible seemed safer.  

bq. But then why propose an option? I would rather fix the behavior of the this 
thing and not have "two ways to do it". Consumers of the TS api already have a 
hard enough time.

Because of backwards-compatibility.  But sure... lets fix this now that I know 
you're game :-)

I just created LUCENE-6121.  I first added my patch here for a bunch of reasons 
but if we're going to disturb the status quo then it definitely deserves its 
own issue.

> Add CachingTokenFilter.isCached and switch LinkedList to ArrayList
> ------------------------------------------------------------------
>
>                 Key: LUCENE-6033
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6033
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: David Smiley
>            Assignee: David Smiley
>             Fix For: 5.0, Trunk
>
>         Attachments: LUCENE-6033.patch, 
> LUCENE-6033_boolean_resetInput_option.patch
>
>
> CachingTokenFilter could use a simple boolean isCached() method implemented 
> as-such:
> {code:java}
>   /** If the underlying token stream was consumed and cached */
>   public boolean isCached() {
>     return cache != null;
>   }
> {code}
> It's useful for the highlighting code to remove its wrapping of 
> CachingTokenFilter if after handing-off to parts of its framework it turns 
> out that it wasn't used.
> Furthermore, use an ArrayList, not a LinkedList.  ArrayList is leaner when 
> the token count is high, and this class doesn't manipulate the list in a way 
> that might favor LL.
> A separate patch will come that actually uses this method.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to