Performance improvement when creating a multi-value field cache
This commit is contained in:
parent
d880a6c1b0
commit
56a2833de4
|
@ -41,6 +41,7 @@ public class FieldDataLoader {
|
||||||
|
|
||||||
field = StringHelper.intern(field);
|
field = StringHelper.intern(field);
|
||||||
ArrayList<int[]> ordinals = new ArrayList<int[]>();
|
ArrayList<int[]> ordinals = new ArrayList<int[]>();
|
||||||
|
int[] idx = new int[reader.maxDoc()];
|
||||||
ordinals.add(new int[reader.maxDoc()]);
|
ordinals.add(new int[reader.maxDoc()]);
|
||||||
|
|
||||||
int t = 1; // current term number
|
int t = 1; // current term number
|
||||||
|
@ -55,22 +56,15 @@ public class FieldDataLoader {
|
||||||
termDocs.seek(termEnum);
|
termDocs.seek(termEnum);
|
||||||
while (termDocs.next()) {
|
while (termDocs.next()) {
|
||||||
int doc = termDocs.doc();
|
int doc = termDocs.doc();
|
||||||
boolean found = false;
|
int[] ordinal;
|
||||||
for (int i = 0; i < ordinals.size(); i++) {
|
if (idx[doc] >= ordinals.size()) {
|
||||||
int[] ordinal = ordinals.get(i);
|
ordinal = new int[reader.maxDoc()];
|
||||||
if (ordinal[doc] == 0) {
|
|
||||||
// we found a spot, use it
|
|
||||||
ordinal[doc] = t;
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
// did not find one, increase by one and redo
|
|
||||||
int[] ordinal = new int[reader.maxDoc()];
|
|
||||||
ordinals.add(ordinal);
|
ordinals.add(ordinal);
|
||||||
ordinal[doc] = t;
|
} else {
|
||||||
|
ordinal = ordinals.get(idx[doc]);
|
||||||
}
|
}
|
||||||
|
ordinal[doc] = t;
|
||||||
|
idx[doc]++;
|
||||||
}
|
}
|
||||||
t++;
|
t++;
|
||||||
} while (termEnum.next());
|
} while (termEnum.next());
|
||||||
|
|
Loading…
Reference in New Issue