make MultiDocValues.getSorted more efficient

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1436472 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-01-21 16:40:02 +00:00
parent 275b1caa00
commit 39e77a6f8e
2 changed files with 20 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.index.FieldInfo.DocValuesType;
import org.apache.lucene.index.IndexReader.ReaderClosedListener;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
@ -174,6 +175,9 @@ public class MultiDocValues {
config.setCodec(Codec.forName("SimpleText"));
IndexWriter writer = new IndexWriter(scratch, config);
List<AtomicReader> newLeaves = new ArrayList<AtomicReader>();
// fake up fieldinfos
FieldInfo fi = new FieldInfo(field, false, 0, false, false, false, null, DocValuesType.SORTED, null, null);
final FieldInfos fis = new FieldInfos(new FieldInfo[] { fi });
for (AtomicReaderContext ctx : leaves) {
final AtomicReader a = ctx.reader();
newLeaves.add(new FilterAtomicReader(a) {
@ -189,6 +193,22 @@ public class MultiDocValues {
public boolean hasDeletions() {
return false; // lie
}
@Override
public FieldInfos getFieldInfos() {
return fis;
}
@Override
public Fields getTermVectors(int docID) throws IOException {
return null; // lie
}
@Override
public void document(int docID, StoredFieldVisitor visitor) throws IOException {
// lie
}
@Override
public Fields fields() throws IOException {
return null; // lie
}
});
}
writer.addIndexes(newLeaves.toArray(new AtomicReader[0]));

View File

@ -41,7 +41,6 @@ import org.apache.lucene.util._TestUtil;
/**
* Tests IndexSearcher's searchAfter() method
*/
// nocommit fail w/ OOME?: ant test -Dtestcase=TestSearchAfter -Dtests.method=testQueries -Dtests.seed=98B4DA915983D1AE -Dtests.slow=true -Dtests.locale=sr -Dtests.timezone=Etc/GMT+2 -Dtests.file.encoding=UTF-8
public class TestSearchAfter extends LuceneTestCase {
private Directory dir;
private IndexReader reader;