mirror of https://github.com/apache/lucene.git
Avoid redundant copies of BytesRef when constructing new Term (#12234)
This commit is contained in:
parent
4e88118a35
commit
2d0dc6407a
|
@ -159,10 +159,7 @@ public class NearestFuzzyQuery extends Query {
|
|||
float score = fe.getBoost();
|
||||
if (variantsQ.size() < MAX_VARIANTS_PER_TERM || score > minScore) {
|
||||
ScoreTerm st =
|
||||
new ScoreTerm(
|
||||
new Term(startTerm.field(), BytesRef.deepCopyOf(possibleMatch)),
|
||||
score,
|
||||
startTerm);
|
||||
new ScoreTerm(new Term(startTerm.field(), possibleMatch), score, startTerm);
|
||||
variantsQ.insertWithOverflow(st);
|
||||
minScore = variantsQ.top().score; // maintain minScore
|
||||
}
|
||||
|
|
|
@ -186,7 +186,7 @@ public class TermFilteredPresearcher extends Presearcher {
|
|||
+ field
|
||||
+ ":"
|
||||
+ Term.toString(term));
|
||||
bq.add(new TermQuery(new Term(field, BytesRef.deepCopyOf(term))), BooleanClause.Occur.SHOULD);
|
||||
bq.add(new TermQuery(new Term(field, term)), BooleanClause.Occur.SHOULD);
|
||||
}
|
||||
|
||||
BooleanQuery built = bq.build();
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.apache.lucene.queries.spans.SpanQuery;
|
|||
import org.apache.lucene.queries.spans.SpanTermQuery;
|
||||
import org.apache.lucene.queryparser.xml.DOMUtils;
|
||||
import org.apache.lucene.queryparser.xml.ParserException;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/** Builder that analyzes the text into a {@link SpanOrQuery} */
|
||||
|
@ -51,8 +50,7 @@ public class SpanOrTermsBuilder extends SpanBuilderBase {
|
|||
TermToBytesRefAttribute termAtt = ts.addAttribute(TermToBytesRefAttribute.class);
|
||||
ts.reset();
|
||||
while (ts.incrementToken()) {
|
||||
SpanTermQuery stq =
|
||||
new SpanTermQuery(new Term(fieldName, BytesRef.deepCopyOf(termAtt.getBytesRef())));
|
||||
SpanTermQuery stq = new SpanTermQuery(new Term(fieldName, termAtt.getBytesRef()));
|
||||
clausesList.add(stq);
|
||||
}
|
||||
ts.end();
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.apache.lucene.search.BooleanQuery;
|
|||
import org.apache.lucene.search.BoostQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
|
@ -55,7 +54,7 @@ public class TermsQueryBuilder implements QueryBuilder {
|
|||
Term term = null;
|
||||
ts.reset();
|
||||
while (ts.incrementToken()) {
|
||||
term = new Term(fieldName, BytesRef.deepCopyOf(termAtt.getBytesRef()));
|
||||
term = new Term(fieldName, termAtt.getBytesRef());
|
||||
bq.add(new BooleanClause(new TermQuery(term), BooleanClause.Occur.SHOULD));
|
||||
}
|
||||
ts.end();
|
||||
|
|
|
@ -224,10 +224,7 @@ public class FuzzyLikeThisQuery extends Query {
|
|||
float score = boostAtt.getBoost();
|
||||
if (variantsQ.size() < MAX_VARIANTS_PER_TERM || score > minScore) {
|
||||
ScoreTerm st =
|
||||
new ScoreTerm(
|
||||
new Term(startTerm.field(), BytesRef.deepCopyOf(possibleMatch)),
|
||||
score,
|
||||
startTerm);
|
||||
new ScoreTerm(new Term(startTerm.field(), possibleMatch), score, startTerm);
|
||||
variantsQ.insertWithOverflow(st);
|
||||
minScore = variantsQ.top().score; // maintain minScore
|
||||
}
|
||||
|
|
|
@ -451,9 +451,7 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
|
|||
// System.out.println(Thread.currentThread().getName() + " now search
|
||||
// body:" + term.utf8ToString());
|
||||
// }
|
||||
totHits.addAndGet(
|
||||
runQuery(
|
||||
s, new TermQuery(new Term("body", BytesRef.deepCopyOf(term)))));
|
||||
totHits.addAndGet(runQuery(s, new TermQuery(new Term("body", term))));
|
||||
}
|
||||
}
|
||||
// if (VERBOSE) {
|
||||
|
|
Loading…
Reference in New Issue