LUCENE-3606: clear up some nocommits

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3606@1211005 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-12-06 16:36:41 +00:00
parent 8b80aac679
commit caedbf9ef9
9 changed files with 37 additions and 42 deletions

View File

@ -44,9 +44,8 @@ public class TestMatchAllDocsQuery extends LuceneTestCase {
addDoc("one", iw, 1f);
addDoc("two", iw, 20f);
addDoc("three four", iw, 300f);
iw.close();
IndexReader ir = IndexReader.open(iw, true);
IndexReader ir = IndexReader.open(dir);
IndexSearcher is = newSearcher(ir);
ScoreDoc[] hits;
@ -70,13 +69,16 @@ public class TestMatchAllDocsQuery extends LuceneTestCase {
hits = is.search(bq, null, 1000).scoreDocs;
assertEquals(1, hits.length);
/* nocommit: fix this test to delete a document with IW
// delete a document:
is.getIndexReader().deleteDocument(0);
iw.deleteDocuments(new Term("key", "one"));
is.close();
ir.close();
ir = IndexReader.open(iw, true);
is = newSearcher(ir);
hits = is.search(new MatchAllDocsQuery(), null, 1000).scoreDocs;
assertEquals(2, hits.length);
*/
iw.close();
is.close();
ir.close();
dir.close();

View File

@ -240,7 +240,6 @@ public class TestBufferedIndexInput extends LuceneTestCase {
}
}
/* nocommit: fix deletions to use IW
public void testSetBufferSize() throws IOException {
File indexDir = _TestUtil.getTempDir("testSetBufferSize");
MockFSDirectory dir = new MockFSDirectory(indexDir, random);
@ -257,25 +256,33 @@ public class TestBufferedIndexInput extends LuceneTestCase {
doc.add(newField("id", "" + i, TextField.TYPE_STORED));
writer.addDocument(doc);
}
writer.close();
dir.allIndexInputs.clear();
IndexReader reader = IndexReader.open(dir);
IndexReader reader = IndexReader.open(writer, true);
Term aaa = new Term("content", "aaa");
Term bbb = new Term("content", "bbb");
Term ccc = new Term("content", "ccc");
assertEquals(37, reader.docFreq(ccc));
reader.deleteDocument(0);
assertEquals(37, reader.docFreq(aaa));
reader.close();
dir.tweakBufferSizes();
reader.deleteDocument(4);
assertEquals(reader.docFreq(bbb), 37);
dir.tweakBufferSizes();
writer.deleteDocuments(new Term("id", "0"));
reader = IndexReader.open(writer, true);
IndexSearcher searcher = newSearcher(reader);
ScoreDoc[] hits = searcher.search(new TermQuery(bbb), null, 1000).scoreDocs;
dir.tweakBufferSizes();
assertEquals(36, hits.length);
reader.close();
searcher.close();
dir.tweakBufferSizes();
writer.deleteDocuments(new Term("id", "4"));
reader = IndexReader.open(writer, true);
searcher = newSearcher(reader);
hits = searcher.search(new TermQuery(bbb), null, 1000).scoreDocs;
dir.tweakBufferSizes();
assertEquals(35, hits.length);
dir.tweakBufferSizes();
hits = searcher.search(new TermQuery(new Term("id", "33")), null, 1000).scoreDocs;
@ -284,13 +291,12 @@ public class TestBufferedIndexInput extends LuceneTestCase {
hits = searcher.search(new TermQuery(aaa), null, 1000).scoreDocs;
dir.tweakBufferSizes();
assertEquals(35, hits.length);
writer.close();
searcher.close();
reader.close();
} finally {
_TestUtil.rmDir(indexDir);
}
}
*/
private static class MockFSDirectory extends Directory {

View File

@ -57,10 +57,9 @@ public abstract class IndexReaderFactory implements NamedListInitializedPlugin {
* Creates a new IndexReader instance using the given Directory.
*
* @param indexDir indexDir index location
* @param readOnly return readOnly IndexReader
* @return An IndexReader instance
* @throws IOException
*/
public abstract IndexReader newReader(Directory indexDir, boolean readOnly)
public abstract IndexReader newReader(Directory indexDir)
throws IOException;
}

View File

@ -314,12 +314,7 @@ public final class SolrCore implements SolrInfoMBean {
// gets a non-caching searcher
public SolrIndexSearcher newSearcher(String name) throws IOException {
return newSearcher(name, false);
}
// gets a non-caching searcher
public SolrIndexSearcher newSearcher(String name, boolean readOnly) throws IOException {
return new SolrIndexSearcher(this, getNewIndexDir(), schema, getSolrConfig().mainIndexConfig, name, readOnly, false, directoryFactory);
return new SolrIndexSearcher(this, getNewIndexDir(), schema, getSolrConfig().mainIndexConfig, name, false, directoryFactory);
}
@ -1146,7 +1141,7 @@ public final class SolrCore implements SolrInfoMBean {
} else {
// verbose("non-reopen START:");
tmp = new SolrIndexSearcher(this, newIndexDir, schema, getSolrConfig().mainIndexConfig, "main", true, true, directoryFactory);
tmp = new SolrIndexSearcher(this, newIndexDir, schema, getSolrConfig().mainIndexConfig, "main", true, directoryFactory);
// verbose("non-reopen DONE: searcher=",tmp);
}
} catch (Throwable th) {

View File

@ -29,13 +29,8 @@ import org.apache.lucene.store.Directory;
*/
public class StandardIndexReaderFactory extends IndexReaderFactory {
/* (non-Javadoc)
* @see org.apache.solr.core.IndexReaderFactory#newReader(org.apache.lucene.store.Directory, boolean)
*/
@Override
public IndexReader newReader(Directory indexDir, boolean readOnly)
throws IOException {
assert readOnly; // nocommit: readOnly is ignored - remove
public IndexReader newReader(Directory indexDir) throws IOException {
return IndexReader.open(indexDir, termInfosIndexDivisor);
}
}

View File

@ -107,9 +107,9 @@ public class SolrIndexSearcher extends IndexSearcher implements SolrInfoMBean {
private Collection<String> storedHighlightFieldNames;
private DirectoryFactory directoryFactory;
public SolrIndexSearcher(SolrCore core, String path, IndexSchema schema, SolrIndexConfig config, String name, boolean readOnly, boolean enableCache, DirectoryFactory directoryFactory) throws IOException {
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), readOnly), true, enableCache, false, directoryFactory);
this(core, schema,name, core.getIndexReaderFactory().newReader(directoryFactory.get(path, config.lockType)), true, enableCache, false, directoryFactory);
}
public SolrIndexSearcher(SolrCore core, IndexSchema schema, String name, IndexReader r, boolean closeReader, boolean enableCache, boolean reserveDirectory, DirectoryFactory directoryFactory) {

View File

@ -61,9 +61,7 @@ public class AlternateDirectoryTest extends SolrTestCaseJ4 {
static volatile boolean newReaderCalled = false;
@Override
public IndexReader newReader(Directory indexDir, boolean readOnly)
throws IOException {
assert readOnly; // nocommit: readOnly is ignored - remove
public IndexReader newReader(Directory indexDir) throws IOException {
TestIndexReaderFactory.newReaderCalled = true;
return IndexReader.open(indexDir);
}

View File

@ -75,7 +75,7 @@ public class TestQuerySenderListener extends SolrTestCaseJ4 {
assertNotNull("Event is null", evt);
assertTrue(evt + " is not equal to " + EventParams.FIRST_SEARCHER, evt.equals(EventParams.FIRST_SEARCHER) == true);
SolrIndexSearcher newSearcher = new SolrIndexSearcher(core, core.getNewIndexDir(), core.getSchema(), core.getSolrConfig().mainIndexConfig, "testQuerySenderListener", true, false, core.getDirectoryFactory());
SolrIndexSearcher newSearcher = new SolrIndexSearcher(core, core.getNewIndexDir(), core.getSchema(), core.getSolrConfig().mainIndexConfig, "testQuerySenderListener", false, core.getDirectoryFactory());
qsl.newSearcher(newSearcher, currentSearcher);
evt = mock.req.getParams().get(EventParams.EVENT);

View File

@ -75,7 +75,7 @@ public class TestQuerySenderNoQuery extends SolrTestCaseJ4 {
assertNotNull("Mock is null", mock);
assertNull("Req (firstsearcher) is not null", mock.req);
SolrIndexSearcher newSearcher = new SolrIndexSearcher(core, core.getNewIndexDir(), core.getSchema(), core.getSolrConfig().mainIndexConfig, "testQuerySenderNoQuery", true, false, core.getDirectoryFactory());
SolrIndexSearcher newSearcher = new SolrIndexSearcher(core, core.getNewIndexDir(), core.getSchema(), core.getSolrConfig().mainIndexConfig, "testQuerySenderNoQuery", false, core.getDirectoryFactory());
qsl.newSearcher(newSearcher, currentSearcher); // get newSearcher.
assertNull("Req (newsearcher) is not null", mock.req);