public final class TrackingDirectoryWrapper extends FilterDirectory
in
Constructor and Description |
---|
TrackingDirectoryWrapper(Directory in) |
Modifier and Type | Method and Description |
---|---|
void |
clearCreatedFiles() |
void |
copyFrom(Directory from,
String src,
String dest,
IOContext context)
Copies the file src in from to this directory under the new
file name dest.
|
IndexOutput |
createOutput(String name,
IOContext context)
Creates a new, empty file in the directory with the given name.
|
IndexOutput |
createTempOutput(String prefix,
String suffix,
IOContext context)
Creates a new, empty file for writing in the directory, with a
temporary file name including prefix and suffix, ending with the
reserved extension
.tmp . |
void |
deleteFile(String name)
Removes an existing file in the directory.
|
Set<String> |
getCreatedFiles()
NOTE: returns a copy of the created files.
|
void |
renameFile(String source,
String dest)
Renames
source to dest as an atomic operation,
where dest does not yet exist in the directory. |
close, fileLength, getDelegate, listAll, obtainLock, openInput, sync, toString, unwrap
ensureOpen, openChecksumInput
public TrackingDirectoryWrapper(Directory in)
public void deleteFile(String name) throws IOException
Directory
deleteFile
in class FilterDirectory
IOException
public IndexOutput createOutput(String name, IOContext context) throws IOException
Directory
createOutput
in class FilterDirectory
IOException
public IndexOutput createTempOutput(String prefix, String suffix, IOContext context) throws IOException
Directory
.tmp
. Use
IndexOutput.getName()
to see what name was used.createTempOutput
in class FilterDirectory
IOException
public void copyFrom(Directory from, String src, String dest, IOContext context) throws IOException
Directory
If you want to copy the entire source directory to the destination one, you can do so like this:
Directory to; // the directory to copy to for (String file : dir.listAll()) { to.copyFrom(dir, file, newFile, IOContext.DEFAULT); // newFile can be either file, or a new name }
NOTE: this method does not check whether dest exist and will overwrite it if it does.
copyFrom
in class Directory
IOException
public void renameFile(String source, String dest) throws IOException
Directory
source
to dest
as an atomic operation,
where dest
does not yet exist in the directory.
Notes: This method is used by IndexWriter to publish commits.
It is ok if this operation is not truly atomic, for example
both source
and dest
can be visible temporarily.
It is just important that the contents of dest
appear
atomically, or an exception is thrown.
renameFile
in class FilterDirectory
IOException
public void clearCreatedFiles()
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.