mirror of https://github.com/apache/lucene.git
don't load MultiDocValues for norms if one leaf reader omits norms
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1230482 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d74db06ddf
commit
8913c0c597
|
@ -46,6 +46,12 @@ public class MultiDocValues extends DocValues {
|
||||||
public DocValues pull(IndexReader reader, String field) throws IOException {
|
public DocValues pull(IndexReader reader, String field) throws IOException {
|
||||||
return reader.normValues(field);
|
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 {
|
public static class DocValuesSlice {
|
||||||
|
@ -65,6 +71,10 @@ public class MultiDocValues extends DocValues {
|
||||||
public DocValues pull(IndexReader reader, String field) throws IOException {
|
public DocValues pull(IndexReader reader, String field) throws IOException {
|
||||||
return reader.docValues(field);
|
return reader.docValues(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean stopLoadingOnNull(IndexReader reader, String field) throws IOException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DocValuesSlice[] slices;
|
private DocValuesSlice[] slices;
|
||||||
|
@ -123,12 +133,19 @@ public class MultiDocValues extends DocValues {
|
||||||
// potentially incompatible types
|
// potentially incompatible types
|
||||||
|
|
||||||
new ReaderUtil.Gather(r) {
|
new ReaderUtil.Gather(r) {
|
||||||
|
boolean stop = false;
|
||||||
@Override
|
@Override
|
||||||
protected void add(int base, IndexReader r) throws IOException {
|
protected void add(int base, IndexReader r) throws IOException {
|
||||||
|
if (stop) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final DocValues d = puller.pull(r, field);
|
final DocValues d = puller.pull(r, field);
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
TypePromoter incoming = TypePromoter.create(d.type(), d.getValueSize());
|
TypePromoter incoming = TypePromoter.create(d.type(), d.getValueSize());
|
||||||
promotedType[0] = promotedType[0].promote(incoming);
|
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()));
|
slices.add(new DocValuesSlice(d, base, r.maxDoc()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue