mirror of https://github.com/apache/lucene.git
SOLR-13694: IndexSizeEstimator NullPointerException.
This commit is contained in:
parent
ea8f921e71
commit
09bee6d57c
|
@ -97,6 +97,8 @@ Bug Fixes
|
||||||
* SOLR-13141: CDCR bootstrap does not replicate index to the replicas of target cluster.
|
* SOLR-13141: CDCR bootstrap does not replicate index to the replicas of target cluster.
|
||||||
(Krzysztof Watral, Amrit Sarkar, Tim, Tdspringsteen, shalin)
|
(Krzysztof Watral, Amrit Sarkar, Tim, Tdspringsteen, shalin)
|
||||||
|
|
||||||
|
* SOLR-13694: IndexSizeEstimator NullPointerException. (ab, hossman)
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -504,14 +504,16 @@ public class IndexSizeEstimator {
|
||||||
CodecReader codecReader = (CodecReader)leafReader;
|
CodecReader codecReader = (CodecReader)leafReader;
|
||||||
StoredFieldsReader storedFieldsReader = codecReader.getFieldsReader();
|
StoredFieldsReader storedFieldsReader = codecReader.getFieldsReader();
|
||||||
// this instance may be faster for a full sequential pass
|
// this instance may be faster for a full sequential pass
|
||||||
storedFieldsReader = storedFieldsReader.getMergeInstance();
|
StoredFieldsReader mergeInstance = storedFieldsReader.getMergeInstance();
|
||||||
for (int docId = 0; docId < leafReader.maxDoc(); docId += samplingStep) {
|
for (int docId = 0; docId < leafReader.maxDoc(); docId += samplingStep) {
|
||||||
if (liveDocs != null && !liveDocs.get(docId)) {
|
if (liveDocs != null && !liveDocs.get(docId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
storedFieldsReader.visitDocument(docId, visitor);
|
mergeInstance.visitDocument(docId, visitor);
|
||||||
|
}
|
||||||
|
if (mergeInstance != storedFieldsReader) {
|
||||||
|
mergeInstance.close();
|
||||||
}
|
}
|
||||||
storedFieldsReader.close();
|
|
||||||
} else {
|
} else {
|
||||||
for (int docId = 0; docId < leafReader.maxDoc(); docId += samplingStep) {
|
for (int docId = 0; docId < leafReader.maxDoc(); docId += samplingStep) {
|
||||||
if (liveDocs != null && !liveDocs.get(docId)) {
|
if (liveDocs != null && !liveDocs.get(docId)) {
|
||||||
|
|
|
@ -23,6 +23,14 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.apache.lucene.codecs.StoredFieldsReader;
|
||||||
|
import org.apache.lucene.document.DocumentStoredFieldVisitor;
|
||||||
|
import org.apache.lucene.index.CodecReader;
|
||||||
|
import org.apache.lucene.index.IndexReader;
|
||||||
|
import org.apache.lucene.index.LeafReader;
|
||||||
|
import org.apache.lucene.index.LeafReaderContext;
|
||||||
|
import org.apache.lucene.index.StoredFieldVisitor;
|
||||||
|
import org.apache.lucene.util.Bits;
|
||||||
import org.apache.lucene.util.RamUsageEstimator;
|
import org.apache.lucene.util.RamUsageEstimator;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||||
|
@ -124,6 +132,23 @@ public class IndexSizeEstimatorTest extends SolrCloudTestCase {
|
||||||
double delta = (double) size * 0.5;
|
double delta = (double) size * 0.5;
|
||||||
assertEquals("sampled size of " + field + " is wildly off", (double)size, (double)sampledSize, delta);
|
assertEquals("sampled size of " + field + " is wildly off", (double)size, (double)sampledSize, delta);
|
||||||
});
|
});
|
||||||
|
// verify the reader is still usable - SOLR-13694
|
||||||
|
IndexReader reader = searcher.getRawReader();
|
||||||
|
for (LeafReaderContext context : reader.leaves()) {
|
||||||
|
LeafReader leafReader = context.reader();
|
||||||
|
assertTrue("unexpected LeafReader class: " + leafReader.getClass().getName(), leafReader instanceof CodecReader);
|
||||||
|
Bits liveDocs = leafReader.getLiveDocs();
|
||||||
|
CodecReader codecReader = (CodecReader) leafReader;
|
||||||
|
StoredFieldsReader storedFieldsReader = codecReader.getFieldsReader();
|
||||||
|
StoredFieldVisitor visitor = new DocumentStoredFieldVisitor();
|
||||||
|
assertNotNull(storedFieldsReader);
|
||||||
|
for (int docId = 0; docId < leafReader.maxDoc(); docId++) {
|
||||||
|
if (liveDocs != null && !liveDocs.get(docId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
storedFieldsReader.visitDocument(docId, visitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
searcherRef.decref();
|
searcherRef.decref();
|
||||||
core.close();
|
core.close();
|
||||||
|
|
Loading…
Reference in New Issue