Package org.apache.lucene.store
Class TrackingDirectoryWrapper
- java.lang.Object
-
- org.apache.lucene.store.Directory
-
- org.apache.lucene.store.FilterDirectory
-
- org.apache.lucene.store.TrackingDirectoryWrapper
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class TrackingDirectoryWrapper extends FilterDirectory
A delegating Directory that records which files were written to and deleted.
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.store.FilterDirectory
in
-
-
Constructor Summary
Constructors Constructor Description TrackingDirectoryWrapper(Directory in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCreatedFiles()voidcopyFrom(Directory from, String src, String dest, IOContext context)Copies an existingsrcfile from directoryfromto a non-existent filedestin this directory.IndexOutputcreateOutput(String name, IOContext context)Creates a new, empty file in the directory and returns anIndexOutputinstance for appending data to this file.IndexOutputcreateTempOutput(String prefix, String suffix, IOContext context)Creates a new, empty, temporary file in the directory and returns anIndexOutputinstance for appending data to this file.voiddeleteFile(String name)Removes an existing file in the directory.Set<String>getCreatedFiles()NOTE: returns a copy of the created files.voidrename(String source, String dest)Renamessourcefile todestfile wheredestmust not already exist in the directory.-
Methods inherited from class org.apache.lucene.store.FilterDirectory
close, ensureOpen, fileLength, getDelegate, getPendingDeletions, listAll, obtainLock, openInput, sync, syncMetaData, toString, unwrap
-
Methods inherited from class org.apache.lucene.store.Directory
getTempFileName, openChecksumInput
-
-
-
-
Constructor Detail
-
TrackingDirectoryWrapper
public TrackingDirectoryWrapper(Directory in)
-
-
Method Detail
-
deleteFile
public void deleteFile(String name) throws IOException
Description copied from class:DirectoryRemoves an existing file in the directory.This method must throw either
NoSuchFileExceptionorFileNotFoundExceptionifnamepoints to a non-existing file.- Overrides:
deleteFilein classFilterDirectory- Parameters:
name- the name of an existing file.- Throws:
IOException- in case of I/O error
-
createOutput
public IndexOutput createOutput(String name, IOContext context) throws IOException
Description copied from class:DirectoryCreates a new, empty file in the directory and returns anIndexOutputinstance for appending data to this file.This method must throw
FileAlreadyExistsExceptionif the file already exists.- Overrides:
createOutputin classFilterDirectory- Parameters:
name- the name of the file to create.- Throws:
IOException- in case of I/O error
-
createTempOutput
public IndexOutput createTempOutput(String prefix, String suffix, IOContext context) throws IOException
Description copied from class:DirectoryCreates a new, empty, temporary file in the directory and returns anIndexOutputinstance for appending data to this file.The temporary file name (accessible via
IndexOutput.getName()) will start withprefix, end withsuffixand have a reserved file extension.tmp.- Overrides:
createTempOutputin classFilterDirectory- Throws:
IOException
-
copyFrom
public void copyFrom(Directory from, String src, String dest, IOContext context) throws IOException
Description copied from class:DirectoryCopies an existingsrcfile from directoryfromto a non-existent filedestin this directory. The given IOContext is only used for opening the destination file.- Overrides:
copyFromin classDirectory- Throws:
IOException
-
rename
public void rename(String source, String dest) throws IOException
Description copied from class:DirectoryRenamessourcefile todestfile wheredestmust not already exist in the directory.It is permitted for this operation to not be truly atomic, for example both
sourceanddestcan be visible temporarily inDirectory.listAll(). However, the implementation of this method must ensure the content ofdestappears as the entiresourceatomically. So oncedestis visible for readers, the entire content of previoussourceis visible.This method is used by IndexWriter to publish commits.
- Overrides:
renamein classFilterDirectory- Throws:
IOException
-
clearCreatedFiles
public void clearCreatedFiles()
-
-