LUCENE-2027: remove Directory.touchFile

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1124363 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-05-18 18:13:23 +00:00
parent deb41ad1f1
commit 62a40f5c36
13 changed files with 3 additions and 99 deletions

View File

@ -530,6 +530,9 @@ API Changes
ClassCastException when loading lazy fields or NumericFields.
(Uwe Schindler, Ryan McKinley, Mike McCandless)
* LUCENE-2027: Directory.touchFile is deprecated and will be removed
in 4.0. (Mike McCandless)
Optimizations
* LUCENE-2990: ArrayUtil/CollectionUtil.*Sort() methods now exit early

View File

@ -199,17 +199,6 @@ public class JEDirectory extends Directory {
return new JELock();
}
@Override
public void touchFile(String name) throws IOException {
File file = new File(name);
long length = 0L;
if (file.exists(this))
length = file.getLength();
file.modify(this, length, System.currentTimeMillis());
}
/**
* Once a transaction handle was committed it is no longer valid. In order
* to continue using this JEDirectory instance after a commit, the

View File

@ -222,19 +222,6 @@ public class DbDirectory extends Directory {
return new DbLock();
}
@Override
public void touchFile(String name)
throws IOException
{
File file = new File(name);
long length = 0L;
if (file.exists(this))
length = file.getLength();
file.modify(this, length, System.currentTimeMillis());
}
/**
* Once a transaction handle was committed it is no longer valid. In
* order to continue using this DbDirectory instance after a commit, the

View File

@ -134,15 +134,6 @@ public class NRTCachingDirectory extends Directory {
}
}
@Override
public synchronized void touchFile(String name) throws IOException {
if (cache.fileExists(name)) {
cache.touchFile(name);
} else {
delegate.touchFile(name);
}
}
@Override
public synchronized void deleteFile(String name) throws IOException {
// Delete from both, in case we are currently uncaching:

View File

@ -189,12 +189,6 @@ public class CompoundFileReader extends Directory {
return directory.fileModified(fileName);
}
/** Set the modified time of the compound file to now. */
@Override
public void touchFile(String name) throws IOException {
directory.touchFile(fileName);
}
/** Not implemented
* @throws UnsupportedOperationException */
@Override

View File

@ -65,10 +65,6 @@ public abstract class Directory implements Closeable {
public abstract long fileModified(String name)
throws IOException;
/** Set the modified time of an existing file to now. */
public abstract void touchFile(String name)
throws IOException;
/** Removes an existing file in the directory. */
public abstract void deleteFile(String name)
throws IOException;

View File

@ -272,14 +272,6 @@ public abstract class FSDirectory extends Directory {
return file.lastModified();
}
/** Set the modified time of an existing file to now. */
@Override
public void touchFile(String name) {
ensureOpen();
File file = new File(directory, name);
file.setLastModified(System.currentTimeMillis());
}
/** Returns the length in bytes of a file in the directory. */
@Override
public long fileLength(String name) throws IOException {

View File

@ -114,11 +114,6 @@ public class FileSwitchDirectory extends Directory {
return getDirectory(name).fileModified(name);
}
@Override
public void touchFile(String name) throws IOException {
getDirectory(name).touchFile(name);
}
@Override
public void deleteFile(String name) throws IOException {
getDirectory(name).deleteFile(name);

View File

@ -27,8 +27,6 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.lucene.util.ThreadInterruptedException;
/**
* A memory-resident {@link Directory} implementation. Locking
* implementation is by default the {@link SingleInstanceLockFactory}
@ -112,30 +110,6 @@ public class RAMDirectory extends Directory {
return file.getLastModified();
}
/** Set the modified time of an existing file to now.
* @throws IOException if the file does not exist
*/
@Override
public void touchFile(String name) throws IOException {
ensureOpen();
RAMFile file = fileMap.get(name);
if (file == null) {
throw new FileNotFoundException(name);
}
long ts2, ts1 = System.currentTimeMillis();
do {
try {
Thread.sleep(0, 1);
} catch (InterruptedException ie) {
throw new ThreadInterruptedException(ie);
}
ts2 = System.currentTimeMillis();
} while(ts1 == ts2);
file.setLastModified(ts2);
}
/** Returns the length in bytes of a file in the directory.
* @throws IOException if the file does not exist
*/

View File

@ -26,7 +26,6 @@ public class RAMFile {
RAMDirectory directory;
protected long sizeInBytes;
// This is publicly modifiable via Directory.touchFile(), so direct access not supported
private long lastModified = System.currentTimeMillis();
// File used as buffer, in no RAMDirectory

View File

@ -559,12 +559,6 @@ public class MockDirectoryWrapper extends Directory {
return delegate.fileModified(name);
}
@Override
public synchronized void touchFile(String name) throws IOException {
maybeYield();
delegate.touchFile(name);
}
@Override
public synchronized long fileLength(String name) throws IOException {
maybeYield();

View File

@ -411,10 +411,6 @@ public class TestFieldsReader extends LuceneTestCase {
return fsDir.fileModified(name);
}
@Override
public void touchFile(String name) throws IOException {
fsDir.touchFile(name);
}
@Override
public void deleteFile(String name) throws IOException {
fsDir.deleteFile(name);
}

View File

@ -345,12 +345,6 @@ public class TestBufferedIndexInput extends LuceneTestCase {
dir.deleteFile(name);
}
@Override
public void touchFile(String name)
throws IOException
{
dir.touchFile(name);
}
@Override
public long fileModified(String name)
throws IOException
{