improve field data loader to bulk read doc ids
This commit is contained in:
parent
f87632fabd
commit
9f706c6f6e
|
@ -49,22 +49,31 @@ public class FieldDataLoader {
|
||||||
TermDocs termDocs = reader.termDocs();
|
TermDocs termDocs = reader.termDocs();
|
||||||
TermEnum termEnum = reader.terms(new Term(field));
|
TermEnum termEnum = reader.terms(new Term(field));
|
||||||
try {
|
try {
|
||||||
|
// bulk read (in lucene 4 it won't be needed).
|
||||||
|
int size = Math.min(128, reader.maxDoc());
|
||||||
|
int[] docs = new int[size];
|
||||||
|
int[] freqs = new int[size];
|
||||||
do {
|
do {
|
||||||
Term term = termEnum.term();
|
Term term = termEnum.term();
|
||||||
if (term == null || term.field() != field) break;
|
if (term == null || term.field() != field) break;
|
||||||
loader.collectTerm(term.text());
|
loader.collectTerm(term.text());
|
||||||
termDocs.seek(termEnum);
|
termDocs.seek(termEnum);
|
||||||
while (termDocs.next()) {
|
|
||||||
int doc = termDocs.doc();
|
int number = termDocs.read(docs, freqs);
|
||||||
int[] ordinal;
|
while (number > 0) {
|
||||||
if (idx[doc] >= ordinals.size()) {
|
for (int i = 0; i < number; i++) {
|
||||||
ordinal = new int[reader.maxDoc()];
|
int doc = docs[i];
|
||||||
ordinals.add(ordinal);
|
int[] ordinal;
|
||||||
} else {
|
if (idx[doc] >= ordinals.size()) {
|
||||||
ordinal = ordinals.get(idx[doc]);
|
ordinal = new int[reader.maxDoc()];
|
||||||
|
ordinals.add(ordinal);
|
||||||
|
} else {
|
||||||
|
ordinal = ordinals.get(idx[doc]);
|
||||||
|
}
|
||||||
|
ordinal[doc] = t;
|
||||||
|
idx[doc]++;
|
||||||
}
|
}
|
||||||
ordinal[doc] = t;
|
number = termDocs.read(docs, freqs);
|
||||||
idx[doc]++;
|
|
||||||
}
|
}
|
||||||
t++;
|
t++;
|
||||||
} while (termEnum.next());
|
} while (termEnum.next());
|
||||||
|
|
Loading…
Reference in New Issue