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);
|
||||
}
|
||||
|
||||
//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
|
||||
Cell nextCell;//see getLeafDocs
|
||||
|
||||
|
@ -135,21 +136,24 @@ public class ContainsPrefixTreeFilter extends AbstractPrefixTreeFilter {
|
|||
if (termsEnum == null)
|
||||
return false;
|
||||
termBytes = cell.getTokenBytesNoLeaf(termBytes);
|
||||
assert assertCloneTermBytes(); //assertions look at termBytes later on
|
||||
return termsEnum.seekExact(termBytes);
|
||||
}
|
||||
|
||||
private boolean assertCloneTermBytes() {
|
||||
termBytes = BytesRef.deepCopyOf(termBytes);
|
||||
return true;
|
||||
}
|
||||
|
||||
private SmallDocSet getDocs(Cell cell, Bits acceptContains) throws IOException {
|
||||
assert cell.getTokenBytesNoLeaf(null).equals(termBytes);
|
||||
|
||||
return collectDocs(acceptContains);
|
||||
}
|
||||
|
||||
private Cell lastLeaf = null;//just for assertion
|
||||
|
||||
private SmallDocSet getLeafDocs(Cell leafCell, Bits acceptContains) throws IOException {
|
||||
assert leafCell.getTokenBytesNoLeaf(null).equals(termBytes);
|
||||
assert ! leafCell.equals(lastLeaf);//don't call for same leaf again
|
||||
lastLeaf = leafCell;
|
||||
/** 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 {
|
||||
assert cell.getTokenBytesNoLeaf(null).equals(termBytes);
|
||||
|
||||
if (termsEnum == null)
|
||||
return null;
|
||||
|
@ -159,8 +163,8 @@ public class ContainsPrefixTreeFilter extends AbstractPrefixTreeFilter {
|
|||
return null;
|
||||
}
|
||||
nextCell = grid.readCell(nextTerm, nextCell);
|
||||
assert leafCell.isPrefixOf(nextCell);
|
||||
if (nextCell.getLevel() == leafCell.getLevel() && nextCell.isLeaf()) {
|
||||
assert cell.isPrefixOf(nextCell);
|
||||
if (nextCell.getLevel() == cell.getLevel() && nextCell.isLeaf()) {
|
||||
return collectDocs(acceptContains);
|
||||
} else {
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue