LUCENE-2631: fix small perf issues with String/TermOrdValComparator

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@992571 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2010-09-04 09:49:18 +00:00
parent 6c9af51a92
commit 6ee1ac44ee
1 changed files with 22 additions and 15 deletions

View File

@ -731,10 +731,7 @@ public abstract class FieldComparator {
@Override
public int compare(int slot1, int slot2) {
if (readerGen[slot1] == readerGen[slot2]) {
int cmp = ords[slot1] - ords[slot2];
if (cmp != 0) {
return cmp;
}
return ords[slot1] - ords[slot2];
}
final BytesRef val1 = values[slot1];
@ -786,6 +783,7 @@ public abstract class FieldComparator {
public void copy(int slot, int doc) {
final int ord = (int) currentDocToOrd.get(doc);
if (ord == 0) {
ords[slot] = 0;
values[slot] = null;
} else {
ords[slot] = ord;
@ -813,22 +811,31 @@ public abstract class FieldComparator {
bottomSlot = bottom;
bottomValue = values[bottomSlot];
if (bottomValue == null) {
// 0 ord is null for all segments
assert ords[bottomSlot] == 0;
bottomOrd = 0;
if (currentReaderGen == readerGen[bottomSlot]) {
bottomOrd = ords[bottomSlot];
bottomSameReader = true;
} else {
final int index = binarySearch(tempBR, termsIndex, bottomValue);
if (index < 0) {
bottomOrd = -index - 2;
bottomSameReader = false;
} else {
bottomOrd = index;
// exact value match
if (bottomValue == null) {
// 0 ord is null for all segments
assert ords[bottomSlot] == 0;
bottomOrd = 0;
bottomSameReader = true;
readerGen[bottomSlot] = currentReaderGen;
} else {
final int index = binarySearch(tempBR, termsIndex, bottomValue);
if (index < 0) {
bottomOrd = -index - 2;
bottomSameReader = false;
} else {
bottomOrd = index;
// exact value match
bottomSameReader = true;
}
}
}
if (bottomSameReader) {
readerGen[bottomSlot] = currentReaderGen;
}
}
@Override