mirror of https://github.com/apache/lucene.git
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:
parent
75b1609b8b
commit
d74fda14f2
|
@ -21,8 +21,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.lucene.index.AtomicReaderContext;
|
import org.apache.lucene.index.AtomicReaderContext;
|
||||||
import org.apache.lucene.index.BinaryDocValues;
|
import org.apache.lucene.index.BinaryDocValues;
|
||||||
import org.apache.lucene.index.DocTermOrds;
|
import org.apache.lucene.index.SortedSetDocValues;
|
||||||
import org.apache.lucene.index.TermsEnum;
|
|
||||||
import org.apache.lucene.search.Collector;
|
import org.apache.lucene.search.Collector;
|
||||||
import org.apache.lucene.search.FieldCache;
|
import org.apache.lucene.search.FieldCache;
|
||||||
import org.apache.lucene.search.Scorer;
|
import org.apache.lucene.search.Scorer;
|
||||||
|
@ -69,10 +68,8 @@ abstract class TermsCollector extends Collector {
|
||||||
|
|
||||||
// impl that works with multiple values per document
|
// impl that works with multiple values per document
|
||||||
static class MV extends TermsCollector {
|
static class MV extends TermsCollector {
|
||||||
|
final BytesRef scratch = new BytesRef();
|
||||||
private DocTermOrds docTermOrds;
|
private SortedSetDocValues docTermOrds;
|
||||||
private TermsEnum docTermsEnum;
|
|
||||||
private DocTermOrds.TermOrdsIterator reuse;
|
|
||||||
|
|
||||||
MV(String field) {
|
MV(String field) {
|
||||||
super(field);
|
super(field);
|
||||||
|
@ -80,31 +77,17 @@ abstract class TermsCollector extends Collector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collect(int doc) throws IOException {
|
public void collect(int doc) throws IOException {
|
||||||
reuse = docTermOrds.lookup(doc, reuse);
|
docTermOrds.setDocument(doc);
|
||||||
int[] buffer = new int[5];
|
long ord;
|
||||||
|
while ((ord = docTermOrds.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {
|
||||||
int chunk;
|
docTermOrds.lookupOrd(ord, scratch);
|
||||||
do {
|
collectorTerms.add(scratch);
|
||||||
chunk = reuse.read(buffer);
|
}
|
||||||
if (chunk == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int idx = 0; idx < chunk; idx++) {
|
|
||||||
int key = buffer[idx];
|
|
||||||
docTermsEnum.seekExact((long) key);
|
|
||||||
collectorTerms.add(docTermsEnum.term());
|
|
||||||
}
|
|
||||||
} while (chunk >= buffer.length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNextReader(AtomicReaderContext context) throws IOException {
|
public void setNextReader(AtomicReaderContext context) throws IOException {
|
||||||
// nocommit: cut over
|
docTermOrds = FieldCache.DEFAULT.getDocTermOrds(context.reader(), field);
|
||||||
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...
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue