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

Uwe Schindler commented on LUCENE-7027:
---------------------------------------

I have no problem committing the given patch. It allows to get an empty token 
attribute after the tokenstream is exhausted. It is the only correct way to fix 
it.

I just mentioned this here to think about it (if we really need this). Bt I 
agree with you: 

bq. Hmm I think correctness trumps performance?

:-)

bq. Or maybe you are saying one can never call captureState after calling end? 
But then how does one hang onto the "final" offset and posInc? And if so, I 
guess we should fix MockTokenizer to enforce this? Yet, CachingTokenFilter is 
doing exactly this, so maybe the bug is there?

That must be allowed, otherwise the whole thing like caching won't work. In 
addition, it is not only captueState that's broken, every thing done with 
TermAttribute leads to the IllegalArgEx, So it is not the tokenstream thats 
buggy its just the attribute implementation (and this is what the bug is 
fixing).

bq. Well, Elasticsearch's simple query parser is just trying to create the 
right "equals" query from the incoming text, for a numeric field.

OK, I was not aware of that. The problem is that the query parser uses the 
CachingTokenFilter, I assume. right?

> NumericTokenStream doesn't implement end() correctly
> ----------------------------------------------------
>
>                 Key: LUCENE-7027
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7027
>             Project: Lucene - Core
>          Issue Type: Bug
>    Affects Versions: 5.5, master, 6.0
>            Reporter: Michael McCandless
>            Assignee: Uwe Schindler
>         Attachments: LUCENE-7027-master.patch
>
>
> This small test:
> {noformat}
>   public void testCloneFullPrecisionToken() throws Exception {
>     FieldType fieldType = new FieldType(IntField.TYPE_NOT_STORED);
>     fieldType.setNumericPrecisionStep(Integer.MAX_VALUE);
>     Field field = new IntField("field", 17, fieldType);
>     TokenStream tokenStream = new CachingTokenFilter(field.tokenStream(null, 
> null));
>     assertTrue(tokenStream.incrementToken());
>   }
> {noformat}
> hits this unexpected exception:
> {noformat}
> There was 1 failure:
> 1) 
> testCloneFullPrecisionToken(org.apache.lucene.analysis.TestNumericTokenStream)
> java.lang.IllegalArgumentException: Illegal shift value, must be 0..31; got 
> shift=2147483647
>       at 
> __randomizedtesting.SeedInfo.seed([2E1E93EF810CB5F7:EF1304A849574BC7]:0)
>       at 
> org.apache.lucene.util.NumericUtils.intToPrefixCodedBytes(NumericUtils.java:175)
>       at 
> org.apache.lucene.util.NumericUtils.intToPrefixCoded(NumericUtils.java:133)
>       at 
> org.apache.lucene.analysis.NumericTokenStream$NumericTermAttributeImpl.getBytesRef(NumericTokenStream.java:165)
>       at 
> org.apache.lucene.analysis.NumericTokenStream$NumericTermAttributeImpl.clone(NumericTokenStream.java:217)
>       at 
> org.apache.lucene.analysis.NumericTokenStream$NumericTermAttributeImpl.clone(NumericTokenStream.java:148)
>       at 
> org.apache.lucene.util.AttributeSource$State.clone(AttributeSource.java:55)
>       at 
> org.apache.lucene.util.AttributeSource.captureState(AttributeSource.java:288)
>       at 
> org.apache.lucene.analysis.CachingTokenFilter.fillCache(CachingTokenFilter.java:96)
>       at 
> org.apache.lucene.analysis.CachingTokenFilter.incrementToken(CachingTokenFilter.java:70)
>       at 
> org.apache.lucene.analysis.TestNumericTokenStream.testCloneFullPrecisionToken(TestNumericTokenStream.java:138)
> {noformat}
> because {{CachingTokenFilter}} expects that it can {{captureState}} after 
> calling {{end}} but {{NumericTokenStream}} gets angry about this.



--
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