mirror of https://github.com/apache/lucene.git
don't cache objects for non-existent/unindexed sortedset
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4765@1445913 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
925fb58932
commit
2bccce2777
|
@ -1379,8 +1379,12 @@ class FieldCacheImpl implements FieldCache {
|
|||
}
|
||||
|
||||
final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
|
||||
if (info != null && info.hasDocValues()) {
|
||||
if (info == null) {
|
||||
return SortedSetDocValues.EMPTY;
|
||||
} else if (info.hasDocValues()) {
|
||||
throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
|
||||
} else if (!info.isIndexed()) {
|
||||
return SortedSetDocValues.EMPTY;
|
||||
}
|
||||
|
||||
DocTermOrds dto = (DocTermOrds) caches.get(DocTermOrds.class).get(reader, new CacheKey(field, null), false);
|
||||
|
|
|
@ -544,7 +544,6 @@ public class TestFieldCache extends LuceneTestCase {
|
|||
assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
|
||||
assertEquals(2, sortedSet.getValueCount());
|
||||
|
||||
// nocommit: not right
|
||||
bits = FieldCache.DEFAULT.getDocsWithField(ar, "sortedset");
|
||||
assertTrue(bits instanceof Bits.MatchAllBits);
|
||||
|
||||
|
@ -594,6 +593,10 @@ public class TestFieldCache extends LuceneTestCase {
|
|||
sorted.get(0, scratch);
|
||||
assertTrue(scratch.bytes == BinaryDocValues.MISSING);
|
||||
|
||||
SortedSetDocValues sortedSet = cache.getDocTermOrds(ar, "bogusmultivalued");
|
||||
sortedSet.setDocument(0);
|
||||
assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
|
||||
|
||||
Bits bits = cache.getDocsWithField(ar, "bogusbits");
|
||||
assertFalse(bits.get(0));
|
||||
|
||||
|
@ -615,6 +618,7 @@ public class TestFieldCache extends LuceneTestCase {
|
|||
doc.add(new StoredField("bogusdoubles", "bogus"));
|
||||
doc.add(new StoredField("bogusterms", "bogus"));
|
||||
doc.add(new StoredField("bogustermsindex", "bogus"));
|
||||
doc.add(new StoredField("bogusmultivalued", "bogus"));
|
||||
doc.add(new StoredField("bogusbits", "bogus"));
|
||||
iw.addDocument(doc);
|
||||
DirectoryReader ir = iw.getReader();
|
||||
|
@ -654,6 +658,10 @@ public class TestFieldCache extends LuceneTestCase {
|
|||
sorted.get(0, scratch);
|
||||
assertTrue(scratch.bytes == BinaryDocValues.MISSING);
|
||||
|
||||
SortedSetDocValues sortedSet = cache.getDocTermOrds(ar, "bogusmultivalued");
|
||||
sortedSet.setDocument(0);
|
||||
assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
|
||||
|
||||
Bits bits = cache.getDocsWithField(ar, "bogusbits");
|
||||
assertFalse(bits.get(0));
|
||||
|
||||
|
|
Loading…
Reference in New Issue