lucene 4: Field name no longed interned when loading field data cache and return empty field data cache for fields that don't exist.

This commit is contained in:
Martijn van Groningen 2012-10-26 01:37:06 +02:00 committed by Shay Banon
parent 454954e7be
commit 15c9cd5142
1 changed files with 4 additions and 4 deletions

View File

@ -38,9 +38,6 @@ public class FieldDataLoader {
public static <T extends FieldData> T load(AtomicReader reader, String field, TypeLoader<T> loader) throws IOException { public static <T extends FieldData> T load(AtomicReader reader, String field, TypeLoader<T> loader) throws IOException {
loader.init(); loader.init();
// LUCENE 4 UPGRADE: StringHelper?
field = field.intern();//StringHelper.intern(field);
ArrayList<int[]> ordinals = new ArrayList<int[]>(); ArrayList<int[]> ordinals = new ArrayList<int[]>();
int[] idx = new int[reader.maxDoc()]; int[] idx = new int[reader.maxDoc()];
ordinals.add(new int[reader.maxDoc()]); ordinals.add(new int[reader.maxDoc()]);
@ -48,8 +45,11 @@ public class FieldDataLoader {
int t = 1; // current term number int t = 1; // current term number
Terms terms = reader.terms(field); Terms terms = reader.terms(field);
TermsEnum termsEnum = terms.iterator(null); if (terms == null) {
return loader.buildSingleValue(field, new int[0]); // Return empty field data if field doesn't exists.
}
TermsEnum termsEnum = terms.iterator(null);
try { try {
DocsEnum docsEnum = null; DocsEnum docsEnum = null;
for (BytesRef term = termsEnum.next(); term != null; term = termsEnum.term()) { for (BytesRef term = termsEnum.next(); term != null; term = termsEnum.term()) {