/** * Sets attributeSource to a new instance. */ void setAttributeSource(AttributeSource attributeSource) { if (this.attributeSource != attributeSource) { this.attributeSource = attributeSource; termAttribute = attributeSource.getAttribute(TermToBytesRefAttribute.class); termFreqAttribute = attributeSource.addAttribute(TermFrequencyAttribute.class); posIncrAttribute = attributeSource.addAttribute(PositionIncrementAttribute.class); offsetAttribute = attributeSource.addAttribute(OffsetAttribute.class); payloadAttribute = attributeSource.getAttribute(PayloadAttribute.class); } }
@Override public void setNextEnum(TermsEnum termsEnum) { this.termsEnum = termsEnum; assert compareToLastTerm(null); // lazy init the initial ScoreTerm because comparator is not known on ctor: if (st == null) st = new ScoreTerm(new TermContext(topReaderContext)); boostAtt = termsEnum.attributes().addAttribute(BoostAttribute.class); }
this.dfaAtt = atts.addAttribute(LevenshteinAutomataAttribute.class); this.maxBoostAtt = atts.addAttribute(MaxNonCompetitiveBoostAttribute.class); this.boostAtt = attributes().addAttribute(BoostAttribute.class);
collectTerms(reader, query, new TermCollector() { private final MaxNonCompetitiveBoostAttribute maxBoostAtt = attributes.addAttribute(MaxNonCompetitiveBoostAttribute.class);
public OneTimeWrapper(AttributeSource attributeSource) { super(attributeSource); this.offsetAtt = attributeSource.addAttribute(OffsetAttribute.class); this.posIncAtt = attributeSource.addAttribute(PositionIncrementAttribute.class); }
Token(AttributeSource attSource) { this.attSource = attSource; this.posIncAtt = attSource.addAttribute(PositionIncrementAttribute.class); this.termAtt = attSource.addAttribute(CharTermAttribute.class); this.offsetAtt = attSource.addAttribute(OffsetAttribute.class); }
private static AttributeSource combineSources(TokenStream... sources) { AttributeSource base = sources[0].cloneAttributes(); try { for (int i = 1; i < sources.length; i++) { Iterator<Class<? extends Attribute>> it = sources[i].getAttributeClassesIterator(); while (it.hasNext()) { base.addAttribute(it.next()); } // check attributes can be captured sources[i].copyTo(base); } return base; } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Attempted to concatenate TokenStreams with different attribute types", e); } }
private void buildField(XContentBuilder builder, final CharsRefBuilder spare, Fields theFields, Iterator<String> fieldIter) throws IOException { String fieldName = fieldIter.next(); builder.startObject(fieldName); Terms curTerms = theFields.terms(fieldName); // write field statistics buildFieldStatistics(builder, curTerms); builder.startObject(FieldStrings.TERMS); TermsEnum termIter = curTerms.iterator(); BoostAttribute boostAtt = termIter.attributes().addAttribute(BoostAttribute.class); for (int i = 0; i < curTerms.size(); i++) { buildTerm(builder, spare, curTerms, termIter, boostAtt); } builder.endObject(); builder.endObject(); }
BytesRefBuilder[] payloads = new BytesRefBuilder[1]; final BytesRefBuilder spare = new BytesRefBuilder(); BoostAttribute boostAtt = this.attributes().addAttribute(BoostAttribute.class);
/** * Create a token exposing values from an AttributeSource */ public Token(AttributeSource source) { this.termAtt = source.addAttribute(CharTermAttribute.class); this.posIncAtt = source.addAttribute(PositionIncrementAttribute.class); this.posLenAtt = source.addAttribute(PositionLengthAttribute.class); this.offsetAtt = source.addAttribute(OffsetAttribute.class); this.typeAtt = source.addAttribute(TypeAttribute.class); this.keywordAtt = source.addAttribute(KeywordAttribute.class); }
if (numFillerTokensToInsert > 0) { nextInputStreamToken = new AttributeSource(getAttributeFactory()); nextInputStreamToken.addAttribute(CharTermAttribute.class); OffsetAttribute newOffsetAtt = nextInputStreamToken.addAttribute(OffsetAttribute.class); newOffsetAtt.setOffset(offsetAtt.endOffset(), offsetAtt.endOffset());
/** * 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); } }
@Override public boolean accept(AttributeSource source) { if (typeAtt == null) { typeAtt = source.addAttribute(TypeAttribute.class); } //check to see if this is a Category return (typeToMatch.equals(typeAtt.type())); }
/** swap in a new actual enum to proxy to */ protected void setEnum(TermsEnum actualEnum) { this.actualEnum = actualEnum; this.actualBoostAtt = actualEnum.attributes().addAttribute(BoostAttribute.class); }
/** swap in a new actual enum to proxy to */ protected void setEnum(TermsEnum actualEnum) { this.actualEnum = actualEnum; this.actualBoostAtt = actualEnum.attributes().addAttribute(BoostAttribute.class); }
@Override public void setNextEnum(TermsEnum termsEnum) { this.termsEnum = termsEnum; assert compareToLastTerm(null); // lazy init the initial ScoreTerm because comparator is not known on ctor: if (st == null) st = new ScoreTerm(new TermContext(topReaderContext)); boostAtt = termsEnum.attributes().addAttribute(BoostAttribute.class); }
@Override public void setNextEnum(TermsEnum termsEnum) { this.termsEnum = termsEnum; assert compareToLastTerm(null); // lazy init the initial ScoreTerm because comparator is not known on ctor: if (st == null) st = new ScoreTerm(new TermContext(topReaderContext)); boostAtt = termsEnum.attributes().addAttribute(BoostAttribute.class); }
@Override public void setNextEnum(TermsEnum termsEnum) { this.termsEnum = termsEnum; assert compareToLastTerm(null); // lazy init the initial ScoreTerm because comparator is not known on ctor: if (st == null) st = new ScoreTerm(new TermContext(topReaderContext)); boostAtt = termsEnum.attributes().addAttribute(BoostAttribute.class); }
@Override public void setNextEnum(final TermsEnum termsEnum) throws IOException { this.termsEnum = termsEnum; this.termComp = termsEnum.getComparator(); assert this.compareToLastTerm(null); // lazy init the initial ScoreTerm because comparator is not known on ctor: if (st == null) st = new ScoreTerm(this.termComp, new TermContext(topReaderContext)); boostAtt = termsEnum.attributes().addAttribute(BoostAttribute.class); }
@Override public void setNextEnum(final TermsEnum termsEnum) throws IOException { this.termsEnum = termsEnum; this.termComp = termsEnum.getComparator(); assert this.compareToLastTerm(null); // lazy init the initial ScoreTerm because comparator is not known on ctor: if (st == null) st = new ScoreTerm(this.termComp, new TermContext(topReaderContext)); boostAtt = termsEnum.attributes().addAttribute(BoostAttribute.class); }