LUCENE-5114: remove unused useCache param

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1503805 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2013-07-16 17:44:10 +00:00
parent 98c38acfe5
commit 360452940e
83 changed files with 162 additions and 211 deletions

View File

@ -62,6 +62,9 @@ API Changes
* LUCENE-5094: Add ramBytesUsed() to MultiDocValues.OrdinalMap.
(Robert Muir)
* LUCENE-5114: Remove unused boolean useCache parameter from
TermsEnum.seekCeil and .seekExact (Mike McCandless)
======================= Lucene 4.4.0 =======================
Changes in backwards compatibility policy

View File

@ -69,9 +69,6 @@ public class BlockTermsReader extends FieldsProducer {
private final TreeMap<String,FieldReader> fields = new TreeMap<String,FieldReader>();
// Caches the most recently looked-up field + terms:
private final DoubleBarrelLRUCache<FieldAndTerm,BlockTermState> termsCache;
// Reads the terms index
private TermsIndexReaderBase indexReader;
@ -113,11 +110,10 @@ public class BlockTermsReader extends FieldsProducer {
// private String segment;
public BlockTermsReader(TermsIndexReaderBase indexReader, Directory dir, FieldInfos fieldInfos, SegmentInfo info, PostingsReaderBase postingsReader, IOContext context,
int termsCacheSize, String segmentSuffix)
String segmentSuffix)
throws IOException {
this.postingsReader = postingsReader;
termsCache = new DoubleBarrelLRUCache<FieldAndTerm,BlockTermState>(termsCacheSize);
// this.segment = segment;
in = dir.openInput(IndexFileNames.segmentFileName(info.name, segmentSuffix, BlockTermsWriter.TERMS_EXTENSION),
@ -362,13 +358,13 @@ public class BlockTermsReader extends FieldsProducer {
// return NOT_FOUND so it's a waste for us to fill in
// the term that was actually NOT_FOUND
@Override
public SeekStatus seekCeil(final BytesRef target, final boolean useCache) throws IOException {
public SeekStatus seekCeil(final BytesRef target) throws IOException {
if (indexEnum == null) {
throw new IllegalStateException("terms index was not loaded");
}
//System.out.println("BTR.seek seg=" + segment + " target=" + fieldInfo.name + ":" + target.utf8ToString() + " " + target + " current=" + term().utf8ToString() + " " + term() + " useCache=" + useCache + " indexIsCurrent=" + indexIsCurrent + " didIndexNext=" + didIndexNext + " seekPending=" + seekPending + " divisor=" + indexReader.getDivisor() + " this=" + this);
//System.out.println("BTR.seek seg=" + segment + " target=" + fieldInfo.name + ":" + target.utf8ToString() + " " + target + " current=" + term().utf8ToString() + " " + term() + " indexIsCurrent=" + indexIsCurrent + " didIndexNext=" + didIndexNext + " seekPending=" + seekPending + " divisor=" + indexReader.getDivisor() + " this=" + this);
if (didIndexNext) {
if (nextIndexTerm == null) {
//System.out.println(" nextIndexTerm=null");
@ -377,23 +373,6 @@ public class BlockTermsReader extends FieldsProducer {
}
}
// Check cache
if (useCache) {
fieldTerm.term = target;
// TODO: should we differentiate "frozen"
// TermState (ie one that was cloned and
// cached/returned by termState()) from the
// malleable (primary) one?
final TermState cachedState = termsCache.get(fieldTerm);
if (cachedState != null) {
seekPending = true;
//System.out.println(" cached!");
seekExact(target, cachedState);
//System.out.println(" term=" + term.utf8ToString());
return SeekStatus.FOUND;
}
}
boolean doSeek = true;
// See if we can avoid seeking, because target term
@ -574,14 +553,6 @@ public class BlockTermsReader extends FieldsProducer {
// Done! Exact match. Stop here, fill in
// real term, return FOUND.
//System.out.println(" FOUND");
if (useCache) {
// Store in cache
decodeMetaData();
//System.out.println(" cache! state=" + state);
termsCache.put(new FieldAndTerm(fieldTerm), (BlockTermState) state.clone());
}
return SeekStatus.FOUND;
} else {
//System.out.println(" NOT_FOUND");

View File

@ -331,7 +331,7 @@ public final class BloomFilteringPostingsFormat extends PostingsFormat {
}
@Override
public final boolean seekExact(BytesRef text, boolean useCache)
public final boolean seekExact(BytesRef text)
throws IOException {
// The magical fail-fast speed up that is the entire point of all of
// this code - save a disk seek if there is a match on an in-memory
@ -341,13 +341,13 @@ public final class BloomFilteringPostingsFormat extends PostingsFormat {
if (filter.contains(text) == ContainsResult.NO) {
return false;
}
return delegate().seekExact(text, useCache);
return delegate().seekExact(text);
}
@Override
public final SeekStatus seekCeil(BytesRef text, boolean useCache)
public final SeekStatus seekCeil(BytesRef text)
throws IOException {
return delegate().seekCeil(text, useCache);
return delegate().seekCeil(text);
}
@Override

View File

@ -684,7 +684,7 @@ public final class DirectPostingsFormat extends PostingsFormat {
}
@Override
public SeekStatus seekCeil(BytesRef term, boolean useCache) {
public SeekStatus seekCeil(BytesRef term) {
// TODO: we should use the skip pointers; should be
// faster than bin search; we should also hold
// & reuse current state so seeking forwards is
@ -707,7 +707,7 @@ public final class DirectPostingsFormat extends PostingsFormat {
}
@Override
public boolean seekExact(BytesRef term, boolean useCache) {
public boolean seekExact(BytesRef term) {
// TODO: we should use the skip pointers; should be
// faster than bin search; we should also hold
// & reuse current state so seeking forwards is
@ -1413,7 +1413,7 @@ public final class DirectPostingsFormat extends PostingsFormat {
}
@Override
public SeekStatus seekCeil(BytesRef term, boolean useCache) {
public SeekStatus seekCeil(BytesRef term) {
throw new UnsupportedOperationException();
}

View File

@ -654,7 +654,7 @@ public final class MemoryPostingsFormat extends PostingsFormat {
}
@Override
public boolean seekExact(BytesRef text, boolean useCache /* ignored */) throws IOException {
public boolean seekExact(BytesRef text) throws IOException {
//System.out.println("te.seekExact text=" + field.name + ":" + text.utf8ToString() + " this=" + this);
current = fstEnum.seekExact(text);
didDecode = false;
@ -662,7 +662,7 @@ public final class MemoryPostingsFormat extends PostingsFormat {
}
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache /* ignored */) throws IOException {
public SeekStatus seekCeil(BytesRef text) throws IOException {
//System.out.println("te.seek text=" + field.name + ":" + text.utf8ToString() + " this=" + this);
current = fstEnum.seekCeil(text);
if (current == null) {

View File

@ -109,7 +109,7 @@ class SimpleTextFieldsReader extends FieldsProducer {
}
@Override
public boolean seekExact(BytesRef text, boolean useCache /* ignored */) throws IOException {
public boolean seekExact(BytesRef text) throws IOException {
final BytesRefFSTEnum.InputOutput<PairOutputs.Pair<Long,PairOutputs.Pair<Long,Long>>> result = fstEnum.seekExact(text);
if (result != null) {
@ -125,7 +125,7 @@ class SimpleTextFieldsReader extends FieldsProducer {
}
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache /* ignored */) throws IOException {
public SeekStatus seekCeil(BytesRef text) throws IOException {
//System.out.println("seek to text=" + text.utf8ToString());
final BytesRefFSTEnum.InputOutput<PairOutputs.Pair<Long,PairOutputs.Pair<Long,Long>>> result = fstEnum.seekCeil(text);

View File

@ -331,7 +331,7 @@ public class SimpleTextTermVectorsReader extends TermVectorsReader {
}
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache) throws IOException {
public SeekStatus seekCeil(BytesRef text) throws IOException {
iterator = terms.tailMap(text).entrySet().iterator();
if (!iterator.hasNext()) {
return SeekStatus.END;

View File

@ -1222,7 +1222,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
}
@Override
public boolean seekExact(BytesRef text, boolean useCache) {
public boolean seekExact(BytesRef text) {
throw new UnsupportedOperationException();
}
@ -1237,7 +1237,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
}
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache) {
public SeekStatus seekCeil(BytesRef text) {
throw new UnsupportedOperationException();
}
}
@ -1499,7 +1499,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
}
@Override
public boolean seekExact(final BytesRef target, final boolean useCache) throws IOException {
public boolean seekExact(final BytesRef target) throws IOException {
if (index == null) {
throw new IllegalStateException("terms index was not loaded");
@ -1760,7 +1760,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
}
@Override
public SeekStatus seekCeil(final BytesRef target, final boolean useCache) throws IOException {
public SeekStatus seekCeil(final BytesRef target) throws IOException {
if (index == null) {
throw new IllegalStateException("terms index was not loaded");
}
@ -2096,7 +2096,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
// this method catches up all internal state so next()
// works properly:
//if (DEBUG) System.out.println(" re-seek to pending term=" + term.utf8ToString() + " " + term);
final boolean result = seekExact(term, false);
final boolean result = seekExact(term);
assert result;
}

View File

@ -824,7 +824,7 @@ public final class CompressingTermVectorsReader extends TermVectorsReader implem
}
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache)
public SeekStatus seekCeil(BytesRef text)
throws IOException {
if (ord < numTerms && ord >= 0) {
final int cmp = term().compareTo(text);

View File

@ -433,7 +433,7 @@ public class Lucene40TermVectorsReader extends TermVectorsReader implements Clos
// NOTE: slow! (linear scan)
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache)
public SeekStatus seekCeil(BytesRef text)
throws IOException {
if (nextTerm != 0) {
final int cmp = text.compareTo(term);

View File

@ -490,7 +490,7 @@ class Lucene42DocValuesProducer extends DocValuesProducer {
}
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache) throws IOException {
public SeekStatus seekCeil(BytesRef text) throws IOException {
if (in.seekCeil(text) == null) {
return SeekStatus.END;
} else if (term().equals(text)) {
@ -503,7 +503,7 @@ class Lucene42DocValuesProducer extends DocValuesProducer {
}
@Override
public boolean seekExact(BytesRef text, boolean useCache) throws IOException {
public boolean seekExact(BytesRef text) throws IOException {
if (in.seekExact(text) == null) {
return false;
} else {

View File

@ -78,7 +78,7 @@ public abstract class AtomicReader extends IndexReader {
return 0;
}
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(term.bytes(), true)) {
if (termsEnum.seekExact(term.bytes())) {
return termsEnum.docFreq();
} else {
return 0;
@ -101,7 +101,7 @@ public abstract class AtomicReader extends IndexReader {
return 0;
}
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(term.bytes(), true)) {
if (termsEnum.seekExact(term.bytes())) {
return termsEnum.totalTermFreq();
} else {
return 0;
@ -156,7 +156,7 @@ public abstract class AtomicReader extends IndexReader {
final Terms terms = fields.terms(term.field());
if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(term.bytes(), true)) {
if (termsEnum.seekExact(term.bytes())) {
return termsEnum.docs(getLiveDocs(), null);
}
}
@ -176,7 +176,7 @@ public abstract class AtomicReader extends IndexReader {
final Terms terms = fields.terms(term.field());
if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(term.bytes(), true)) {
if (termsEnum.seekExact(term.bytes())) {
return termsEnum.docsAndPositions(getLiveDocs(), null);
}
}

View File

@ -390,7 +390,7 @@ class BufferedDeletesStream {
// System.out.println(" term=" + term);
if (termsEnum.seekExact(term.bytes(), false)) {
if (termsEnum.seekExact(term.bytes())) {
// we don't need term frequencies for this
DocsEnum docsEnum = termsEnum.docs(rld.getLiveDocs(), docs, DocsEnum.FLAG_NONE);
//System.out.println("BDS: got docsEnum=" + docsEnum);

View File

@ -1117,7 +1117,7 @@ public class CheckIndex {
long totDocCountNoDeletes = 0;
long totDocFreq = 0;
for(int i=0;i<seekCount;i++) {
if (!termsEnum.seekExact(seekTerms[i], true)) {
if (!termsEnum.seekExact(seekTerms[i])) {
throw new RuntimeException("seek to existing term " + seekTerms[i] + " failed");
}
@ -1543,7 +1543,7 @@ public class CheckIndex {
}
final DocsEnum postingsDocs2;
if (!postingsTermsEnum.seekExact(term, true)) {
if (!postingsTermsEnum.seekExact(term)) {
throw new RuntimeException("vector term=" + term + " field=" + field + " does not exist in postings; doc=" + j);
}
postingsPostings = postingsTermsEnum.docsAndPositions(null, postingsPostings);

View File

@ -659,7 +659,7 @@ public class DocTermOrds {
}
@Override
public SeekStatus seekCeil(BytesRef target, boolean useCache) throws IOException {
public SeekStatus seekCeil(BytesRef target) throws IOException {
// already here
if (term != null && term.equals(target)) {
@ -729,7 +729,7 @@ public class DocTermOrds {
//System.out.println(" do seek term=" + base.utf8ToString());
ord = idx << indexIntervalBits;
delta = (int) (targetOrd - ord);
final TermsEnum.SeekStatus seekStatus = termsEnum.seekCeil(base, true);
final TermsEnum.SeekStatus seekStatus = termsEnum.seekCeil(base);
assert seekStatus == TermsEnum.SeekStatus.FOUND;
} else {
//System.out.println("seek w/in block");

View File

@ -157,8 +157,8 @@ public class FilterAtomicReader extends AtomicReader {
}
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache) throws IOException {
return in.seekCeil(text, useCache);
public SeekStatus seekCeil(BytesRef text) throws IOException {
return in.seekCeil(text);
}
@Override

View File

@ -154,7 +154,7 @@ public abstract class FilteredTermsEnum extends TermsEnum {
* support seeking.
*/
@Override
public boolean seekExact(BytesRef term, boolean useCache) throws IOException {
public boolean seekExact(BytesRef term) throws IOException {
throw new UnsupportedOperationException(getClass().getName()+" does not support seeking");
}
@ -163,7 +163,7 @@ public abstract class FilteredTermsEnum extends TermsEnum {
* support seeking.
*/
@Override
public SeekStatus seekCeil(BytesRef term, boolean useCache) throws IOException {
public SeekStatus seekCeil(BytesRef term) throws IOException {
throw new UnsupportedOperationException(getClass().getName()+" does not support seeking");
}
@ -222,7 +222,7 @@ public abstract class FilteredTermsEnum extends TermsEnum {
//System.out.println(" seek to t=" + (t == null ? "null" : t.utf8ToString()) + " tenum=" + tenum);
// Make sure we always seek forward:
assert actualTerm == null || t == null || getComparator().compare(t, actualTerm) > 0: "curTerm=" + actualTerm + " seekTerm=" + t;
if (t == null || tenum.seekCeil(t, false) == SeekStatus.END) {
if (t == null || tenum.seekCeil(t) == SeekStatus.END) {
// no more terms to seek to or enum exhausted
//System.out.println(" return null");
return null;

View File

@ -150,7 +150,7 @@ public final class MultiFields extends Fields {
final Terms terms = getTerms(r, field);
if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(term, true)) {
if (termsEnum.seekExact(term)) {
return termsEnum.docs(liveDocs, null, flags);
}
}
@ -178,7 +178,7 @@ public final class MultiFields extends Fields {
final Terms terms = getTerms(r, field);
if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(term, true)) {
if (termsEnum.seekExact(term)) {
return termsEnum.docsAndPositions(liveDocs, null, flags);
}
}

View File

@ -144,7 +144,7 @@ public final class MultiTermsEnum extends TermsEnum {
}
@Override
public boolean seekExact(BytesRef term, boolean useCache) throws IOException {
public boolean seekExact(BytesRef term) throws IOException {
queue.clear();
numTop = 0;
@ -173,13 +173,13 @@ public final class MultiTermsEnum extends TermsEnum {
} else if (cmp < 0) {
status = false;
} else {
status = currentSubs[i].terms.seekExact(term, useCache);
status = currentSubs[i].terms.seekExact(term);
}
} else {
status = false;
}
} else {
status = currentSubs[i].terms.seekExact(term, useCache);
status = currentSubs[i].terms.seekExact(term);
}
if (status) {
@ -195,7 +195,7 @@ public final class MultiTermsEnum extends TermsEnum {
}
@Override
public SeekStatus seekCeil(BytesRef term, boolean useCache) throws IOException {
public SeekStatus seekCeil(BytesRef term) throws IOException {
queue.clear();
numTop = 0;
lastSeekExact = false;
@ -225,13 +225,13 @@ public final class MultiTermsEnum extends TermsEnum {
} else if (cmp < 0) {
status = SeekStatus.NOT_FOUND;
} else {
status = currentSubs[i].terms.seekCeil(term, useCache);
status = currentSubs[i].terms.seekCeil(term);
}
} else {
status = SeekStatus.END;
}
} else {
status = currentSubs[i].terms.seekCeil(term, useCache);
status = currentSubs[i].terms.seekCeil(term);
}
if (status == SeekStatus.FOUND) {

View File

@ -37,7 +37,7 @@ class SortedDocValuesTermsEnum extends TermsEnum {
}
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache /* ignored */) throws IOException {
public SeekStatus seekCeil(BytesRef text) throws IOException {
int ord = values.lookupTerm(text);
if (ord >= 0) {
currentOrd = ord;
@ -61,7 +61,7 @@ class SortedDocValuesTermsEnum extends TermsEnum {
}
@Override
public boolean seekExact(BytesRef text, boolean useCache) throws IOException {
public boolean seekExact(BytesRef text) throws IOException {
int ord = values.lookupTerm(text);
if (ord >= 0) {
term.offset = 0;

View File

@ -37,7 +37,7 @@ class SortedSetDocValuesTermsEnum extends TermsEnum {
}
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache /* ignored */) throws IOException {
public SeekStatus seekCeil(BytesRef text) throws IOException {
long ord = values.lookupTerm(text);
if (ord >= 0) {
currentOrd = ord;
@ -61,7 +61,7 @@ class SortedSetDocValuesTermsEnum extends TermsEnum {
}
@Override
public boolean seekExact(BytesRef text, boolean useCache) throws IOException {
public boolean seekExact(BytesRef text) throws IOException {
long ord = values.lookupTerm(text);
if (ord >= 0) {
term.offset = 0;

View File

@ -78,7 +78,7 @@ public final class TermContext {
* <p>
* Note: the given context must be a top-level context.
*/
public static TermContext build(IndexReaderContext context, Term term, boolean cache)
public static TermContext build(IndexReaderContext context, Term term)
throws IOException {
assert context != null && context.isTopLevel;
final String field = term.field();
@ -92,7 +92,7 @@ public final class TermContext {
final Terms terms = fields.terms(field);
if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(bytes, cache)) {
if (termsEnum.seekExact(bytes)) {
final TermState termState = termsEnum.termState();
//if (DEBUG) System.out.println(" found");
perReaderTermState.register(termState, ctx.ord, termsEnum.docFreq(), termsEnum.totalTermFreq());

View File

@ -26,7 +26,7 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefIterator;
/** Iterator to seek ({@link #seekCeil(BytesRef)}, {@link
* #seekExact(BytesRef,boolean)}) or step through ({@link
* #seekExact(BytesRef)}) or step through ({@link
* #next} terms to obtain frequency information ({@link
* #docFreq}), {@link DocsEnum} or {@link
* DocsAndPositionsEnum} for the current term ({@link
@ -70,24 +70,17 @@ public abstract class TermsEnum implements BytesRefIterator {
* true if the term is found. If this returns false, the
* enum is unpositioned. For some codecs, seekExact may
* be substantially faster than {@link #seekCeil}. */
public boolean seekExact(BytesRef text, boolean useCache) throws IOException {
return seekCeil(text, useCache) == SeekStatus.FOUND;
public boolean seekExact(BytesRef text) throws IOException {
return seekCeil(text) == SeekStatus.FOUND;
}
/** Expert: just like {@link #seekCeil(BytesRef)} but allows
* you to control whether the implementation should
* attempt to use its term cache (if it uses one). */
public abstract SeekStatus seekCeil(BytesRef text, boolean useCache) throws IOException;
/** Seeks to the specified term, if it exists, or to the
* next (ceiling) term. Returns SeekStatus to
* indicate whether exact term was found, a different
* term was found, or EOF was hit. The target term may
* be before or after the current term. If this returns
* SeekStatus.END, the enum is unpositioned. */
public final SeekStatus seekCeil(BytesRef text) throws IOException {
return seekCeil(text, true);
}
public abstract SeekStatus seekCeil(BytesRef text) throws IOException;
/** Seeks to the specified term by ordinal (position) as
* previously returned by {@link #ord}. The target ord
@ -117,7 +110,7 @@ public abstract class TermsEnum implements BytesRefIterator {
* @param state the {@link TermState}
* */
public void seekExact(BytesRef term, TermState state) throws IOException {
if (!seekExact(term, true)) {
if (!seekExact(term)) {
throw new IllegalArgumentException("term=" + term + " does not exist");
}
}
@ -226,7 +219,7 @@ public abstract class TermsEnum implements BytesRefIterator {
*/
public static final TermsEnum EMPTY = new TermsEnum() {
@Override
public SeekStatus seekCeil(BytesRef term, boolean useCache) { return SeekStatus.END; }
public SeekStatus seekCeil(BytesRef term) { return SeekStatus.END; }
@Override
public void seekExact(long ord) {}

View File

@ -303,13 +303,13 @@ public class FuzzyTermsEnum extends TermsEnum {
}
@Override
public boolean seekExact(BytesRef text, boolean useCache) throws IOException {
return actualEnum.seekExact(text, useCache);
public boolean seekExact(BytesRef text) throws IOException {
return actualEnum.seekExact(text);
}
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache) throws IOException {
return actualEnum.seekCeil(text, useCache);
public SeekStatus seekCeil(BytesRef text) throws IOException {
return actualEnum.seekCeil(text);
}
@Override

View File

@ -149,7 +149,7 @@ public class MultiPhraseQuery extends Query {
for (Term term: terms) {
TermContext termContext = termContexts.get(term);
if (termContext == null) {
termContext = TermContext.build(context, term, true);
termContext = TermContext.build(context, term);
termContexts.put(term, termContext);
}
allTermStats.add(searcher.termStatistics(term, termContext));

View File

@ -37,7 +37,6 @@ import org.apache.lucene.search.similarities.Similarity.SimScorer;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.ToStringUtils;
/** A Query that matches documents containing a particular sequence of terms.
@ -218,7 +217,7 @@ public class PhraseQuery extends Query {
TermStatistics termStats[] = new TermStatistics[terms.size()];
for (int i = 0; i < terms.size(); i++) {
final Term term = terms.get(i);
states[i] = TermContext.build(context, term, true);
states[i] = TermContext.build(context, term);
termStats[i] = searcher.termStatistics(term, states[i]);
}
stats = similarity.computeWeight(getBoost(), searcher.collectionStatistics(field), termStats);
@ -269,7 +268,7 @@ public class PhraseQuery extends Query {
// PhraseQuery on a field that did not index
// positions.
if (postingsEnum == null) {
assert te.seekExact(t.bytes(), false) : "termstate found but no term exists in reader";
assert te.seekExact(t.bytes()) : "termstate found but no term exists in reader";
// term does exist, but has no positions
throw new IllegalStateException("field \"" + t.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + t.text() + ")");
}

View File

@ -163,7 +163,7 @@ public class TermQuery extends Query {
final TermContext termState;
if (perReaderTermState == null || perReaderTermState.topReaderContext != context) {
// make TermQuery single-pass if we don't have a PRTS or if the context differs!
termState = TermContext.build(context, term, true); // cache term lookups!
termState = TermContext.build(context, term);
} else {
// PRTS was pre-build for this IS
termState = this.perReaderTermState;

View File

@ -182,7 +182,7 @@ public class PayloadSpanUtil {
TreeSet<Term> terms = new TreeSet<Term>();
query.extractTerms(terms);
for (Term term : terms) {
termContexts.put(term, TermContext.build(context, term, true));
termContexts.put(term, TermContext.build(context, term));
}
for (AtomicReaderContext atomicReaderContext : context.leaves()) {
final Spans spans = query.getSpans(atomicReaderContext, atomicReaderContext.reader().getLiveDocs(), termContexts);

View File

@ -98,7 +98,7 @@ public class SpanTermQuery extends SpanQuery {
final Terms terms = fields.terms(term.field());
if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(term.bytes(), true)) {
if (termsEnum.seekExact(term.bytes())) {
state = termsEnum.termState();
} else {
state = null;

View File

@ -52,7 +52,7 @@ public class SpanWeight extends Weight {
final TermStatistics termStats[] = new TermStatistics[terms.size()];
int i = 0;
for (Term term : terms) {
TermContext state = TermContext.build(context, term, true);
TermContext state = TermContext.build(context, term);
termStats[i] = searcher.termStatistics(term, state);
termContexts.put(term, state);
i++;

View File

@ -162,7 +162,7 @@ public class TestReuseDocsEnum extends LuceneTestCase {
return null;
}
TermsEnum iterator = terms.iterator(null);
if (iterator.seekExact(term, true)) {
if (iterator.seekExact(term)) {
return iterator.docs(bits, null, random().nextBoolean() ? DocsEnum.FLAG_FREQS : DocsEnum.FLAG_NONE);
}
return null;

View File

@ -235,21 +235,21 @@ public class TestBlockPostingsFormat3 extends LuceneTestCase {
leftEnum = leftTerms.iterator(leftEnum);
rightEnum = rightTerms.iterator(rightEnum);
assertEquals(leftEnum.seekExact(b, false), rightEnum.seekExact(b, false));
assertEquals(leftEnum.seekExact(b, true), rightEnum.seekExact(b, true));
assertEquals(leftEnum.seekExact(b), rightEnum.seekExact(b));
assertEquals(leftEnum.seekExact(b), rightEnum.seekExact(b));
SeekStatus leftStatus;
SeekStatus rightStatus;
leftStatus = leftEnum.seekCeil(b, false);
rightStatus = rightEnum.seekCeil(b, false);
leftStatus = leftEnum.seekCeil(b);
rightStatus = rightEnum.seekCeil(b);
assertEquals(leftStatus, rightStatus);
if (leftStatus != SeekStatus.END) {
assertEquals(leftEnum.term(), rightEnum.term());
}
leftStatus = leftEnum.seekCeil(b, true);
rightStatus = rightEnum.seekCeil(b, true);
leftStatus = leftEnum.seekCeil(b);
rightStatus = rightEnum.seekCeil(b);
assertEquals(leftStatus, rightStatus);
if (leftStatus != SeekStatus.END) {
assertEquals(leftEnum.term(), rightEnum.term());

View File

@ -332,7 +332,7 @@ public class TestDocTermOrds extends LuceneTestCase {
Terms terms = MultiFields.getTerms(r, "field");
if (terms != null) {
TermsEnum termsEnum = terms.iterator(null);
TermsEnum.SeekStatus result = termsEnum.seekCeil(prefixRef, false);
TermsEnum.SeekStatus result = termsEnum.seekCeil(prefixRef);
if (result != TermsEnum.SeekStatus.END) {
assertFalse("term=" + termsEnum.term().utf8ToString() + " matches prefix=" + prefixRef.utf8ToString(), StringHelper.startsWith(termsEnum.term(), prefixRef));
} else {
@ -454,16 +454,16 @@ public class TestDocTermOrds extends LuceneTestCase {
assertEquals(SeekStatus.END, termsEnum.seekCeil(new BytesRef("zzz")));
// seekExact()
assertTrue(termsEnum.seekExact(new BytesRef("beer"), true));
assertTrue(termsEnum.seekExact(new BytesRef("beer")));
assertEquals("beer", termsEnum.term().utf8ToString());
assertEquals(0, termsEnum.ord());
assertTrue(termsEnum.seekExact(new BytesRef("hello"), true));
assertTrue(termsEnum.seekExact(new BytesRef("hello")));
assertEquals("hello", termsEnum.term().utf8ToString());
assertEquals(1, termsEnum.ord());
assertTrue(termsEnum.seekExact(new BytesRef("world"), true));
assertTrue(termsEnum.seekExact(new BytesRef("world")));
assertEquals("world", termsEnum.term().utf8ToString());
assertEquals(2, termsEnum.ord());
assertFalse(termsEnum.seekExact(new BytesRef("bogus"), true));
assertFalse(termsEnum.seekExact(new BytesRef("bogus")));
// seek(ord)
termsEnum.seekExact(0);

View File

@ -95,7 +95,7 @@ public class TestDocsAndPositions extends LuceneTestCase {
Terms terms = reader.terms(fieldName);
if (terms != null) {
TermsEnum te = terms.iterator(null);
if (te.seekExact(bytes, true)) {
if (te.seekExact(bytes)) {
return te.docsAndPositions(liveDocs, null);
}
}
@ -341,7 +341,7 @@ public class TestDocsAndPositions extends LuceneTestCase {
// now reuse and check again
TermsEnum te = r.terms("foo").iterator(null);
assertTrue(te.seekExact(new BytesRef("bar"), true));
assertTrue(te.seekExact(new BytesRef("bar")));
disi = _TestUtil.docs(random(), te, null, disi, DocsEnum.FLAG_NONE);
docid = disi.docID();
assertEquals(-1, docid);
@ -366,7 +366,7 @@ public class TestDocsAndPositions extends LuceneTestCase {
// now reuse and check again
TermsEnum te = r.terms("foo").iterator(null);
assertTrue(te.seekExact(new BytesRef("bar"), true));
assertTrue(te.seekExact(new BytesRef("bar")));
disi = te.docsAndPositions(null, disi);
docid = disi.docID();
assertEquals(-1, docid);

View File

@ -70,7 +70,7 @@ public class TestPayloadsOnVectors extends LuceneTestCase {
Terms terms = reader.getTermVector(1, "field");
assert terms != null;
TermsEnum termsEnum = terms.iterator(null);
assertTrue(termsEnum.seekExact(new BytesRef("withPayload"), true));
assertTrue(termsEnum.seekExact(new BytesRef("withPayload")));
DocsAndPositionsEnum de = termsEnum.docsAndPositions(null, null);
assertEquals(0, de.nextDoc());
assertEquals(0, de.nextPosition());
@ -112,7 +112,7 @@ public class TestPayloadsOnVectors extends LuceneTestCase {
Terms terms = reader.getTermVector(0, "field");
assert terms != null;
TermsEnum termsEnum = terms.iterator(null);
assertTrue(termsEnum.seekExact(new BytesRef("withPayload"), true));
assertTrue(termsEnum.seekExact(new BytesRef("withPayload")));
DocsAndPositionsEnum de = termsEnum.docsAndPositions(null, null);
assertEquals(0, de.nextDoc());
assertEquals(3, de.nextPosition());

View File

@ -227,7 +227,7 @@ public class TestPerSegmentDeletes extends LuceneTestCase {
Fields fields = MultiFields.getFields(reader);
Terms cterms = fields.terms(term.field);
TermsEnum ctermsEnum = cterms.iterator(null);
if (ctermsEnum.seekExact(new BytesRef(term.text()), false)) {
if (ctermsEnum.seekExact(new BytesRef(term.text()))) {
DocsEnum docsEnum = _TestUtil.docs(random(), ctermsEnum, bits, null, DocsEnum.FLAG_NONE);
return toArray(docsEnum);
}

View File

@ -301,7 +301,7 @@ public class TestPostingsOffsets extends LuceneTestCase {
final FieldCache.Ints docIDToID = FieldCache.DEFAULT.getInts(sub, "id", false);
for(String term : terms) {
//System.out.println(" term=" + term);
if (termsEnum.seekExact(new BytesRef(term), random().nextBoolean())) {
if (termsEnum.seekExact(new BytesRef(term))) {
docs = termsEnum.docs(null, docs);
assertNotNull(docs);
int doc;

View File

@ -354,7 +354,7 @@ public class TestStressIndexing2 extends LuceneTestCase {
}
termDocs1 = _TestUtil.docs(random(), termsEnum, liveDocs1, termDocs1, DocsEnum.FLAG_NONE);
if (termsEnum2.seekExact(term, false)) {
if (termsEnum2.seekExact(term)) {
termDocs2 = _TestUtil.docs(random(), termsEnum2, liveDocs2, termDocs2, DocsEnum.FLAG_NONE);
} else {
termDocs2 = null;

View File

@ -111,7 +111,7 @@ public class TestTermsEnum extends LuceneTestCase {
System.out.println("TEST: iter seekCeil target=" + target.utf8ToString() + " exists=" + exists);
}
// seekCeil
final TermsEnum.SeekStatus status = termsEnum.seekCeil(target, random().nextBoolean());
final TermsEnum.SeekStatus status = termsEnum.seekCeil(target);
if (VERBOSE) {
System.out.println(" got " + status);
}
@ -134,7 +134,7 @@ public class TestTermsEnum extends LuceneTestCase {
System.out.println("TEST: iter seekExact target=" + target.utf8ToString() + " exists=" + exists);
}
// seekExact
final boolean result = termsEnum.seekExact(target, false);
final boolean result = termsEnum.seekExact(target);
if (VERBOSE) {
System.out.println(" got " + result);
}
@ -571,7 +571,7 @@ public class TestTermsEnum extends LuceneTestCase {
// sugar
private boolean seekExact(TermsEnum te, String term) throws IOException {
return te.seekExact(new BytesRef(term), random().nextBoolean());
return te.seekExact(new BytesRef(term));
}
// sugar
@ -666,13 +666,13 @@ public class TestTermsEnum extends LuceneTestCase {
if (VERBOSE) {
System.out.println(" seekExact");
}
assertEquals(loc >= 0, te.seekExact(t, random().nextBoolean()));
assertEquals(loc >= 0, te.seekExact(t));
} else {
if (VERBOSE) {
System.out.println(" seekCeil");
}
final TermsEnum.SeekStatus result = te.seekCeil(t, random().nextBoolean());
final TermsEnum.SeekStatus result = te.seekCeil(t);
if (VERBOSE) {
System.out.println(" got " + result);
}

View File

@ -117,10 +117,10 @@ public class TestTermsEnum2 extends LuceneTestCase {
// term is accepted
if (random().nextBoolean()) {
// seek exact
assertTrue(te.seekExact(term, random().nextBoolean()));
assertTrue(te.seekExact(term));
} else {
// seek ceil
assertEquals(SeekStatus.FOUND, te.seekCeil(term, random().nextBoolean()));
assertEquals(SeekStatus.FOUND, te.seekCeil(term));
assertEquals(term, te.term());
}
}
@ -138,10 +138,10 @@ public class TestTermsEnum2 extends LuceneTestCase {
if (c == 0) {
assertEquals(term, te.next());
} else if (c == 1) {
assertEquals(SeekStatus.FOUND, te.seekCeil(term, random().nextBoolean()));
assertEquals(SeekStatus.FOUND, te.seekCeil(term));
assertEquals(term, te.term());
} else {
assertTrue(te.seekExact(term, random().nextBoolean()));
assertTrue(te.seekExact(term));
}
}
}

View File

@ -294,7 +294,7 @@ public class TestMinShouldMatch2 extends LuceneTestCase {
if (ord >= 0) {
boolean success = ords.add(ord);
assert success; // no dups
TermContext context = TermContext.build(reader.getContext(), term, true);
TermContext context = TermContext.build(reader.getContext(), term);
SimWeight w = weight.similarity.computeWeight(1f,
searcher.collectionStatistics("field"),
searcher.termStatistics(term, context));

View File

@ -60,7 +60,7 @@ public class MultiSpansWrapper extends Spans { // can't be package private due t
TreeSet<Term> terms = new TreeSet<Term>();
query.extractTerms(terms);
for (Term term : terms) {
termContexts.put(term, TermContext.build(topLevelReaderContext, term, true));
termContexts.put(term, TermContext.build(topLevelReaderContext, term));
}
final List<AtomicReaderContext> leaves = topLevelReaderContext.leaves();
if(leaves.size() == 1) {

View File

@ -932,20 +932,15 @@ public class TestFSTs extends LuceneTestCase {
}
}
final boolean useCache = random().nextBoolean();
if (VERBOSE) {
System.out.println(" useCache=" + useCache);
}
final TermsEnum.SeekStatus status;
if (nextID == null) {
if (termsEnum.seekExact(new BytesRef(id), useCache)) {
if (termsEnum.seekExact(new BytesRef(id))) {
status = TermsEnum.SeekStatus.FOUND;
} else {
status = TermsEnum.SeekStatus.NOT_FOUND;
}
} else {
status = termsEnum.seekCeil(new BytesRef(id), useCache);
status = termsEnum.seekCeil(new BytesRef(id));
}
if (nextID != null) {

View File

@ -130,7 +130,7 @@ class DrillSidewaysQuery extends Query {
continue;
}
for(int i=0;i<drillDownTerms[dim].length;i++) {
if (termsEnum.seekExact(drillDownTerms[dim][i].bytes(), false)) {
if (termsEnum.seekExact(drillDownTerms[dim][i].bytes())) {
DocsEnum docsEnum = termsEnum.docs(null, null, 0);
if (docsEnum != null) {
dims[dim].docsEnums[i] = docsEnum;

View File

@ -428,7 +428,7 @@ public class DirectoryTaxonomyWriter implements TaxonomyWriter {
Terms terms = ctx.reader().terms(Consts.FULL);
if (terms != null) {
termsEnum = terms.iterator(termsEnum);
if (termsEnum.seekExact(catTerm, true)) {
if (termsEnum.seekExact(catTerm)) {
// liveDocs=null because the taxonomy has no deletes
docs = termsEnum.docs(null, docs, 0 /* freqs not required */);
// if the term was found, we know it has exactly one document.

View File

@ -90,7 +90,7 @@ public class FacetsPayloadMigrationReader extends FilterAtomicReader {
Terms terms = fields.terms(term.field());
if (terms != null) {
TermsEnum te = terms.iterator(null); // no use for reusing
if (te.seekExact(term.bytes(), true)) {
if (te.seekExact(term.bytes())) {
// we're not expected to be called for deleted documents
dpe = te.docsAndPositions(null, null, DocsAndPositionsEnum.FLAG_PAYLOADS);
}

View File

@ -303,7 +303,7 @@ public abstract class TermGroupFacetCollector extends AbstractGroupFacetCollecto
int facetOrd;
if (groupedFacetHit.facetValue != null) {
if (facetOrdTermsEnum == null || !facetOrdTermsEnum.seekExact(groupedFacetHit.facetValue, true)) {
if (facetOrdTermsEnum == null || !facetOrdTermsEnum.seekExact(groupedFacetHit.facetValue)) {
continue;
}
facetOrd = (int) facetOrdTermsEnum.ord();
@ -319,7 +319,7 @@ public abstract class TermGroupFacetCollector extends AbstractGroupFacetCollecto
if (facetPrefix != null) {
TermsEnum.SeekStatus seekStatus;
if (facetOrdTermsEnum != null) {
seekStatus = facetOrdTermsEnum.seekCeil(facetPrefix, true);
seekStatus = facetOrdTermsEnum.seekCeil(facetPrefix);
} else {
seekStatus = TermsEnum.SeekStatus.END;
}
@ -334,7 +334,7 @@ public abstract class TermGroupFacetCollector extends AbstractGroupFacetCollecto
BytesRef facetEndPrefix = BytesRef.deepCopyOf(facetPrefix);
facetEndPrefix.append(UnicodeUtil.BIG_TERM);
seekStatus = facetOrdTermsEnum.seekCeil(facetEndPrefix, true);
seekStatus = facetOrdTermsEnum.seekCeil(facetEndPrefix);
if (seekStatus != TermsEnum.SeekStatus.END) {
endFacetOrd = (int) facetOrdTermsEnum.ord();
} else {

View File

@ -282,7 +282,7 @@ public class WeightedSpanTermExtractor {
TreeSet<Term> extractedTerms = new TreeSet<Term>();
q.extractTerms(extractedTerms);
for (Term term : extractedTerms) {
termContexts.put(term, TermContext.build(context, term, true));
termContexts.put(term, TermContext.build(context, term));
}
Bits acceptDocs = context.reader().getLiveDocs();
final Spans spans = q.getSpans(context, acceptDocs, termContexts);

View File

@ -459,7 +459,7 @@ public class PostingsHighlighter {
continue;
} else if (de == null) {
postings[i] = EMPTY; // initially
if (!termsEnum.seekExact(terms[i], true)) {
if (!termsEnum.seekExact(terms[i])) {
continue; // term not found
}
de = postings[i] = termsEnum.docsAndPositions(null, null, DocsAndPositionsEnum.FLAG_OFFSETS);

View File

@ -241,7 +241,7 @@ class TermsIncludingScoreQuery extends Query {
}
scoreUpto = upto;
if (termsEnum.seekExact(terms.get(ords[upto++], spare), true)) {
if (termsEnum.seekExact(terms.get(ords[upto++], spare))) {
docsEnum = reuse = termsEnum.docs(acceptDocs, reuse, DocsEnum.FLAG_NONE);
}
}
@ -337,7 +337,7 @@ class TermsIncludingScoreQuery extends Query {
BytesRef spare = new BytesRef();
DocsEnum docsEnum = null;
for (int i = 0; i < terms.size(); i++) {
if (termsEnum.seekExact(terms.get(ords[i], spare), true)) {
if (termsEnum.seekExact(terms.get(ords[i], spare))) {
docsEnum = termsEnum.docs(acceptDocs, docsEnum, DocsEnum.FLAG_NONE);
float score = TermsIncludingScoreQuery.this.scores[ords[i]];
for (int doc = docsEnum.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = docsEnum.nextDoc()) {
@ -393,7 +393,7 @@ class TermsIncludingScoreQuery extends Query {
BytesRef spare = new BytesRef();
DocsEnum docsEnum = null;
for (int i = 0; i < terms.size(); i++) {
if (termsEnum.seekExact(terms.get(ords[i], spare), true)) {
if (termsEnum.seekExact(terms.get(ords[i], spare))) {
docsEnum = termsEnum.docs(acceptDocs, docsEnum, DocsEnum.FLAG_NONE);
float score = TermsIncludingScoreQuery.this.scores[ords[i]];
for (int doc = docsEnum.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = docsEnum.nextDoc()) {

View File

@ -557,7 +557,7 @@ public class TestJoinUtil extends LuceneTestCase {
joinValues.addAll(joinValueToJoinScores.keySet());
for (BytesRef joinValue : joinValues) {
termsEnum = terms.iterator(termsEnum);
if (termsEnum.seekExact(joinValue, true)) {
if (termsEnum.seekExact(joinValue)) {
docsEnum = termsEnum.docs(slowCompositeReader.getLiveDocs(), docsEnum, DocsEnum.FLAG_NONE);
JoinScore joinScore = joinValueToJoinScores.get(joinValue);

View File

@ -885,13 +885,13 @@ public class MemoryIndex {
@Override
public boolean seekExact(BytesRef text, boolean useCache) {
public boolean seekExact(BytesRef text) {
termUpto = binarySearch(text, br, 0, info.terms.size()-1, info.terms, info.sortedTerms, BytesRef.getUTF8SortedAsUnicodeComparator());
return termUpto >= 0;
}
@Override
public SeekStatus seekCeil(BytesRef text, boolean useCache) {
public SeekStatus seekCeil(BytesRef text) {
termUpto = binarySearch(text, br, 0, info.terms.size()-1, info.terms, info.sortedTerms, BytesRef.getUTF8SortedAsUnicodeComparator());
if (termUpto < 0) { // not found; choose successor
termUpto = -termUpto-1;

View File

@ -327,7 +327,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
// now reuse and check again
TermsEnum te = reader.terms("foo").iterator(null);
assertTrue(te.seekExact(new BytesRef("bar"), true));
assertTrue(te.seekExact(new BytesRef("bar")));
disi = te.docs(null, disi, DocsEnum.FLAG_NONE);
docid = disi.docID();
assertEquals(-1, docid);
@ -361,7 +361,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
// now reuse and check again
TermsEnum te = reader.terms("foo").iterator(null);
assertTrue(te.seekExact(new BytesRef("bar"), true));
assertTrue(te.seekExact(new BytesRef("bar")));
disi = te.docsAndPositions(null, disi);
docid = disi.docID();
assertEquals(-1, docid);

View File

@ -246,7 +246,7 @@ public class CommonTermsQuery extends Query {
assert termsEnum != null;
if (termsEnum == TermsEnum.EMPTY) continue;
if (termsEnum.seekExact(term.bytes(), false)) {
if (termsEnum.seekExact(term.bytes())) {
if (termContext == null) {
contextArray[i] = new TermContext(reader.getContext(),
termsEnum.termState(), context.ord, termsEnum.docFreq(),

View File

@ -193,7 +193,7 @@ public final class TermsFilter extends Filter {
for (int i = termsAndField.start; i < termsAndField.end; i++) {
spare.offset = offsets[i];
spare.length = offsets[i+1] - offsets[i];
if (termsEnum.seekExact(spare, false)) { // don't use cache since we could pollute the cache here easily
if (termsEnum.seekExact(spare)) {
docs = termsEnum.docs(acceptDocs, docs, DocsEnum.FLAG_NONE); // no freq since we don't need them
if (result == null) {
if (docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {

View File

@ -69,7 +69,7 @@ public class JoinDocFreqValueSource extends FieldCacheSource {
{
try {
terms.get(doc, ref);
if (termsEnum.seekExact(ref, true)) {
if (termsEnum.seekExact(ref)) {
return termsEnum.docFreq();
} else {
return 0;

View File

@ -67,7 +67,7 @@ public class TFValueSource extends TermFreqValueSource {
if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(indexedBytes, false)) {
if (termsEnum.seekExact(indexedBytes)) {
docs = termsEnum.docs(null, null);
} else {
docs = null;

View File

@ -60,7 +60,7 @@ public class TermFreqValueSource extends DocFreqValueSource {
if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(indexedBytes, false)) {
if (termsEnum.seekExact(indexedBytes)) {
docs = termsEnum.docs(null, null);
} else {
docs = null;

View File

@ -171,11 +171,11 @@ public abstract class AbstractVisitingPrefixTreeFilter extends AbstractPrefixTre
int compare = termsEnum.getComparator().compare(thisTerm, curVNodeTerm);
if (compare > 0) {
// leap frog (termsEnum is beyond where we would otherwise seek)
assert ! context.reader().terms(fieldName).iterator(null).seekExact(curVNodeTerm, false) : "should be absent";
assert ! context.reader().terms(fieldName).iterator(null).seekExact(curVNodeTerm) : "should be absent";
} else {
if (compare < 0) {
// Seek !
TermsEnum.SeekStatus seekStatus = termsEnum.seekCeil(curVNodeTerm, true);
TermsEnum.SeekStatus seekStatus = termsEnum.seekCeil(curVNodeTerm);
if (seekStatus == TermsEnum.SeekStatus.END)
break; // all done
thisTerm = termsEnum.term();

View File

@ -134,7 +134,7 @@ public class ContainsPrefixTreeFilter extends AbstractPrefixTreeFilter {
termBytes.bytes = cell.getTokenBytes();
termBytes.length = termBytes.bytes.length;
return termsEnum.seekExact(termBytes, cell.getLevel() <= 2);
return termsEnum.seekExact(termBytes);
}
private SmallDocSet getDocs(Cell cell, Bits acceptContains) throws IOException {

View File

@ -525,7 +525,7 @@ public class SpellChecker implements java.io.Closeable {
if (!isEmpty) {
for (TermsEnum te : termsEnums) {
if (te.seekExact(currentTerm, false)) {
if (te.seekExact(currentTerm)) {
continue terms;
}
}

View File

@ -87,8 +87,6 @@ public final class Lucene41WithOrds extends PostingsFormat {
}
}
public final static int TERMS_CACHE_SIZE = 1024;
@Override
public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException {
PostingsReaderBase postings = new Lucene41PostingsReader(state.directory, state.fieldInfos, state.segmentInfo, state.context, state.segmentSuffix);
@ -117,7 +115,6 @@ public final class Lucene41WithOrds extends PostingsFormat {
state.segmentInfo,
postings,
state.context,
TERMS_CACHE_SIZE,
state.segmentSuffix);
success = true;
return ret;

View File

@ -187,7 +187,6 @@ public final class MockFixedIntBlockPostingsFormat extends PostingsFormat {
state.segmentInfo,
postingsReader,
state.context,
1024,
state.segmentSuffix);
success = true;
return ret;

View File

@ -212,7 +212,6 @@ public final class MockVariableIntBlockPostingsFormat extends PostingsFormat {
state.segmentInfo,
postingsReader,
state.context,
1024,
state.segmentSuffix);
success = true;
return ret;

View File

@ -400,8 +400,6 @@ public final class MockRandomPostingsFormat extends PostingsFormat {
}
}
final int termsCacheSize = _TestUtil.nextInt(random, 1, 1024);
success = false;
try {
fields = new BlockTermsReader(indexReader,
@ -410,7 +408,6 @@ public final class MockRandomPostingsFormat extends PostingsFormat {
state.segmentInfo,
postingsReader,
state.context,
termsCacheSize,
state.segmentSuffix);
success = true;
} finally {

View File

@ -110,7 +110,6 @@ public final class MockSepPostingsFormat extends PostingsFormat {
state.segmentInfo,
postingsReader,
state.context,
1024,
state.segmentSuffix);
success = true;
return ret;

View File

@ -336,7 +336,7 @@ public final class RAMOnlyPostingsFormat extends PostingsFormat {
}
@Override
public SeekStatus seekCeil(BytesRef term, boolean useCache) {
public SeekStatus seekCeil(BytesRef term) {
current = term.utf8ToString();
it = null;
if (ramField.termToDocs.containsKey(current)) {

View File

@ -185,9 +185,9 @@ public class AssertingAtomicReader extends FilterAtomicReader {
}
@Override
public SeekStatus seekCeil(BytesRef term, boolean useCache) throws IOException {
public SeekStatus seekCeil(BytesRef term) throws IOException {
assert term.isValid();
SeekStatus result = super.seekCeil(term, useCache);
SeekStatus result = super.seekCeil(term);
if (result == SeekStatus.END) {
state = State.UNPOSITIONED;
} else {
@ -197,9 +197,9 @@ public class AssertingAtomicReader extends FilterAtomicReader {
}
@Override
public boolean seekExact(BytesRef text, boolean useCache) throws IOException {
public boolean seekExact(BytesRef text) throws IOException {
assert text.isValid();
if (super.seekExact(text, useCache)) {
if (super.seekExact(text)) {
state = State.POSITIONED;
return true;
} else {

View File

@ -746,16 +746,16 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase {
assertEquals(SeekStatus.END, termsEnum.seekCeil(new BytesRef("zzz")));
// seekExact()
assertTrue(termsEnum.seekExact(new BytesRef("beer"), true));
assertTrue(termsEnum.seekExact(new BytesRef("beer")));
assertEquals("beer", termsEnum.term().utf8ToString());
assertEquals(0, termsEnum.ord());
assertTrue(termsEnum.seekExact(new BytesRef("hello"), true));
assertTrue(termsEnum.seekExact(new BytesRef("hello")));
assertEquals(Codec.getDefault().toString(), "hello", termsEnum.term().utf8ToString());
assertEquals(1, termsEnum.ord());
assertTrue(termsEnum.seekExact(new BytesRef("world"), true));
assertTrue(termsEnum.seekExact(new BytesRef("world")));
assertEquals("world", termsEnum.term().utf8ToString());
assertEquals(2, termsEnum.ord());
assertFalse(termsEnum.seekExact(new BytesRef("bogus"), true));
assertFalse(termsEnum.seekExact(new BytesRef("bogus")));
// seek(ord)
termsEnum.seekExact(0);
@ -1788,16 +1788,16 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase {
assertEquals(SeekStatus.END, termsEnum.seekCeil(new BytesRef("zzz")));
// seekExact()
assertTrue(termsEnum.seekExact(new BytesRef("beer"), true));
assertTrue(termsEnum.seekExact(new BytesRef("beer")));
assertEquals("beer", termsEnum.term().utf8ToString());
assertEquals(0, termsEnum.ord());
assertTrue(termsEnum.seekExact(new BytesRef("hello"), true));
assertTrue(termsEnum.seekExact(new BytesRef("hello")));
assertEquals("hello", termsEnum.term().utf8ToString());
assertEquals(1, termsEnum.ord());
assertTrue(termsEnum.seekExact(new BytesRef("world"), true));
assertTrue(termsEnum.seekExact(new BytesRef("world")));
assertEquals("world", termsEnum.term().utf8ToString());
assertEquals(2, termsEnum.ord());
assertFalse(termsEnum.seekExact(new BytesRef("bogus"), true));
assertFalse(termsEnum.seekExact(new BytesRef("bogus")));
// seek(ord)
termsEnum.seekExact(0);

View File

@ -983,7 +983,7 @@ public abstract class BasePostingsFormatTestCase extends LuceneTestCase {
termsEnum = terms.iterator(null);
if (!useTermState) {
assertTrue(termsEnum.seekExact(fieldAndTerm.term, true));
assertTrue(termsEnum.seekExact(fieldAndTerm.term));
} else {
termsEnum.seekExact(fieldAndTerm.term, termState);
}

View File

@ -500,9 +500,9 @@ public abstract class BaseTermVectorsFormatTestCase extends LuceneTestCase {
assertNull(termsEnum.next());
for (int i = 0; i < 5; ++i) {
if (random().nextBoolean()) {
assertTrue(termsEnum.seekExact(RandomPicks.randomFrom(random(), tk.termBytes), random().nextBoolean()));
assertTrue(termsEnum.seekExact(RandomPicks.randomFrom(random(), tk.termBytes)));
} else {
assertEquals(SeekStatus.FOUND, termsEnum.seekCeil(RandomPicks.randomFrom(random(), tk.termBytes), random().nextBoolean()));
assertEquals(SeekStatus.FOUND, termsEnum.seekCeil(RandomPicks.randomFrom(random(), tk.termBytes)));
}
}
}

View File

@ -185,7 +185,7 @@ public abstract class ShardSearchingTestBase extends LuceneTestCase {
}
try {
for(Term term : terms) {
final TermContext termContext = TermContext.build(s.getIndexReader().getContext(), term, false);
final TermContext termContext = TermContext.build(s.getIndexReader().getContext(), term);
stats.put(term, s.termStatistics(term, termContext));
}
} finally {

View File

@ -1751,14 +1751,13 @@ public abstract class LuceneTestCase extends Assert {
rightEnum = rightTerms.iterator(rightEnum);
}
final boolean useCache = random().nextBoolean();
final boolean seekExact = random().nextBoolean();
if (seekExact) {
assertEquals(info, leftEnum.seekExact(b, useCache), rightEnum.seekExact(b, useCache));
assertEquals(info, leftEnum.seekExact(b), rightEnum.seekExact(b));
} else {
SeekStatus leftStatus = leftEnum.seekCeil(b, useCache);
SeekStatus rightStatus = rightEnum.seekCeil(b, useCache);
SeekStatus leftStatus = leftEnum.seekCeil(b);
SeekStatus rightStatus = rightEnum.seekCeil(b);
assertEquals(info, leftStatus, rightStatus);
if (leftStatus != SeekStatus.END) {
assertEquals(info, leftEnum.term(), rightEnum.term());

View File

@ -928,7 +928,7 @@ public class _TestUtil {
return null;
}
final TermsEnum termsEnum = terms.iterator(null);
if (!termsEnum.seekExact(term, random.nextBoolean())) {
if (!termsEnum.seekExact(term)) {
return null;
}
return docs(random, termsEnum, liveDocs, reuse, flags);

View File

@ -562,7 +562,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
for (String id : elevations.ids) {
term.copyChars(id);
if (seen.contains(id) == false && termsEnum.seekExact(term, false)) {
if (seen.contains(id) == false && termsEnum.seekExact(term)) {
docsEnum = termsEnum.docs(liveDocs, docsEnum, DocsEnum.FLAG_NONE);
if (docsEnum != null) {
int docId = docsEnum.nextDoc();

View File

@ -163,7 +163,7 @@ public class TermsComponent extends SearchComponent {
BytesRef term = null;
if (lowerBytes != null) {
if (termsEnum.seekCeil(lowerBytes, true) == TermsEnum.SeekStatus.END) {
if (termsEnum.seekCeil(lowerBytes) == TermsEnum.SeekStatus.END) {
termsEnum = null;
} else {
term = termsEnum.term();

View File

@ -768,7 +768,7 @@ public class SimpleFacets {
// facet.offset when sorting by index order.
if (startTermBytes != null) {
if (termsEnum.seekCeil(startTermBytes, true) == TermsEnum.SeekStatus.END) {
if (termsEnum.seekCeil(startTermBytes) == TermsEnum.SeekStatus.END) {
termsEnum = null;
} else {
term = termsEnum.term();

View File

@ -231,13 +231,13 @@ public class UnInvertedField extends DocTermOrds {
TermsEnum te = getOrdTermsEnum(searcher.getAtomicReader());
if (te != null && prefix != null && prefix.length() > 0) {
final BytesRef prefixBr = new BytesRef(prefix);
if (te.seekCeil(prefixBr, true) == TermsEnum.SeekStatus.END) {
if (te.seekCeil(prefixBr) == TermsEnum.SeekStatus.END) {
startTerm = numTermsInField;
} else {
startTerm = (int) te.ord();
}
prefixBr.append(UnicodeUtil.BIG_TERM);
if (te.seekCeil(prefixBr, true) == TermsEnum.SeekStatus.END) {
if (te.seekCeil(prefixBr) == TermsEnum.SeekStatus.END) {
endTerm = numTermsInField;
} else {
endTerm = (int) te.ord();

View File

@ -309,7 +309,7 @@ class JoinQuery extends Query {
if (prefix == null) {
term = termsEnum.next();
} else {
if (termsEnum.seekCeil(prefix, true) != TermsEnum.SeekStatus.END) {
if (termsEnum.seekCeil(prefix) != TermsEnum.SeekStatus.END) {
term = termsEnum.term();
}
}

View File

@ -718,7 +718,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
if (terms == null) return -1;
BytesRef termBytes = t.bytes();
final TermsEnum termsEnum = terms.iterator(null);
if (!termsEnum.seekExact(termBytes, false)) {
if (!termsEnum.seekExact(termBytes)) {
return -1;
}
DocsEnum docs = termsEnum.docs(atomicReader.getLiveDocs(), null, DocsEnum.FLAG_NONE);
@ -742,7 +742,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
if (terms == null) continue;
TermsEnum te = terms.iterator(null);
if (te.seekExact(idBytes, true)) {
if (te.seekExact(idBytes)) {
DocsEnum docs = te.docs(reader.getLiveDocs(), null, DocsEnum.FLAG_NONE);
int id = docs.nextDoc();
if (id == DocIdSetIterator.NO_MORE_DOCS) continue;

View File

@ -297,7 +297,7 @@ public class FileFloatSource extends ValueSource {
continue; // go to next line in file.. leave values as default.
}
if (!termsEnum.seekExact(internalKey, false)) {
if (!termsEnum.seekExact(internalKey)) {
if (notFoundCount<10) { // collect first 10 not found for logging
notFound.add(key);
}

View File

@ -112,7 +112,7 @@ public class TestFaceting extends SolrTestCaseJ4 {
// test seeking before term
if (size>0) {
assertEquals(size>0, te.seekCeil(new BytesRef("000"), true) != TermsEnum.SeekStatus.END);
assertEquals(size>0, te.seekCeil(new BytesRef("000")) != TermsEnum.SeekStatus.END);
assertEquals(0, te.ord());
assertEquals(t(0), te.term().utf8ToString());
}

View File

@ -132,7 +132,7 @@ public class TestRTGBase extends SolrTestCaseJ4 {
if (terms == null) return -1;
BytesRef termBytes = t.bytes();
final TermsEnum termsEnum = terms.iterator(null);
if (!termsEnum.seekExact(termBytes, false)) {
if (!termsEnum.seekExact(termBytes)) {
return -1;
}
DocsEnum docs = termsEnum.docs(MultiFields.getLiveDocs(r), null, DocsEnum.FLAG_NONE);