also fix SimpleTextDimValues to skip writing if merged segment had deleted all docs with the dimensional field

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1721583 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-12-23 22:36:16 +00:00
parent 132986048f
commit 3430150819
3 changed files with 17 additions and 3 deletions

View File

@ -24,6 +24,7 @@ import java.util.Map;
import org.apache.lucene.codecs.DimensionalReader;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.store.BufferedChecksumIndexInput;
@ -135,9 +136,18 @@ class SimpleTextDimensionalReader extends DimensionalReader {
/** Finds all documents and points matching the provided visitor */
@Override
public void intersect(String field, IntersectVisitor visitor) throws IOException {
FieldInfo fieldInfo = readState.fieldInfos.fieldInfo(field);
if (fieldInfo == null) {
throw new IllegalArgumentException("field=\"" + field + "\" is unrecognized");
}
if (fieldInfo.getDimensionCount() == 0) {
throw new IllegalArgumentException("field=\"" + field + "\" did not index dimensional values");
}
BKDReader bkdReader = readers.get(field);
if (bkdReader == null) {
throw new IllegalArgumentException("field=\"" + field + "\" was not indexed with dimensional values");
// Schema ghost corner case! This field did index dimensional values in the past, but
// now all docs having this dimensional field were deleted in this segment:
return;
}
bkdReader.intersect(visitor);
}

View File

@ -157,7 +157,11 @@ class SimpleTextDimensionalWriter extends DimensionalWriter {
return Relation.CELL_CROSSES_QUERY;
}
});
indexFPs.put(fieldInfo.name, writer.finish(dataOut));
// We could have 0 points on merge since all docs with dimensional fields may be deleted:
if (writer.getPointCount() > 0) {
indexFPs.put(fieldInfo.name, writer.finish(dataOut));
}
}
private void write(IndexOutput out, String s) throws IOException {

View File

@ -105,7 +105,7 @@ public class Lucene60DimensionalWriter extends DimensionalWriter implements Clos
}
});
// We could have 0 points since all docs with dimensional fields may be deleted:
// We could have 0 points on merge since all docs with dimensional fields may be deleted:
if (writer.getPointCount() > 0) {
indexFPs.put(fieldInfo.name, writer.finish(dataOut));
}