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. * LUCENE-5094: Add ramBytesUsed() to MultiDocValues.OrdinalMap.
(Robert Muir) (Robert Muir)
* LUCENE-5114: Remove unused boolean useCache parameter from
TermsEnum.seekCeil and .seekExact (Mike McCandless)
======================= Lucene 4.4.0 ======================= ======================= Lucene 4.4.0 =======================
Changes in backwards compatibility policy 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>(); 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 // Reads the terms index
private TermsIndexReaderBase indexReader; private TermsIndexReaderBase indexReader;
@ -113,11 +110,10 @@ public class BlockTermsReader extends FieldsProducer {
// private String segment; // private String segment;
public BlockTermsReader(TermsIndexReaderBase indexReader, Directory dir, FieldInfos fieldInfos, SegmentInfo info, PostingsReaderBase postingsReader, IOContext context, public BlockTermsReader(TermsIndexReaderBase indexReader, Directory dir, FieldInfos fieldInfos, SegmentInfo info, PostingsReaderBase postingsReader, IOContext context,
int termsCacheSize, String segmentSuffix) String segmentSuffix)
throws IOException { throws IOException {
this.postingsReader = postingsReader; this.postingsReader = postingsReader;
termsCache = new DoubleBarrelLRUCache<FieldAndTerm,BlockTermState>(termsCacheSize);
// this.segment = segment; // this.segment = segment;
in = dir.openInput(IndexFileNames.segmentFileName(info.name, segmentSuffix, BlockTermsWriter.TERMS_EXTENSION), 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 // return NOT_FOUND so it's a waste for us to fill in
// the term that was actually NOT_FOUND // the term that was actually NOT_FOUND
@Override @Override
public SeekStatus seekCeil(final BytesRef target, final boolean useCache) throws IOException { public SeekStatus seekCeil(final BytesRef target) throws IOException {
if (indexEnum == null) { if (indexEnum == null) {
throw new IllegalStateException("terms index was not loaded"); 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 (didIndexNext) {
if (nextIndexTerm == null) { if (nextIndexTerm == null) {
//System.out.println(" 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; boolean doSeek = true;
// See if we can avoid seeking, because target term // 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 // Done! Exact match. Stop here, fill in
// real term, return FOUND. // real term, return FOUND.
//System.out.println(" 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; return SeekStatus.FOUND;
} else { } else {
//System.out.println(" NOT_FOUND"); //System.out.println(" NOT_FOUND");

View File

@ -331,7 +331,7 @@ public final class BloomFilteringPostingsFormat extends PostingsFormat {
} }
@Override @Override
public final boolean seekExact(BytesRef text, boolean useCache) public final boolean seekExact(BytesRef text)
throws IOException { throws IOException {
// The magical fail-fast speed up that is the entire point of all of // 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 // 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) { if (filter.contains(text) == ContainsResult.NO) {
return false; return false;
} }
return delegate().seekExact(text, useCache); return delegate().seekExact(text);
} }
@Override @Override
public final SeekStatus seekCeil(BytesRef text, boolean useCache) public final SeekStatus seekCeil(BytesRef text)
throws IOException { throws IOException {
return delegate().seekCeil(text, useCache); return delegate().seekCeil(text);
} }
@Override @Override

View File

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

View File

@ -654,7 +654,7 @@ public final class MemoryPostingsFormat extends PostingsFormat {
} }
@Override @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); //System.out.println("te.seekExact text=" + field.name + ":" + text.utf8ToString() + " this=" + this);
current = fstEnum.seekExact(text); current = fstEnum.seekExact(text);
didDecode = false; didDecode = false;
@ -662,7 +662,7 @@ public final class MemoryPostingsFormat extends PostingsFormat {
} }
@Override @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); //System.out.println("te.seek text=" + field.name + ":" + text.utf8ToString() + " this=" + this);
current = fstEnum.seekCeil(text); current = fstEnum.seekCeil(text);
if (current == null) { if (current == null) {

View File

@ -109,7 +109,7 @@ class SimpleTextFieldsReader extends FieldsProducer {
} }
@Override @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); final BytesRefFSTEnum.InputOutput<PairOutputs.Pair<Long,PairOutputs.Pair<Long,Long>>> result = fstEnum.seekExact(text);
if (result != null) { if (result != null) {
@ -125,7 +125,7 @@ class SimpleTextFieldsReader extends FieldsProducer {
} }
@Override @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()); //System.out.println("seek to text=" + text.utf8ToString());
final BytesRefFSTEnum.InputOutput<PairOutputs.Pair<Long,PairOutputs.Pair<Long,Long>>> result = fstEnum.seekCeil(text); 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 @Override
public SeekStatus seekCeil(BytesRef text, boolean useCache) throws IOException { public SeekStatus seekCeil(BytesRef text) throws IOException {
iterator = terms.tailMap(text).entrySet().iterator(); iterator = terms.tailMap(text).entrySet().iterator();
if (!iterator.hasNext()) { if (!iterator.hasNext()) {
return SeekStatus.END; return SeekStatus.END;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -154,7 +154,7 @@ public abstract class FilteredTermsEnum extends TermsEnum {
* support seeking. * support seeking.
*/ */
@Override @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"); throw new UnsupportedOperationException(getClass().getName()+" does not support seeking");
} }
@ -163,7 +163,7 @@ public abstract class FilteredTermsEnum extends TermsEnum {
* support seeking. * support seeking.
*/ */
@Override @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"); 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); //System.out.println(" seek to t=" + (t == null ? "null" : t.utf8ToString()) + " tenum=" + tenum);
// Make sure we always seek forward: // Make sure we always seek forward:
assert actualTerm == null || t == null || getComparator().compare(t, actualTerm) > 0: "curTerm=" + actualTerm + " seekTerm=" + t; 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 // no more terms to seek to or enum exhausted
//System.out.println(" return null"); //System.out.println(" return null");
return null; return null;

View File

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

View File

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

View File

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

View File

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

View File

@ -78,7 +78,7 @@ public final class TermContext {
* <p> * <p>
* Note: the given context must be a top-level context. * 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 { throws IOException {
assert context != null && context.isTopLevel; assert context != null && context.isTopLevel;
final String field = term.field(); final String field = term.field();
@ -92,7 +92,7 @@ public final class TermContext {
final Terms terms = fields.terms(field); final Terms terms = fields.terms(field);
if (terms != null) { if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null); final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(bytes, cache)) { if (termsEnum.seekExact(bytes)) {
final TermState termState = termsEnum.termState(); final TermState termState = termsEnum.termState();
//if (DEBUG) System.out.println(" found"); //if (DEBUG) System.out.println(" found");
perReaderTermState.register(termState, ctx.ord, termsEnum.docFreq(), termsEnum.totalTermFreq()); 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; import org.apache.lucene.util.BytesRefIterator;
/** Iterator to seek ({@link #seekCeil(BytesRef)}, {@link /** 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 * #next} terms to obtain frequency information ({@link
* #docFreq}), {@link DocsEnum} or {@link * #docFreq}), {@link DocsEnum} or {@link
* DocsAndPositionsEnum} for the current term ({@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 * true if the term is found. If this returns false, the
* enum is unpositioned. For some codecs, seekExact may * enum is unpositioned. For some codecs, seekExact may
* be substantially faster than {@link #seekCeil}. */ * be substantially faster than {@link #seekCeil}. */
public boolean seekExact(BytesRef text, boolean useCache) throws IOException { public boolean seekExact(BytesRef text) throws IOException {
return seekCeil(text, useCache) == SeekStatus.FOUND; 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 /** Seeks to the specified term, if it exists, or to the
* next (ceiling) term. Returns SeekStatus to * next (ceiling) term. Returns SeekStatus to
* indicate whether exact term was found, a different * indicate whether exact term was found, a different
* term was found, or EOF was hit. The target term may * term was found, or EOF was hit. The target term may
* be before or after the current term. If this returns * be before or after the current term. If this returns
* SeekStatus.END, the enum is unpositioned. */ * SeekStatus.END, the enum is unpositioned. */
public final SeekStatus seekCeil(BytesRef text) throws IOException { public abstract SeekStatus seekCeil(BytesRef text) throws IOException;
return seekCeil(text, true);
}
/** Seeks to the specified term by ordinal (position) as /** Seeks to the specified term by ordinal (position) as
* previously returned by {@link #ord}. The target ord * previously returned by {@link #ord}. The target ord
@ -117,7 +110,7 @@ public abstract class TermsEnum implements BytesRefIterator {
* @param state the {@link TermState} * @param state the {@link TermState}
* */ * */
public void seekExact(BytesRef term, TermState state) throws IOException { public void seekExact(BytesRef term, TermState state) throws IOException {
if (!seekExact(term, true)) { if (!seekExact(term)) {
throw new IllegalArgumentException("term=" + term + " does not exist"); 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() { public static final TermsEnum EMPTY = new TermsEnum() {
@Override @Override
public SeekStatus seekCeil(BytesRef term, boolean useCache) { return SeekStatus.END; } public SeekStatus seekCeil(BytesRef term) { return SeekStatus.END; }
@Override @Override
public void seekExact(long ord) {} public void seekExact(long ord) {}

View File

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

View File

@ -149,7 +149,7 @@ public class MultiPhraseQuery extends Query {
for (Term term: terms) { for (Term term: terms) {
TermContext termContext = termContexts.get(term); TermContext termContext = termContexts.get(term);
if (termContext == null) { if (termContext == null) {
termContext = TermContext.build(context, term, true); termContext = TermContext.build(context, term);
termContexts.put(term, termContext); termContexts.put(term, termContext);
} }
allTermStats.add(searcher.termStatistics(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.search.similarities.Similarity;
import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.Bits; import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.ToStringUtils; import org.apache.lucene.util.ToStringUtils;
/** A Query that matches documents containing a particular sequence of terms. /** 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()]; TermStatistics termStats[] = new TermStatistics[terms.size()];
for (int i = 0; i < terms.size(); i++) { for (int i = 0; i < terms.size(); i++) {
final Term term = terms.get(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]); termStats[i] = searcher.termStatistics(term, states[i]);
} }
stats = similarity.computeWeight(getBoost(), searcher.collectionStatistics(field), termStats); 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 // PhraseQuery on a field that did not index
// positions. // positions.
if (postingsEnum == null) { 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 // term does exist, but has no positions
throw new IllegalStateException("field \"" + t.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + t.text() + ")"); 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; final TermContext termState;
if (perReaderTermState == null || perReaderTermState.topReaderContext != context) { if (perReaderTermState == null || perReaderTermState.topReaderContext != context) {
// make TermQuery single-pass if we don't have a PRTS or if the context differs! // 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 { } else {
// PRTS was pre-build for this IS // PRTS was pre-build for this IS
termState = this.perReaderTermState; termState = this.perReaderTermState;

View File

@ -182,7 +182,7 @@ public class PayloadSpanUtil {
TreeSet<Term> terms = new TreeSet<Term>(); TreeSet<Term> terms = new TreeSet<Term>();
query.extractTerms(terms); query.extractTerms(terms);
for (Term term : 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()) { for (AtomicReaderContext atomicReaderContext : context.leaves()) {
final Spans spans = query.getSpans(atomicReaderContext, atomicReaderContext.reader().getLiveDocs(), termContexts); 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()); final Terms terms = fields.terms(term.field());
if (terms != null) { if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null); final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(term.bytes(), true)) { if (termsEnum.seekExact(term.bytes())) {
state = termsEnum.termState(); state = termsEnum.termState();
} else { } else {
state = null; state = null;

View File

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

View File

@ -162,7 +162,7 @@ public class TestReuseDocsEnum extends LuceneTestCase {
return null; return null;
} }
TermsEnum iterator = terms.iterator(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 iterator.docs(bits, null, random().nextBoolean() ? DocsEnum.FLAG_FREQS : DocsEnum.FLAG_NONE);
} }
return null; return null;

View File

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

View File

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

View File

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

View File

@ -70,7 +70,7 @@ public class TestPayloadsOnVectors extends LuceneTestCase {
Terms terms = reader.getTermVector(1, "field"); Terms terms = reader.getTermVector(1, "field");
assert terms != null; assert terms != null;
TermsEnum termsEnum = terms.iterator(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); DocsAndPositionsEnum de = termsEnum.docsAndPositions(null, null);
assertEquals(0, de.nextDoc()); assertEquals(0, de.nextDoc());
assertEquals(0, de.nextPosition()); assertEquals(0, de.nextPosition());
@ -112,7 +112,7 @@ public class TestPayloadsOnVectors extends LuceneTestCase {
Terms terms = reader.getTermVector(0, "field"); Terms terms = reader.getTermVector(0, "field");
assert terms != null; assert terms != null;
TermsEnum termsEnum = terms.iterator(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); DocsAndPositionsEnum de = termsEnum.docsAndPositions(null, null);
assertEquals(0, de.nextDoc()); assertEquals(0, de.nextDoc());
assertEquals(3, de.nextPosition()); assertEquals(3, de.nextPosition());

View File

@ -227,7 +227,7 @@ public class TestPerSegmentDeletes extends LuceneTestCase {
Fields fields = MultiFields.getFields(reader); Fields fields = MultiFields.getFields(reader);
Terms cterms = fields.terms(term.field); Terms cterms = fields.terms(term.field);
TermsEnum ctermsEnum = cterms.iterator(null); 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); DocsEnum docsEnum = _TestUtil.docs(random(), ctermsEnum, bits, null, DocsEnum.FLAG_NONE);
return toArray(docsEnum); return toArray(docsEnum);
} }

View File

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

View File

@ -354,7 +354,7 @@ public class TestStressIndexing2 extends LuceneTestCase {
} }
termDocs1 = _TestUtil.docs(random(), termsEnum, liveDocs1, termDocs1, DocsEnum.FLAG_NONE); 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); termDocs2 = _TestUtil.docs(random(), termsEnum2, liveDocs2, termDocs2, DocsEnum.FLAG_NONE);
} else { } else {
termDocs2 = null; termDocs2 = null;

View File

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

View File

@ -117,10 +117,10 @@ public class TestTermsEnum2 extends LuceneTestCase {
// term is accepted // term is accepted
if (random().nextBoolean()) { if (random().nextBoolean()) {
// seek exact // seek exact
assertTrue(te.seekExact(term, random().nextBoolean())); assertTrue(te.seekExact(term));
} else { } else {
// seek ceil // seek ceil
assertEquals(SeekStatus.FOUND, te.seekCeil(term, random().nextBoolean())); assertEquals(SeekStatus.FOUND, te.seekCeil(term));
assertEquals(term, te.term()); assertEquals(term, te.term());
} }
} }
@ -138,10 +138,10 @@ public class TestTermsEnum2 extends LuceneTestCase {
if (c == 0) { if (c == 0) {
assertEquals(term, te.next()); assertEquals(term, te.next());
} else if (c == 1) { } else if (c == 1) {
assertEquals(SeekStatus.FOUND, te.seekCeil(term, random().nextBoolean())); assertEquals(SeekStatus.FOUND, te.seekCeil(term));
assertEquals(term, te.term()); assertEquals(term, te.term());
} else { } 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) { if (ord >= 0) {
boolean success = ords.add(ord); boolean success = ords.add(ord);
assert success; // no dups 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, SimWeight w = weight.similarity.computeWeight(1f,
searcher.collectionStatistics("field"), searcher.collectionStatistics("field"),
searcher.termStatistics(term, context)); 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>(); TreeSet<Term> terms = new TreeSet<Term>();
query.extractTerms(terms); query.extractTerms(terms);
for (Term term : 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(); final List<AtomicReaderContext> leaves = topLevelReaderContext.leaves();
if(leaves.size() == 1) { 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; final TermsEnum.SeekStatus status;
if (nextID == null) { if (nextID == null) {
if (termsEnum.seekExact(new BytesRef(id), useCache)) { if (termsEnum.seekExact(new BytesRef(id))) {
status = TermsEnum.SeekStatus.FOUND; status = TermsEnum.SeekStatus.FOUND;
} else { } else {
status = TermsEnum.SeekStatus.NOT_FOUND; status = TermsEnum.SeekStatus.NOT_FOUND;
} }
} else { } else {
status = termsEnum.seekCeil(new BytesRef(id), useCache); status = termsEnum.seekCeil(new BytesRef(id));
} }
if (nextID != null) { if (nextID != null) {

View File

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

View File

@ -428,7 +428,7 @@ public class DirectoryTaxonomyWriter implements TaxonomyWriter {
Terms terms = ctx.reader().terms(Consts.FULL); Terms terms = ctx.reader().terms(Consts.FULL);
if (terms != null) { if (terms != null) {
termsEnum = terms.iterator(termsEnum); termsEnum = terms.iterator(termsEnum);
if (termsEnum.seekExact(catTerm, true)) { if (termsEnum.seekExact(catTerm)) {
// liveDocs=null because the taxonomy has no deletes // liveDocs=null because the taxonomy has no deletes
docs = termsEnum.docs(null, docs, 0 /* freqs not required */); docs = termsEnum.docs(null, docs, 0 /* freqs not required */);
// if the term was found, we know it has exactly one document. // 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()); Terms terms = fields.terms(term.field());
if (terms != null) { if (terms != null) {
TermsEnum te = terms.iterator(null); // no use for reusing 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 // we're not expected to be called for deleted documents
dpe = te.docsAndPositions(null, null, DocsAndPositionsEnum.FLAG_PAYLOADS); dpe = te.docsAndPositions(null, null, DocsAndPositionsEnum.FLAG_PAYLOADS);
} }

View File

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

View File

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

View File

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

View File

@ -241,7 +241,7 @@ class TermsIncludingScoreQuery extends Query {
} }
scoreUpto = upto; 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); docsEnum = reuse = termsEnum.docs(acceptDocs, reuse, DocsEnum.FLAG_NONE);
} }
} }
@ -337,7 +337,7 @@ class TermsIncludingScoreQuery extends Query {
BytesRef spare = new BytesRef(); BytesRef spare = new BytesRef();
DocsEnum docsEnum = null; DocsEnum docsEnum = null;
for (int i = 0; i < terms.size(); i++) { 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); docsEnum = termsEnum.docs(acceptDocs, docsEnum, DocsEnum.FLAG_NONE);
float score = TermsIncludingScoreQuery.this.scores[ords[i]]; float score = TermsIncludingScoreQuery.this.scores[ords[i]];
for (int doc = docsEnum.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = docsEnum.nextDoc()) { 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(); BytesRef spare = new BytesRef();
DocsEnum docsEnum = null; DocsEnum docsEnum = null;
for (int i = 0; i < terms.size(); i++) { 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); docsEnum = termsEnum.docs(acceptDocs, docsEnum, DocsEnum.FLAG_NONE);
float score = TermsIncludingScoreQuery.this.scores[ords[i]]; float score = TermsIncludingScoreQuery.this.scores[ords[i]];
for (int doc = docsEnum.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = docsEnum.nextDoc()) { 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()); joinValues.addAll(joinValueToJoinScores.keySet());
for (BytesRef joinValue : joinValues) { for (BytesRef joinValue : joinValues) {
termsEnum = terms.iterator(termsEnum); termsEnum = terms.iterator(termsEnum);
if (termsEnum.seekExact(joinValue, true)) { if (termsEnum.seekExact(joinValue)) {
docsEnum = termsEnum.docs(slowCompositeReader.getLiveDocs(), docsEnum, DocsEnum.FLAG_NONE); docsEnum = termsEnum.docs(slowCompositeReader.getLiveDocs(), docsEnum, DocsEnum.FLAG_NONE);
JoinScore joinScore = joinValueToJoinScores.get(joinValue); JoinScore joinScore = joinValueToJoinScores.get(joinValue);

View File

@ -885,13 +885,13 @@ public class MemoryIndex {
@Override @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()); termUpto = binarySearch(text, br, 0, info.terms.size()-1, info.terms, info.sortedTerms, BytesRef.getUTF8SortedAsUnicodeComparator());
return termUpto >= 0; return termUpto >= 0;
} }
@Override @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()); termUpto = binarySearch(text, br, 0, info.terms.size()-1, info.terms, info.sortedTerms, BytesRef.getUTF8SortedAsUnicodeComparator());
if (termUpto < 0) { // not found; choose successor if (termUpto < 0) { // not found; choose successor
termUpto = -termUpto-1; termUpto = -termUpto-1;

View File

@ -327,7 +327,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
// now reuse and check again // now reuse and check again
TermsEnum te = reader.terms("foo").iterator(null); 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); disi = te.docs(null, disi, DocsEnum.FLAG_NONE);
docid = disi.docID(); docid = disi.docID();
assertEquals(-1, docid); assertEquals(-1, docid);
@ -361,7 +361,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
// now reuse and check again // now reuse and check again
TermsEnum te = reader.terms("foo").iterator(null); 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); disi = te.docsAndPositions(null, disi);
docid = disi.docID(); docid = disi.docID();
assertEquals(-1, docid); assertEquals(-1, docid);

View File

@ -246,7 +246,7 @@ public class CommonTermsQuery extends Query {
assert termsEnum != null; assert termsEnum != null;
if (termsEnum == TermsEnum.EMPTY) continue; if (termsEnum == TermsEnum.EMPTY) continue;
if (termsEnum.seekExact(term.bytes(), false)) { if (termsEnum.seekExact(term.bytes())) {
if (termContext == null) { if (termContext == null) {
contextArray[i] = new TermContext(reader.getContext(), contextArray[i] = new TermContext(reader.getContext(),
termsEnum.termState(), context.ord, termsEnum.docFreq(), 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++) { for (int i = termsAndField.start; i < termsAndField.end; i++) {
spare.offset = offsets[i]; spare.offset = offsets[i];
spare.length = offsets[i+1] - 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 docs = termsEnum.docs(acceptDocs, docs, DocsEnum.FLAG_NONE); // no freq since we don't need them
if (result == null) { if (result == null) {
if (docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) { if (docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {

View File

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

View File

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

View File

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

View File

@ -171,11 +171,11 @@ public abstract class AbstractVisitingPrefixTreeFilter extends AbstractPrefixTre
int compare = termsEnum.getComparator().compare(thisTerm, curVNodeTerm); int compare = termsEnum.getComparator().compare(thisTerm, curVNodeTerm);
if (compare > 0) { if (compare > 0) {
// leap frog (termsEnum is beyond where we would otherwise seek) // 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 { } else {
if (compare < 0) { if (compare < 0) {
// Seek ! // Seek !
TermsEnum.SeekStatus seekStatus = termsEnum.seekCeil(curVNodeTerm, true); TermsEnum.SeekStatus seekStatus = termsEnum.seekCeil(curVNodeTerm);
if (seekStatus == TermsEnum.SeekStatus.END) if (seekStatus == TermsEnum.SeekStatus.END)
break; // all done break; // all done
thisTerm = termsEnum.term(); thisTerm = termsEnum.term();

View File

@ -134,7 +134,7 @@ public class ContainsPrefixTreeFilter extends AbstractPrefixTreeFilter {
termBytes.bytes = cell.getTokenBytes(); termBytes.bytes = cell.getTokenBytes();
termBytes.length = termBytes.bytes.length; 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 { private SmallDocSet getDocs(Cell cell, Bits acceptContains) throws IOException {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -500,9 +500,9 @@ public abstract class BaseTermVectorsFormatTestCase extends LuceneTestCase {
assertNull(termsEnum.next()); assertNull(termsEnum.next());
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
if (random().nextBoolean()) { if (random().nextBoolean()) {
assertTrue(termsEnum.seekExact(RandomPicks.randomFrom(random(), tk.termBytes), random().nextBoolean())); assertTrue(termsEnum.seekExact(RandomPicks.randomFrom(random(), tk.termBytes)));
} else { } 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 { try {
for(Term term : terms) { 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)); stats.put(term, s.termStatistics(term, termContext));
} }
} finally { } finally {

View File

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

View File

@ -928,7 +928,7 @@ public class _TestUtil {
return null; return null;
} }
final TermsEnum termsEnum = terms.iterator(null); final TermsEnum termsEnum = terms.iterator(null);
if (!termsEnum.seekExact(term, random.nextBoolean())) { if (!termsEnum.seekExact(term)) {
return null; return null;
} }
return docs(random, termsEnum, liveDocs, reuse, flags); 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) { for (String id : elevations.ids) {
term.copyChars(id); 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); docsEnum = termsEnum.docs(liveDocs, docsEnum, DocsEnum.FLAG_NONE);
if (docsEnum != null) { if (docsEnum != null) {
int docId = docsEnum.nextDoc(); int docId = docsEnum.nextDoc();

View File

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

View File

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

View File

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

View File

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

View File

@ -718,7 +718,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
if (terms == null) return -1; if (terms == null) return -1;
BytesRef termBytes = t.bytes(); BytesRef termBytes = t.bytes();
final TermsEnum termsEnum = terms.iterator(null); final TermsEnum termsEnum = terms.iterator(null);
if (!termsEnum.seekExact(termBytes, false)) { if (!termsEnum.seekExact(termBytes)) {
return -1; return -1;
} }
DocsEnum docs = termsEnum.docs(atomicReader.getLiveDocs(), null, DocsEnum.FLAG_NONE); 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; if (terms == null) continue;
TermsEnum te = terms.iterator(null); TermsEnum te = terms.iterator(null);
if (te.seekExact(idBytes, true)) { if (te.seekExact(idBytes)) {
DocsEnum docs = te.docs(reader.getLiveDocs(), null, DocsEnum.FLAG_NONE); DocsEnum docs = te.docs(reader.getLiveDocs(), null, DocsEnum.FLAG_NONE);
int id = docs.nextDoc(); int id = docs.nextDoc();
if (id == DocIdSetIterator.NO_MORE_DOCS) continue; 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. 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 if (notFoundCount<10) { // collect first 10 not found for logging
notFound.add(key); notFound.add(key);
} }

View File

@ -112,7 +112,7 @@ public class TestFaceting extends SolrTestCaseJ4 {
// test seeking before term // test seeking before term
if (size>0) { 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(0, te.ord());
assertEquals(t(0), te.term().utf8ToString()); assertEquals(t(0), te.term().utf8ToString());
} }

View File

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