cutover multi-valued join collector

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4765@1444839 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-02-11 15:52:16 +00:00
parent 75b1609b8b
commit d74fda14f2
1 changed files with 10 additions and 27 deletions

View File

@ -21,8 +21,7 @@ import java.io.IOException;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.DocTermOrds;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.Scorer;
@ -69,10 +68,8 @@ abstract class TermsCollector extends Collector {
// impl that works with multiple values per document
static class MV extends TermsCollector {
private DocTermOrds docTermOrds;
private TermsEnum docTermsEnum;
private DocTermOrds.TermOrdsIterator reuse;
final BytesRef scratch = new BytesRef();
private SortedSetDocValues docTermOrds;
MV(String field) {
super(field);
@ -80,31 +77,17 @@ abstract class TermsCollector extends Collector {
@Override
public void collect(int doc) throws IOException {
reuse = docTermOrds.lookup(doc, reuse);
int[] buffer = new int[5];
int chunk;
do {
chunk = reuse.read(buffer);
if (chunk == 0) {
return;
docTermOrds.setDocument(doc);
long ord;
while ((ord = docTermOrds.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {
docTermOrds.lookupOrd(ord, scratch);
collectorTerms.add(scratch);
}
for (int idx = 0; idx < chunk; idx++) {
int key = buffer[idx];
docTermsEnum.seekExact((long) key);
collectorTerms.add(docTermsEnum.term());
}
} while (chunk >= buffer.length);
}
@Override
public void setNextReader(AtomicReaderContext context) throws IOException {
// nocommit: cut over
DocTermOrds.Iterator iterator = (DocTermOrds.Iterator) FieldCache.DEFAULT.getDocTermOrds(context.reader(), field);
docTermOrds = iterator.getParent();
docTermsEnum = docTermOrds.getOrdTermsEnum(context.reader());
reuse = null; // LUCENE-3377 needs to be fixed first then this statement can be removed...
docTermOrds = FieldCache.DEFAULT.getDocTermOrds(context.reader(), field);
}
}