SOLR-3322 Add more context to IndexReaderFactory.newReader.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1311812 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrzej Bialecki 2012-04-10 16:06:33 +00:00
parent fb97a9e169
commit aff9334337
5 changed files with 10 additions and 4 deletions

View File

@ -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
----------------------

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -117,7 +117,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
public 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 {

View File

@ -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);
}