LUCENE-2858: Fix contrib/misc

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene2858@1237350 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-01-29 17:04:32 +00:00
parent caa766b847
commit 827d2f8c4a
4 changed files with 16 additions and 15 deletions

View File

@ -135,7 +135,7 @@ public class MultiPassIndexSplitter {
}
Directory dir = FSDirectory.open(new File(args[i]));
try {
if (!IndexReader.indexExists(dir)) {
if (!DirectoryReader.indexExists(dir)) {
System.err.println("Invalid input index - skipping: " + file);
continue;
}
@ -143,7 +143,7 @@ public class MultiPassIndexSplitter {
System.err.println("Invalid input index - skipping: " + file);
continue;
}
indexes.add(IndexReader.open(dir));
indexes.add(DirectoryReader.open(dir));
}
}
if (outDir == null) {
@ -182,15 +182,15 @@ public class MultiPassIndexSplitter {
super(initSubReaders(reader), false /* dont close */);
}
private static IndexReader[] initSubReaders(IndexReader reader) throws IOException {
final ArrayList<IndexReader> subs = new ArrayList<IndexReader>();
private static AtomicIndexReader[] initSubReaders(IndexReader reader) throws IOException {
final ArrayList<AtomicIndexReader> subs = new ArrayList<AtomicIndexReader>();
new ReaderUtil.Gather(reader) {
@Override
protected void add(int base, IndexReader r) {
protected void add(int base, AtomicIndexReader r) {
subs.add(new FakeDeleteAtomicIndexReader(r));
}
}.run();
return subs.toArray(new IndexReader[subs.size()]);
return subs.toArray(new AtomicIndexReader[subs.size()]);
}
public void deleteDocument(int docID) {
@ -226,7 +226,7 @@ public class MultiPassIndexSplitter {
private static final class FakeDeleteAtomicIndexReader extends FilterIndexReader {
FixedBitSet liveDocs;
public FakeDeleteAtomicIndexReader(IndexReader reader) {
public FakeDeleteAtomicIndexReader(AtomicIndexReader reader) {
super(reader);
undeleteAll(); // initialize main bitset
}

View File

@ -20,7 +20,7 @@ package org.apache.lucene.index;
import java.io.IOException;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.index.AtomicIndexReader.AtomicReaderContext;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Filter;
@ -84,7 +84,7 @@ public class PKIndexSplitter {
public void split() throws IOException {
boolean success = false;
IndexReader reader = IndexReader.open(input);
DirectoryReader reader = DirectoryReader.open(input);
try {
// pass an individual config in here since one config can not be reused!
createIndex(config1, dir1, reader, docsInFirstIndex, false);
@ -124,7 +124,7 @@ public class PKIndexSplitter {
final int numDocs;
public DocumentFilteredAtomicIndexReader(AtomicReaderContext context, Filter preserveFilter, boolean negateFilter) throws IOException {
super(context.reader);
super(context.reader());
final int maxDoc = in.maxDoc();
final FixedBitSet bits = new FixedBitSet(maxDoc);
// ignore livedocs here, as we filter them later:

View File

@ -17,6 +17,7 @@ package org.apache.lucene.misc;
* limitations under the License.
*/
import org.apache.lucene.index.AtomicIndexReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.index.Fields;
@ -187,7 +188,7 @@ public class HighFreqTerms {
new ReaderUtil.Gather(reader) {
@Override
protected void add(int base, IndexReader r) throws IOException {
protected void add(int base, AtomicIndexReader r) throws IOException {
Bits liveDocs = r.getLiveDocs();
if (liveDocs == null) {
// TODO: we could do this up front, during the scan

View File

@ -60,7 +60,7 @@ public class TestIndexSplitter extends LuceneTestCase {
iw.addDocument(doc);
}
iw.commit();
IndexReader iwReader = iw.getReader();
DirectoryReader iwReader = iw.getReader();
assertEquals(3, iwReader.getSequentialSubReaders().length);
iwReader.close();
iw.close();
@ -69,7 +69,7 @@ public class TestIndexSplitter extends LuceneTestCase {
String splitSegName = is.infos.info(1).name;
is.split(destDir, new String[] {splitSegName});
Directory fsDirDest = newFSDirectory(destDir);
IndexReader r = IndexReader.open(fsDirDest);
DirectoryReader r = DirectoryReader.open(fsDirDest);
assertEquals(50, r.maxDoc());
r.close();
fsDirDest.close();
@ -81,14 +81,14 @@ public class TestIndexSplitter extends LuceneTestCase {
IndexSplitter.main(new String[] {dir.getAbsolutePath(), destDir2.getAbsolutePath(), splitSegName});
assertEquals(4, destDir2.listFiles().length);
Directory fsDirDest2 = newFSDirectory(destDir2);
r = IndexReader.open(fsDirDest2);
r = DirectoryReader.open(fsDirDest2);
assertEquals(50, r.maxDoc());
r.close();
fsDirDest2.close();
// now remove the copied segment from src
IndexSplitter.main(new String[] {dir.getAbsolutePath(), "-d", splitSegName});
r = IndexReader.open(fsDir);
r = DirectoryReader.open(fsDir);
assertEquals(2, r.getSequentialSubReaders().length);
r.close();
fsDir.close();