public abstract class DelegatingAnalyzerWrapper extends AnalyzerWrapper
This solves the problem of per field analyzer wrapper, where it also maintains a thread local per field token stream components, while it can safely delegate those and not also hold these data structures, which can become expensive memory wise.
Please note: This analyzer uses a private Analyzer.ReuseStrategy
,
which is returned by Analyzer.getReuseStrategy()
. This strategy is used when
delegating. If you wrap this analyzer again and reuse this strategy, no
delegation is done and the given fallback is used.
Analyzer.ReuseStrategy, Analyzer.TokenStreamComponents
GLOBAL_REUSE_STRATEGY, PER_FIELD_REUSE_STRATEGY
Modifier | Constructor and Description |
---|---|
protected |
DelegatingAnalyzerWrapper(Analyzer.ReuseStrategy fallbackStrategy)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Analyzer.TokenStreamComponents |
wrapComponents(String fieldName,
Analyzer.TokenStreamComponents components)
Wraps / alters the given TokenStreamComponents, taken from the wrapped
Analyzer, to form new components.
|
protected Reader |
wrapReader(String fieldName,
Reader reader)
Wraps / alters the given Reader.
|
protected Reader |
wrapReaderForNormalization(String fieldName,
Reader reader)
Wraps / alters the given Reader.
|
protected TokenStream |
wrapTokenStreamForNormalization(String fieldName,
TokenStream in)
Wraps / alters the given TokenStream for normalization purposes, taken
from the wrapped Analyzer, to form new components.
|
attributeFactory, createComponents, getOffsetGap, getPositionIncrementGap, getWrappedAnalyzer, initReader, initReaderForNormalization, normalize
close, getReuseStrategy, getVersion, normalize, setVersion, tokenStream, tokenStream
protected DelegatingAnalyzerWrapper(Analyzer.ReuseStrategy fallbackStrategy)
fallbackStrategy
- is the strategy to use if delegation is not possible
This is to support the common pattern:
new OtherWrapper(thisWrapper.getReuseStrategy())
protected final Analyzer.TokenStreamComponents wrapComponents(String fieldName, Analyzer.TokenStreamComponents components)
AnalyzerWrapper
wrapComponents
in class AnalyzerWrapper
fieldName
- Name of the field which is to be analyzedcomponents
- TokenStreamComponents taken from the wrapped Analyzerprotected final TokenStream wrapTokenStreamForNormalization(String fieldName, TokenStream in)
AnalyzerWrapper
wrapTokenStreamForNormalization
in class AnalyzerWrapper
fieldName
- Name of the field which is to be analyzedin
- TokenStream taken from the wrapped Analyzerprotected final Reader wrapReader(String fieldName, Reader reader)
AnalyzerWrapper
AnalyzerWrapper.initReader(String, Reader)
. By default, the given reader
is returned.wrapReader
in class AnalyzerWrapper
fieldName
- name of the field which is to be analyzedreader
- the reader to wrapprotected final Reader wrapReaderForNormalization(String fieldName, Reader reader)
AnalyzerWrapper
AnalyzerWrapper.initReaderForNormalization(String, Reader)
. By default,
the given reader is returned.wrapReaderForNormalization
in class AnalyzerWrapper
fieldName
- name of the field which is to be analyzedreader
- the reader to wrapCopyright © 2000-2020 Apache Software Foundation. All Rights Reserved.