mirror of https://github.com/apache/lucene.git
LUCENE-2075: fix false trip in assert, when comparing two TermInfos
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@885028 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f0e064eb41
commit
c0c5b9c2f0
|
@ -42,28 +42,6 @@ class TermInfo {
|
||||||
skipOffset = ti.skipOffset;
|
skipOffset = ti.skipOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj instanceof TermInfo) {
|
|
||||||
TermInfo other = (TermInfo) obj;
|
|
||||||
return other.docFreq == docFreq &&
|
|
||||||
other.freqPointer == freqPointer &&
|
|
||||||
other.proxPointer == proxPointer &&
|
|
||||||
other.skipOffset == skipOffset;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode() {
|
|
||||||
final int PRIME = 17;
|
|
||||||
int result = 1;
|
|
||||||
result = PRIME * result + docFreq;
|
|
||||||
result = (int) (PRIME * result + freqPointer);
|
|
||||||
result = (int) (PRIME * result + proxPointer);
|
|
||||||
result = (int) (PRIME * result + skipOffset);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
final void set(int docFreq,
|
final void set(int docFreq,
|
||||||
long freqPointer, long proxPointer, int skipOffset) {
|
long freqPointer, long proxPointer, int skipOffset) {
|
||||||
this.docFreq = docFreq;
|
this.docFreq = docFreq;
|
||||||
|
|
|
@ -223,7 +223,7 @@ final class TermInfosReader {
|
||||||
if (tiOrd == null) {
|
if (tiOrd == null) {
|
||||||
termsCache.put(term, new TermInfoAndOrd(ti, (int) enumerator.position));
|
termsCache.put(term, new TermInfoAndOrd(ti, (int) enumerator.position));
|
||||||
} else {
|
} else {
|
||||||
assert ti.equals(tiOrd);
|
assert sameTermInfo(ti, tiOrd, enumerator);
|
||||||
assert (int) enumerator.position == tiOrd.termOrd;
|
assert (int) enumerator.position == tiOrd.termOrd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ final class TermInfosReader {
|
||||||
if (tiOrd == null) {
|
if (tiOrd == null) {
|
||||||
termsCache.put(term, new TermInfoAndOrd(ti, (int) enumerator.position));
|
termsCache.put(term, new TermInfoAndOrd(ti, (int) enumerator.position));
|
||||||
} else {
|
} else {
|
||||||
assert ti.equals(tiOrd);
|
assert sameTermInfo(ti, tiOrd, enumerator);
|
||||||
assert (int) enumerator.position == tiOrd.termOrd;
|
assert (int) enumerator.position == tiOrd.termOrd;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -261,6 +261,25 @@ final class TermInfosReader {
|
||||||
return ti;
|
return ti;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// called only from asserts
|
||||||
|
private final boolean sameTermInfo(TermInfo ti1, TermInfo ti2, SegmentTermEnum enumerator) {
|
||||||
|
if (ti1.docFreq != ti2.docFreq) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ti1.freqPointer != ti2.freqPointer) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ti1.proxPointer != ti2.proxPointer) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// skipOffset is only valid when docFreq >= skipInterval:
|
||||||
|
if (ti1.docFreq >= enumerator.skipInterval &&
|
||||||
|
ti1.skipOffset != ti2.skipOffset) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the nth term in the set. */
|
/** Returns the nth term in the set. */
|
||||||
final Term get(int position) throws IOException {
|
final Term get(int position) throws IOException {
|
||||||
if (size == 0) return null;
|
if (size == 0) return null;
|
||||||
|
|
Loading…
Reference in New Issue