Tokenizer implementations can't be reset [LUCENE-8651]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
The fine print here is that they can't be reset without calling setReader() every time before reset() is called. The reason for this is that Tokenizer violates the contract put forth by TokenStream.reset() which is the following:
"Resets this stream to a clean state. Stateful implementations must implement this method so that they can be reused, just as if they had been created fresh."
Tokenizer implementation's reset function can't reset in that manner because their Tokenizer.close() removes the reference to the underlying Reader because of #3462. The catch-22 here is that we don't want to unnecessarily keep around a Reader (memory leak) but we would like to be able to reset() if necessary.
The patches include an integration test that attempts to use a ConcatenatingTokenStream to join an input TokenStream with a KeywordTokenizer TokenStream. This test fails with an IllegalStateException thrown by Tokenizer.ILLEGAL_STATE_READER.
---
Migrated from [LUCENE-8651](https://issues.apache.org/jira/browse/LUCENE-8651) by Dan Meehl, updated Jan 25 2019
Attachments: [LUCENE-8650-2.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-8651/LUCENE-8650-2.patch), [LUCENE-8651.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-8651/LUCENE-8651.patch) (versions: 2)
Linked issues:
- #3462
- #9696
Contributor guide
Research direction
Start with Tokenizer.reset()/close() and the TokenStream.reset() contract, then reproduce the integration test described for ConcatenatingTokenStream with KeywordTokenizer. Compare the attached patches and verify the test no longer throws Tokenizer.ILLEGAL_STATE_READER while preserving the reader-lifecycle behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100