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.GlobalReuseStrategy, Analyzer.PerFieldReuseStrategy, 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.
|
createComponents, getOffsetGap, getPositionIncrementGap, getWrappedAnalyzer, initReader
close, getReuseStrategy, getVersion, 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 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 wrapCopyright © 2000-2014 Apache Software Foundation. All Rights Reserved.