You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/01/12 11:53:53 UTC
svn commit: r1230482 -
/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java
Author: simonw
Date: Thu Jan 12 10:53:53 2012
New Revision: 1230482
URL: http://svn.apache.org/viewvc?rev=1230482&view=rev
Log:
don't load MultiDocValues for norms if one leaf reader omits norms
Modified:
lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java
Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java?rev=1230482&r1=1230481&r2=1230482&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java Thu Jan 12 10:53:53 2012
@@ -46,6 +46,12 @@ public class MultiDocValues extends DocV
public DocValues pull(IndexReader reader, String field) throws IOException {
return reader.normValues(field);
}
+
+ public boolean stopLoadingOnNull(IndexReader reader, String field) throws IOException {
+ // for norms we drop all norms if one leaf reader has no norms and the field is present
+ Fields fields = reader.fields();
+ return (fields != null && fields.terms(field) != null);
+ }
};
public static class DocValuesSlice {
@@ -65,6 +71,10 @@ public class MultiDocValues extends DocV
public DocValues pull(IndexReader reader, String field) throws IOException {
return reader.docValues(field);
}
+
+ public boolean stopLoadingOnNull(IndexReader reader, String field) throws IOException {
+ return false;
+ }
}
private DocValuesSlice[] slices;
@@ -123,12 +133,19 @@ public class MultiDocValues extends DocV
// potentially incompatible types
new ReaderUtil.Gather(r) {
+ boolean stop = false;
@Override
protected void add(int base, IndexReader r) throws IOException {
+ if (stop) {
+ return;
+ }
final DocValues d = puller.pull(r, field);
if (d != null) {
TypePromoter incoming = TypePromoter.create(d.type(), d.getValueSize());
promotedType[0] = promotedType[0].promote(incoming);
+ } else if (puller.stopLoadingOnNull(r, field)){
+ promotedType[0] = TypePromoter.getIdentityPromoter(); // set to identity to return null
+ stop = true;
}
slices.add(new DocValuesSlice(d, base, r.maxDoc()));
}