mirror of https://github.com/apache/lucene.git
don't don binary search in two places
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1433362 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
09d19ac341
commit
1e29841a26
|
@ -52,30 +52,23 @@ public abstract class SortedDocValues extends BinaryDocValues {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SeekStatus seekCeil(BytesRef text, boolean useCache /* ignored */) throws IOException {
|
public SeekStatus seekCeil(BytesRef text, boolean useCache /* ignored */) throws IOException {
|
||||||
int low = 0;
|
int ord = lookupTerm(text, term);
|
||||||
int high = getValueCount()-1;
|
if (ord > 0) {
|
||||||
|
currentOrd = ord;
|
||||||
while (low <= high) {
|
term.offset = 0;
|
||||||
int mid = (low + high) >>> 1;
|
term.copyBytes(text);
|
||||||
seekExact(mid);
|
return SeekStatus.FOUND;
|
||||||
int cmp = term.compareTo(text);
|
} else {
|
||||||
|
currentOrd = -ord-1;
|
||||||
if (cmp < 0)
|
if (currentOrd == getValueCount()) {
|
||||||
low = mid + 1;
|
|
||||||
else if (cmp > 0)
|
|
||||||
high = mid - 1;
|
|
||||||
else {
|
|
||||||
return SeekStatus.FOUND; // key found
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (low == getValueCount()) {
|
|
||||||
return SeekStatus.END;
|
return SeekStatus.END;
|
||||||
} else {
|
} else {
|
||||||
seekExact(low);
|
// nocommit hmm can we avoid this "extra" lookup?:
|
||||||
|
lookupOrd(currentOrd, term);
|
||||||
return SeekStatus.NOT_FOUND;
|
return SeekStatus.NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekExact(long ord) throws IOException {
|
public void seekExact(long ord) throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue