mirror of https://github.com/apache/lucene.git
Remove IW.slowFileExists, since it's only called from "used to be helpful but now useless" asserts:
- Directory.copyFrom now throws an exception if the test already exists - Directory.sync now throws an exception if a file name didn't already exist
This commit is contained in:
parent
42e1caf2bf
commit
044aabfb30
|
@ -17,9 +17,7 @@
|
||||||
package org.apache.lucene.index;
|
package org.apache.lucene.index;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.NoSuchFileException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -2885,9 +2883,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
||||||
// Copy the segment's files
|
// Copy the segment's files
|
||||||
for (String file: info.files()) {
|
for (String file: info.files()) {
|
||||||
final String newFileName = newInfo.namedForThisSegment(file);
|
final String newFileName = newInfo.namedForThisSegment(file);
|
||||||
|
|
||||||
assert !slowFileExists(directory, newFileName): "file \"" + newFileName + "\" already exists; newInfo.files=" + newInfo.files();
|
|
||||||
|
|
||||||
directory.copyFrom(info.info.dir, file, newFileName, context);
|
directory.copyFrom(info.info.dir, file, newFileName, context);
|
||||||
copiedFiles.add(newFileName);
|
copiedFiles.add(newFileName);
|
||||||
}
|
}
|
||||||
|
@ -4542,7 +4537,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
||||||
|
|
||||||
Collection<String> files = toSync.files(false);
|
Collection<String> files = toSync.files(false);
|
||||||
for(final String fileName: files) {
|
for(final String fileName: files) {
|
||||||
assert slowFileExists(directory, fileName): "file " + fileName + " does not exist; files=" + Arrays.toString(directory.listAll());
|
|
||||||
// If this trips it means we are missing a call to
|
// If this trips it means we are missing a call to
|
||||||
// .checkpoint somewhere, because by the time we
|
// .checkpoint somewhere, because by the time we
|
||||||
// are called, deleter should know about every
|
// are called, deleter should know about every
|
||||||
|
@ -4999,19 +4993,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
||||||
void process(IndexWriter writer, boolean triggerMerge, boolean clearBuffers) throws IOException;
|
void process(IndexWriter writer, boolean triggerMerge, boolean clearBuffers) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used only by asserts: returns true if the file exists
|
|
||||||
* (can be opened), false if it cannot be opened, and
|
|
||||||
* (unlike Java's File.exists) throws IOException if
|
|
||||||
* there's some unexpected error. */
|
|
||||||
static boolean slowFileExists(Directory dir, String fileName) throws IOException {
|
|
||||||
try {
|
|
||||||
dir.openInput(fileName, IOContext.DEFAULT).close();
|
|
||||||
return true;
|
|
||||||
} catch (NoSuchFileException | FileNotFoundException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Anything that will add N docs to the index should reserve first to
|
/** Anything that will add N docs to the index should reserve first to
|
||||||
* make sure it's allowed. This will throw {@code
|
* make sure it's allowed. This will throw {@code
|
||||||
* IllegalArgumentException} if it's not allowed. */
|
* IllegalArgumentException} if it's not allowed. */
|
||||||
|
|
Loading…
Reference in New Issue