LUCENE-4599: fix Compressing vectors to not return a docsAndPositions when it has no prox

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1436765 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-01-22 06:51:45 +00:00
parent 5837fe83bd
commit 27de783467
2 changed files with 12 additions and 16 deletions

View File

@ -873,22 +873,7 @@ public final class CompressingTermVectorsReader extends TermVectorsReader implem
}
@Override
public DocsEnum docs(Bits liveDocs, DocsEnum reuse, int flags)
throws IOException {
return docsAndPositions(liveDocs, reuse, flags);
}
@Override
public DocsAndPositionsEnum docsAndPositions(Bits liveDocs,
DocsAndPositionsEnum reuse, int flags) throws IOException {
if ((flags & POSITIONS) == 0 && (flags & OFFSETS) == 0) {
return null;
}
return docsAndPositions(liveDocs, (DocsEnum) reuse, flags);
}
private DocsAndPositionsEnum docsAndPositions(Bits liveDocs,
DocsEnum reuse, int ignoredFlags) throws IOException {
public final DocsEnum docs(Bits liveDocs, DocsEnum reuse, int flags) throws IOException {
final TVDocsEnum docsEnum;
if (reuse != null && reuse instanceof TVDocsEnum) {
docsEnum = (TVDocsEnum) reuse;
@ -900,6 +885,15 @@ public final class CompressingTermVectorsReader extends TermVectorsReader implem
return docsEnum;
}
@Override
public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse, int flags) throws IOException {
if (positions == null && startOffsets == null) {
return null;
}
// TODO: slightly sheisty
return (DocsAndPositionsEnum) docs(liveDocs, reuse, flags);
}
}
private static class TVDocsEnum extends DocsAndPositionsEnum {

View File

@ -289,6 +289,8 @@ public class TestTermVectorsReader extends LuceneTestCase {
String term = text.utf8ToString();
//System.out.println("Term: " + term);
assertEquals(testTerms[i], term);
assertNotNull(termsEnum.docs(null, null));
assertNull(termsEnum.docsAndPositions(null, null)); // no pos
}
reader.close();
}