Apache Lucene open-source search software
SOLR-3322 Add more context to IndexReaderFactory.newReader.
Andrzej Bialeckiaff933433741
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 6a9869831ac..cdc89300e4d 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -484,6 +484,8 @@ Other Changes* SOLR-3302: Upgraded SLF4j to version 1.6.4 (hossman)+* SOLR-3322: Add more context to IndexReaderFactory.newReader (ab)+Documentation----------------------diff --git a/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.java b/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.javaindex 9d48d1a7438..b9e74098219 100644--- a/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.java+++ b/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.java@@ -58,9 +58,13 @@ public abstract class IndexReaderFactory implements NamedListInitializedPlugin {* Creates a new IndexReader instance using the given Directory.** @param indexDir indexDir index location+ * @param core {@link SolrCore} instance where this reader will be used. NOTE:+ * this SolrCore instance may not be fully configured yet, but basic things like+ * {@link SolrCore#getCoreDescriptor()}, {@link SolrCore#getSchema()} and+ * {@link SolrCore#getSolrConfig()} are valid.* @return An IndexReader instance* @throws IOException*/- public abstract DirectoryReader newReader(Directory indexDir)+ public abstract DirectoryReader newReader(Directory indexDir, SolrCore core)throws IOException;}diff --git a/solr/core/src/java/org/apache/solr/core/StandardIndexReaderFactory.java b/solr/core/src/java/org/apache/solr/core/StandardIndexReaderFactory.javaindex b52d4127f1e..615e9d923ee 100644--- a/solr/core/src/java/org/apache/solr/core/StandardIndexReaderFactory.java+++ b/solr/core/src/java/org/apache/solr/core/StandardIndexReaderFactory.java@@ -30,7 +30,7 @@ import org.apache.lucene.store.Directory;public class StandardIndexReaderFactory extends IndexReaderFactory {@Override- public DirectoryReader newReader(Directory indexDir) throws IOException {+ public DirectoryReader newReader(Directory indexDir, SolrCore core) throws IOException {return DirectoryReader.open(indexDir, termInfosIndexDivisor);}}diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.javaindex 5a9312e3c39..b2ae0edfee6 100644--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java@@ -117,7 +117,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrInpublic SolrIndexSearcher(SolrCore core, String path, IndexSchema schema, SolrIndexConfig config, String name, boolean enableCache, DirectoryFactory directoryFactory) throws IOException {// we don't need to reserve the directory because we get it from the factory- this(core, schema,name, core.getIndexReaderFactory().newReader(directoryFactory.get(path, config.lockType)), true, enableCache, false, directoryFactory);+ this(core, schema,name, core.getIndexReaderFactory().newReader(directoryFactory.get(path, config.lockType), core), true, enableCache, false, directoryFactory);}public SolrIndexSearcher(SolrCore core, IndexSchema schema, String name, DirectoryReader r, boolean closeReader, boolean enableCache, boolean reserveDirectory, DirectoryFactory directoryFactory) throws IOException {diff --git a/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java b/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.javaindex 09ca9fce4ae..0578d405b86 100755--- a/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java+++ b/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java@@ -61,7 +61,7 @@ public class AlternateDirectoryTest extends SolrTestCaseJ4 {static volatile boolean newReaderCalled = false;@Override- public DirectoryReader newReader(Directory indexDir) throws IOException {+ public DirectoryReader newReader(Directory indexDir, SolrCore core) throws IOException {TestIndexReaderFactory.newReaderCalled = true;return DirectoryReader.open(indexDir);}