mirror of https://github.com/apache/lucene.git
make all Directory.listAll's sort, and add BaseDirectoryTestCase; add TODO; suppress VirusCheckingFS for another test
This commit is contained in:
parent
9cf74f791c
commit
dd6379c05f
|
@ -699,14 +699,15 @@ final class IndexFileDeleter implements Closeable {
|
||||||
infoStream.message("IFD", "delete \"" + names + "\"");
|
infoStream.message("IFD", "delete \"" + names + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
// nocommit put annoying windows-specific segments_N heroics back?
|
|
||||||
|
|
||||||
for(String name : names) {
|
for(String name : names) {
|
||||||
try {
|
try {
|
||||||
directory.deleteFile(name);
|
directory.deleteFile(name);
|
||||||
} catch (NoSuchFileException | FileNotFoundException e) {
|
} catch (NoSuchFileException | FileNotFoundException e) {
|
||||||
// IndexWriter should only ask us to delete files it knows it wrote, so if we hit this, something is wrong!
|
// IndexWriter should only ask us to delete files it knows it wrote, so if we hit this, something is wrong!
|
||||||
|
|
||||||
if (Constants.WINDOWS) {
|
if (Constants.WINDOWS) {
|
||||||
|
// TODO: can we remove this OS-specific hacky logic? If windows deleteFile is buggy, we should instead contain this workaround in
|
||||||
|
// a WindowsFSDirectory ...
|
||||||
// LUCENE-6684: we suppress this assert for Windows, since a file could be in a confusing "pending delete" state, and falsely
|
// LUCENE-6684: we suppress this assert for Windows, since a file could be in a confusing "pending delete" state, and falsely
|
||||||
// return NSFE/FNFE
|
// return NSFE/FNFE
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -754,8 +754,9 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
||||||
* IO error
|
* IO error
|
||||||
*/
|
*/
|
||||||
public IndexWriter(Directory d, IndexWriterConfig conf) throws IOException {
|
public IndexWriter(Directory d, IndexWriterConfig conf) throws IOException {
|
||||||
if (d instanceof FSDirectory && ((FSDirectory) d).checkPendingDeletions()) {
|
Directory unwrapped = FilterDirectory.unwrap(d);
|
||||||
throw new IllegalArgumentException("Directory still has pending deleted files");
|
if (unwrapped instanceof FSDirectory && ((FSDirectory) unwrapped).checkPendingDeletions()) {
|
||||||
|
throw new IllegalArgumentException("Directory still has pending deleted files; cannot initialize IndexWriter");
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.setIndexWriter(this); // prevent reuse by other instances
|
conf.setIndexWriter(this); // prevent reuse by other instances
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.apache.lucene.util.IOUtils;
|
||||||
public abstract class Directory implements Closeable {
|
public abstract class Directory implements Closeable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of strings, one for each entry in the directory.
|
* Returns an array of strings, one for each entry in the directory, in sorted (UTF16, java's String.compare) order.
|
||||||
*
|
*
|
||||||
* @throws IOException in case of IO error
|
* @throws IOException in case of IO error
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -119,8 +120,12 @@ public class RAMDirectory extends BaseDirectory implements Accountable {
|
||||||
// concurrently
|
// concurrently
|
||||||
Set<String> fileNames = fileMap.keySet();
|
Set<String> fileNames = fileMap.keySet();
|
||||||
List<String> names = new ArrayList<>(fileNames.size());
|
List<String> names = new ArrayList<>(fileNames.size());
|
||||||
for (String name : fileNames) names.add(name);
|
for (String name : fileNames) {
|
||||||
return names.toArray(new String[names.size()]);
|
names.add(name);
|
||||||
|
}
|
||||||
|
String[] namesArray = names.toArray(new String[names.size()]);
|
||||||
|
Arrays.sort(namesArray);
|
||||||
|
return namesArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean fileNameExists(String name) {
|
public final boolean fileNameExists(String name) {
|
||||||
|
|
|
@ -2738,7 +2738,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
||||||
try {
|
try {
|
||||||
w = new IndexWriter(dir, iwc);
|
w = new IndexWriter(dir, iwc);
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
assertEquals("Directory still has pending deleted files", iae.getMessage());
|
assertEquals("Directory still has pending deleted files; cannot initialize IndexWriter", iae.getMessage());
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -58,8 +59,8 @@ import org.apache.lucene.index.SegmentReader;
|
||||||
import org.apache.lucene.index.SortedSetDocValues;
|
import org.apache.lucene.index.SortedSetDocValues;
|
||||||
import org.apache.lucene.index.SortingMergePolicy;
|
import org.apache.lucene.index.SortingMergePolicy;
|
||||||
import org.apache.lucene.index.Term;
|
import org.apache.lucene.index.Term;
|
||||||
import org.apache.lucene.search.BooleanClause;
|
|
||||||
import org.apache.lucene.search.BooleanClause.Occur;
|
import org.apache.lucene.search.BooleanClause.Occur;
|
||||||
|
import org.apache.lucene.search.BooleanClause;
|
||||||
import org.apache.lucene.search.BooleanQuery;
|
import org.apache.lucene.search.BooleanQuery;
|
||||||
import org.apache.lucene.search.Collector;
|
import org.apache.lucene.search.Collector;
|
||||||
import org.apache.lucene.search.EarlyTerminatingSortingCollector;
|
import org.apache.lucene.search.EarlyTerminatingSortingCollector;
|
||||||
|
|
|
@ -45,10 +45,12 @@ import org.apache.lucene.search.suggest.Lookup.LookupResult;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
|
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@SuppressFileSystems("VirusCheckingFS")
|
||||||
public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
|
public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
|
||||||
|
|
||||||
public void testBasic() throws Exception {
|
public void testBasic() throws Exception {
|
||||||
|
|
|
@ -33,9 +33,11 @@ import org.apache.lucene.search.suggest.Input;
|
||||||
import org.apache.lucene.search.suggest.InputArrayIterator;
|
import org.apache.lucene.search.suggest.InputArrayIterator;
|
||||||
import org.apache.lucene.search.suggest.Lookup;
|
import org.apache.lucene.search.suggest.Lookup;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
|
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
|
|
||||||
|
@SuppressFileSystems("VirusCheckingFS")
|
||||||
public class BlendedInfixSuggesterTest extends LuceneTestCase {
|
public class BlendedInfixSuggesterTest extends LuceneTestCase {
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue