mirror of https://github.com/apache/lucene.git
LUCENE-5611: move attribute juggling to a fieldinvertstate setter
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5611@1590747 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f0414ff3af
commit
e7b59c5a21
|
@ -544,15 +544,7 @@ final class DefaultIndexingChain extends DocConsumer {
|
||||||
try (TokenStream stream = field.tokenStream(docState.analyzer)) {
|
try (TokenStream stream = field.tokenStream(docState.analyzer)) {
|
||||||
// reset the TokenStream to the first token
|
// reset the TokenStream to the first token
|
||||||
stream.reset();
|
stream.reset();
|
||||||
|
invertState.setAttributeSource(stream);
|
||||||
if (invertState.attributeSource != stream) {
|
|
||||||
// EmptyTokenStream gets angry otherwise:
|
|
||||||
invertState.termAttribute = stream.getAttribute(TermToBytesRefAttribute.class);
|
|
||||||
invertState.posIncrAttribute = stream.addAttribute(PositionIncrementAttribute.class);
|
|
||||||
invertState.offsetAttribute = stream.addAttribute(OffsetAttribute.class);
|
|
||||||
invertState.payloadAttribute = stream.getAttribute(PayloadAttribute.class);
|
|
||||||
invertState.attributeSource = stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
termsHashPerField.start(field, first);
|
termsHashPerField.start(field, first);
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,20 @@ public final class FieldInvertState {
|
||||||
boost = 1.0f;
|
boost = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: better name?
|
||||||
|
/**
|
||||||
|
* Sets attributeSource to a new instance.
|
||||||
|
*/
|
||||||
|
void setAttributeSource(AttributeSource attributeSource) {
|
||||||
|
if (this.attributeSource != attributeSource) {
|
||||||
|
this.attributeSource = attributeSource;
|
||||||
|
termAttribute = attributeSource.getAttribute(TermToBytesRefAttribute.class);
|
||||||
|
posIncrAttribute = attributeSource.addAttribute(PositionIncrementAttribute.class);
|
||||||
|
offsetAttribute = attributeSource.addAttribute(OffsetAttribute.class);
|
||||||
|
payloadAttribute = attributeSource.getAttribute(PayloadAttribute.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the last processed term position.
|
* Get the last processed term position.
|
||||||
* @return the position
|
* @return the position
|
||||||
|
|
Loading…
Reference in New Issue