LUCENE-2858: fix modules facet (partially)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene2858@1237330 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-01-29 16:34:57 +00:00
parent 4ef047b892
commit acefe212c1
7 changed files with 19 additions and 14 deletions

View File

@ -4,7 +4,7 @@ import java.io.IOException;
import java.util.List;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.index.AtomicIndexReader.AtomicReaderContext;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.Scorer;

View File

@ -3,7 +3,7 @@ package org.apache.lucene.facet.search;
import java.io.IOException;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.index.AtomicIndexReader.AtomicReaderContext;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;

View File

@ -15,6 +15,7 @@ import org.apache.lucene.facet.taxonomy.InconsistentTaxonomyException;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.Consts.LoadFullPathOnly;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.DocsEnum;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.MultiFields;
@ -58,7 +59,7 @@ public class DirectoryTaxonomyReader implements TaxonomyReader {
private static final Logger logger = Logger.getLogger(DirectoryTaxonomyReader.class.getName());
private IndexReader indexReader;
private DirectoryReader indexReader;
// The following lock is used to allow multiple threads to read from the
// index concurrently, while having them block during the very short
@ -126,7 +127,7 @@ public class DirectoryTaxonomyReader implements TaxonomyReader {
parentArray.refresh(indexReader);
}
protected IndexReader openIndexReader(Directory directory) throws CorruptIndexException, IOException {
protected DirectoryReader openIndexReader(Directory directory) throws CorruptIndexException, IOException {
return IndexReader.open(directory);
}
@ -353,7 +354,7 @@ public class DirectoryTaxonomyReader implements TaxonomyReader {
// safely read indexReader without holding the write lock, because
// no other thread can be writing at this time (this method is the
// only possible writer, and it is "synchronized" to avoid this case).
IndexReader r2 = IndexReader.openIfChanged(indexReader);
DirectoryReader r2 = DirectoryReader.openIfChanged(indexReader);
if (r2 == null) {
return false; // no changes, nothing to do
}

View File

@ -22,6 +22,7 @@ import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.DocsEnum;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
@ -112,7 +113,7 @@ public class DirectoryTaxonomyWriter implements TaxonomyWriter {
* that some of the cached data was cleared).
*/
private boolean cacheIsComplete;
private IndexReader reader;
private DirectoryReader reader;
private int cacheMisses;
/**
@ -188,7 +189,7 @@ public class DirectoryTaxonomyWriter implements TaxonomyWriter {
throws CorruptIndexException, LockObtainFailedException,
IOException {
if (!IndexReader.indexExists(directory) || openMode==OpenMode.CREATE) {
if (!DirectoryReader.indexExists(directory) || openMode==OpenMode.CREATE) {
taxoIndexCreateTime = Long.toString(System.nanoTime());
}
@ -281,7 +282,7 @@ public class DirectoryTaxonomyWriter implements TaxonomyWriter {
* calling {@link IndexReader#open(IndexWriter, boolean)}. Extending classes can override
* this method to return their own {@link IndexReader}.
*/
protected IndexReader openReader() throws IOException {
protected DirectoryReader openReader() throws IOException {
return IndexReader.open(indexWriter, true);
}
@ -618,7 +619,7 @@ public class DirectoryTaxonomyWriter implements TaxonomyWriter {
private synchronized void refreshReader() throws IOException {
if (reader != null) {
IndexReader r2 = IndexReader.openIfChanged(reader);
DirectoryReader r2 = DirectoryReader.openIfChanged(reader);
if (r2 != null) {
reader.close();
reader = r2;

View File

@ -9,6 +9,7 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
@ -133,7 +134,7 @@ public class FacetTestUtils {
}
public static class IndexTaxonomyReaderPair {
public IndexReader indexReader;
public DirectoryReader indexReader;
public TaxonomyReader taxReader;
public IndexSearcher indexSearcher;

View File

@ -9,6 +9,7 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
@ -299,7 +300,7 @@ public class TestTotalFacetCountsCache extends LuceneTestCase {
writers[0].taxWriter.close();
readers[0].taxReader.refresh();
IndexReader r2 = IndexReader.openIfChanged(readers[0].indexReader);
DirectoryReader r2 = DirectoryReader.openIfChanged(readers[0].indexReader);
assertNotNull(r2);
// Hold on to the 'original' reader so we can do some checks with it
IndexReader origReader = null;

View File

@ -3,6 +3,7 @@ package org.apache.lucene.facet.taxonomy.directory;
import java.util.HashMap;
import java.util.Map;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.AlreadyClosedException;
@ -54,7 +55,7 @@ public class TestDirectoryTaxonomyWriter extends LuceneTestCase {
// commit() wasn't called.
Directory dir = newDirectory();
DirectoryTaxonomyWriter ltw = new DirectoryTaxonomyWriter(dir, OpenMode.CREATE_OR_APPEND, new NoOpCache());
assertFalse(IndexReader.indexExists(dir));
assertFalse(DirectoryReader.indexExists(dir));
ltw.commit(); // first commit, so that an index will be created
ltw.addCategory(new CategoryPath("a"));
@ -70,7 +71,7 @@ public class TestDirectoryTaxonomyWriter extends LuceneTestCase {
// Verifies that committed data is retrievable
Directory dir = newDirectory();
DirectoryTaxonomyWriter ltw = new DirectoryTaxonomyWriter(dir, OpenMode.CREATE_OR_APPEND, new NoOpCache());
assertFalse(IndexReader.indexExists(dir));
assertFalse(DirectoryReader.indexExists(dir));
ltw.commit(); // first commit, so that an index will be created
ltw.addCategory(new CategoryPath("a"));
ltw.addCategory(new CategoryPath("b"));
@ -78,7 +79,7 @@ public class TestDirectoryTaxonomyWriter extends LuceneTestCase {
userCommitData.put("testing", "1 2 3");
ltw.commit(userCommitData);
ltw.close();
IndexReader r = IndexReader.open(dir);
DirectoryReader r = IndexReader.open(dir);
assertEquals("2 categories plus root should have been committed to the underlying directory", 3, r.numDocs());
Map <String, String> readUserCommitData = r.getCommitUserData();
assertTrue("wrong value extracted from commit data",