LUCENE-2459: fix FilterIndexReader to (by default) emulate flex API on top of pre-flex API

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@943935 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2010-05-13 16:51:18 +00:00
parent 712ce48d67
commit 48cca13075
2 changed files with 21 additions and 2 deletions

View File

@ -119,7 +119,7 @@ public class FilterIndexReader extends IndexReader {
@Override
public Bits getDeletedDocs() throws IOException {
return in.getDeletedDocs();
return MultiFields.getDeletedDocs(in);
}
@Override
@ -291,7 +291,18 @@ public class FilterIndexReader extends IndexReader {
@Override
public IndexReader[] getSequentialSubReaders() {
return in.getSequentialSubReaders();
return null;
}
/* Flex API wrappers. */
@Override
public Fields fields() throws IOException {
return new LegacyFields(this);
}
@Override
public Terms terms(String field) throws IOException {
return new LegacyTerms(this, field);
}
/** If the subclass of FilteredIndexReader modifies the

View File

@ -113,7 +113,15 @@ public class TestFilterIndexReader extends LuceneTestCase {
writer.close();
//IndexReader reader = new TestReader(IndexReader.open(directory, true));
RAMDirectory target = new MockRAMDirectory();
writer = new IndexWriter(target, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
IndexReader reader = new TestReader(IndexReader.open(directory, true));
writer.addIndexes(reader);
writer.close();
reader.close();
reader = IndexReader.open(target, true);
assertTrue(reader.isOptimized());