mirror of https://github.com/apache/lucene.git
LUCENE-5608 fix assertions given that tokens are re-used
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1594391 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f0001135dc
commit
6f92315865
|
@ -83,6 +83,7 @@ public class ContainsPrefixTreeFilter extends AbstractPrefixTreeFilter {
|
||||||
super(context, acceptDocs);
|
super(context, acceptDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//The reused value of cell.getTokenBytesNoLeaf which is always then seek()'ed to. It's used in assertions too.
|
||||||
BytesRef termBytes = new BytesRef();//no leaf
|
BytesRef termBytes = new BytesRef();//no leaf
|
||||||
Cell nextCell;//see getLeafDocs
|
Cell nextCell;//see getLeafDocs
|
||||||
|
|
||||||
|
@ -135,21 +136,24 @@ public class ContainsPrefixTreeFilter extends AbstractPrefixTreeFilter {
|
||||||
if (termsEnum == null)
|
if (termsEnum == null)
|
||||||
return false;
|
return false;
|
||||||
termBytes = cell.getTokenBytesNoLeaf(termBytes);
|
termBytes = cell.getTokenBytesNoLeaf(termBytes);
|
||||||
|
assert assertCloneTermBytes(); //assertions look at termBytes later on
|
||||||
return termsEnum.seekExact(termBytes);
|
return termsEnum.seekExact(termBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean assertCloneTermBytes() {
|
||||||
|
termBytes = BytesRef.deepCopyOf(termBytes);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private SmallDocSet getDocs(Cell cell, Bits acceptContains) throws IOException {
|
private SmallDocSet getDocs(Cell cell, Bits acceptContains) throws IOException {
|
||||||
assert cell.getTokenBytesNoLeaf(null).equals(termBytes);
|
assert cell.getTokenBytesNoLeaf(null).equals(termBytes);
|
||||||
|
|
||||||
return collectDocs(acceptContains);
|
return collectDocs(acceptContains);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Cell lastLeaf = null;//just for assertion
|
/** Gets docs on the leaf of the given cell, _if_ there is a leaf cell, otherwise null. */
|
||||||
|
private SmallDocSet getLeafDocs(Cell cell, Bits acceptContains) throws IOException {
|
||||||
private SmallDocSet getLeafDocs(Cell leafCell, Bits acceptContains) throws IOException {
|
assert cell.getTokenBytesNoLeaf(null).equals(termBytes);
|
||||||
assert leafCell.getTokenBytesNoLeaf(null).equals(termBytes);
|
|
||||||
assert ! leafCell.equals(lastLeaf);//don't call for same leaf again
|
|
||||||
lastLeaf = leafCell;
|
|
||||||
|
|
||||||
if (termsEnum == null)
|
if (termsEnum == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -159,8 +163,8 @@ public class ContainsPrefixTreeFilter extends AbstractPrefixTreeFilter {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
nextCell = grid.readCell(nextTerm, nextCell);
|
nextCell = grid.readCell(nextTerm, nextCell);
|
||||||
assert leafCell.isPrefixOf(nextCell);
|
assert cell.isPrefixOf(nextCell);
|
||||||
if (nextCell.getLevel() == leafCell.getLevel() && nextCell.isLeaf()) {
|
if (nextCell.getLevel() == cell.getLevel() && nextCell.isLeaf()) {
|
||||||
return collectDocs(acceptContains);
|
return collectDocs(acceptContains);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue